Using the JiT Compiler
The JiT (Just-in-time) compiler compiles the application dynamically, as the application loads. To do this, we will need to rely on 3 providers that tell the JiT compiler how to translate the template texts for a particular language:
TRANSLATIONS
is a string containing the content of the translation file.TRANSLATIONS_FORMAT
is the format of the file.LOCALE_ID
is the locale of the target language.
Here's how to boostrap the app with the translation providers for French. We're assuming the translation file is messages.fr.xlf
.
app/index.ts:
We're using webpack and raw-loader
to load the load the translations. We could alternatively make an http call based on which language we're interested in, and asynchronously bootstrap the app once its loaded.
Last updated