Replies: 1 comment
-
//lingui.config
{
locales: ["en", "br"],
} runtime app const supportedLocalesMap = {
"en-GB": "en",
"en-US": "en",
"pt-BR": "pt",
"pt-PT": "pt",
}
const userLocale = detectLocale(`[...]`); // for example `en-GB`
export async function loadCatalog(locale: string) {
const { messages } = await import(`@lingui/loader!../locales/${locale}/messages.po`);
return messages;
}
const catalogLocale = supportedLocalesMap[supportedLocalesMap]
// will use `en-GB` locale for date / number formatting but load mesages from `en` catalog
i18n.load(userLocale, await loadCatalog(catalogLocale))
i18n.activate(userLocale) locales from lingui.config used only for extracting/compilation (just a list of files which would be created / compiled). In runtime app you can do whatever logic for choosing locale or catalog. There is room for creativity |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
For example, Chinese locales have multiple regional locales with their own sematic naming format. But that is not very user friendly for URL accesses. And Japanese/Korean locale naming is different from its top level domain.
Is it possible to alias them in Lingui.config? If not, is it possible to change them somewhere using middleware, and how to do that?
Beta Was this translation helpful? Give feedback.
All reactions