diff --git a/packages/next-international/src/app/middleware/index.ts b/packages/next-international/src/app/middleware/index.ts index 530d07f..f4a3727 100644 --- a/packages/next-international/src/app/middleware/index.ts +++ b/packages/next-international/src/app/middleware/index.ts @@ -78,7 +78,7 @@ function localeFromRequest( const defaultResolveLocaleFromRequest: NonNullable['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; }; diff --git a/packages/next-international/src/common/create-t.ts b/packages/next-international/src/common/create-t.ts index 6516b25..d0ad797 100644 --- a/packages/next-international/src/common/create-t.ts +++ b/packages/next-international/src/common/create-t.ts @@ -25,7 +25,7 @@ export function createT 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); @@ -62,7 +62,7 @@ export function createT 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();