Skip to content

Dynamically load a new locale on runtime? #663

Answered by ivanhofer
alkstal asked this question in Q&A
Discussion options

You must be logged in to vote

By default typesafe-i18n generates a lot of boilerplate code for you. This works fine for 95% of projects I guess. If you want to customize the behavior, just set the generateOnlyTypes-option to true and modify the files like you need them.

If you just want to load locales in a different way you can also manually set the loadedLocales object inside i18n/i18n-util.ts.

If you really want to opt opt of the typesafety features, you can load Translations via a ´fetch` calls in runtime, but you will not know if the translated strings contain an error.

I know of some companies that use a combined approach. They save translations to the Git repo once per day to check if translations contain an er…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@alkstal
Comment options

Answer selected by alkstal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants