Config Options

Let's explain each one of the config options:

  • reRenderOnLangChange: Applications that don't allow the user to change the language in runtime (i.e., from a dropdown), should leave it false. It can save on memory by rendering the view once and unsubscribing from the language changes event (defaults to false):

translocoConfig({
...
reRenderOnLangChange: boolean
})
  • defaultLang: Sets the default language: (defaults to en)

translocoConfig({
...
defaultLang: 'en'
})
  • fallbackLang: Sets the default language/s to use as a fallback. See the TranslocoFallbackStrategy section if you need to customize it:

translocoConfig({
...
fallbackLang: 'en' // or as array ['en', 'ru']
})
  • failedRetries: How many time should Transloco retry to load translation files, in case of a load failure (defaults to 2):

translocoConfig({
...
failedRetries: 1
})
  • prodMode: Whether the application runs in production mode: (defaults to false)

import { environment } from '../environments/environment';
translocoConfig({
...
prodMode: environment.production
})
  • availableLangs: The available languages in your application:

translocoConfig({
...
availableLangs: ['en', 'es']
})
  • missingHandler.allowEmpty: Whether to allow empty values: (defaults to false)

translocoConfig({
...
missingHandler: {
allowEmpty: true
}
})
  • missingHandler.useFallbackTranslation: Whether to use the fallback language for missing keys or values: (defaults to false)

translocoConfig({
...
fallbackLang: 'en',
missingHandler: {
// will use the first language set in the `fallbackLang` property
useFallbackTranslation: true
}
})
  • missingHandler.logMissingKey: Whether to console.warn a missing key: (defaults to true)

translocoConfig({
...
missingHandler: {
logMissingKey: false
}
})
  • flatten.aot: Check the optimization plugin:

import { environment } from '../environments/environment';
translocoConfig({
...
flatten: {
aot: environment.production
}
})