0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-16 20:26:19 -05:00

refactor(core): update per comments

This commit is contained in:
Gao Sun 2021-09-01 17:52:55 +08:00
parent 7c6602a1ac
commit 9ccb66ddfd
No known key found for this signature in database
GPG key ID: 0F0EFA2E36639F31
2 changed files with 3 additions and 3 deletions

View file

@ -19,7 +19,7 @@ const resolveLanguage = (languageString: string): Optional<[string, number]> =>
for (const item of rest) {
const [key, value] = item.split('=');
if (key === 'q' && !Number.isNaN(Number(value))) {
if (key === 'q' && !Number.isNaN(value)) {
return [language, Number(value)];
}
}

View file

@ -23,11 +23,11 @@ export default function koaI18next<
const languages = detectLanguage(ctx);
// Cannot patch type def directly, see https://github.com/microsoft/TypeScript/issues/36146
const languageUtils = i18next.services.languageUtils as LanguageUtils;
const found = languages
const foundLanguage = languages
.map((code) => languageUtils.formatLanguageCode(code))
.find((code) => languageUtils.isSupportedCode(code));
await i18next.changeLanguage(found);
await i18next.changeLanguage(foundLanguage);
ctx.locale = i18next.language;
return next();
};