mirror of
https://github.com/logto-io/logto.git
synced 2025-01-06 20:40:08 -05:00
refactor(core): update per comments
This commit is contained in:
parent
7c6602a1ac
commit
9ccb66ddfd
2 changed files with 3 additions and 3 deletions
|
@ -19,7 +19,7 @@ const resolveLanguage = (languageString: string): Optional<[string, number]> =>
|
||||||
|
|
||||||
for (const item of rest) {
|
for (const item of rest) {
|
||||||
const [key, value] = item.split('=');
|
const [key, value] = item.split('=');
|
||||||
if (key === 'q' && !Number.isNaN(Number(value))) {
|
if (key === 'q' && !Number.isNaN(value)) {
|
||||||
return [language, Number(value)];
|
return [language, Number(value)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,11 +23,11 @@ export default function koaI18next<
|
||||||
const languages = detectLanguage(ctx);
|
const languages = detectLanguage(ctx);
|
||||||
// Cannot patch type def directly, see https://github.com/microsoft/TypeScript/issues/36146
|
// Cannot patch type def directly, see https://github.com/microsoft/TypeScript/issues/36146
|
||||||
const languageUtils = i18next.services.languageUtils as LanguageUtils;
|
const languageUtils = i18next.services.languageUtils as LanguageUtils;
|
||||||
const found = languages
|
const foundLanguage = languages
|
||||||
.map((code) => languageUtils.formatLanguageCode(code))
|
.map((code) => languageUtils.formatLanguageCode(code))
|
||||||
.find((code) => languageUtils.isSupportedCode(code));
|
.find((code) => languageUtils.isSupportedCode(code));
|
||||||
|
|
||||||
await i18next.changeLanguage(found);
|
await i18next.changeLanguage(foundLanguage);
|
||||||
ctx.locale = i18next.language;
|
ctx.locale = i18next.language;
|
||||||
return next();
|
return next();
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue