Skip to content

Commit

Permalink
Merge branch 'main' into ref/enforce-types-imports
Browse files Browse the repository at this point in the history
  • Loading branch information
Yovach authored Oct 11, 2023
2 parents 082075e + c38b52e commit 0854f60
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/next-international/src/app/middleware/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function localeFromRequest<Locales extends readonly string[]>(

const defaultResolveLocaleFromRequest: NonNullable<I18nMiddlewareConfig<any>['resolveLocaleFromRequest']> = request => {
const header = request.headers.get('Accept-Language');
const locale = header?.split(',')?.[0]?.split('-')?.[0];
const locale = header?.split(',', 1)?.[0]?.split('-', 1)?.[0];
return locale ?? null;
};

Expand Down
4 changes: 2 additions & 2 deletions packages/next-international/src/common/create-t.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function createT<Locale extends BaseLocale, Scope extends Scopes<Locale>
const pluralKeys = new Set(
Object.keys(content)
.filter(key => key.includes('#'))
.map(key => key.split('#')[0]),
.map(key => key.split('#', 1)[0]),
);

const pluralRules = new Intl.PluralRules(context.locale);
Expand Down Expand Up @@ -63,7 +63,7 @@ export function createT<Locale extends BaseLocale, Scope extends Scopes<Locale>
let value = scope ? content[`${scope}.${key}`] : content[key];

if (!value && isPlural) {
const baseKey = key.split('#')[0] as Key;
const baseKey = key.split('#', 1)[0] as Key;
value = (content[`${baseKey}#other`] || key)?.toString();
} else {
value = (value || key)?.toString();
Expand Down

0 comments on commit 0854f60

Please sign in to comment.