Skip to main content

Config Options

Below is a list of the config options and their usages:

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',
fallbackLang: ['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) When enabled, Transloco will disable all console warnings.

import { isDevMode } from '@angular/core';

translocoConfig({
prodMode: !isDevMode(),
});

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: {
// It 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 { isDevMode } from '@angular/core';

translocoConfig({
flatten: {
aot: !isDevMode(),
},
});

interpolation

The start and end markings for parameters: (defaults to ['{{', '}}'])

translocoConfig({
// This will enable you to specify parameters as such: `"Hello <<<value>>>"`
interpolation: ['<<<', '>>>'],
});

scopes.keepCasing

This will make sure that the casing of the provided scope name is not altered, given that no alias has been set otherwise this setting will be ignored.

translocoConfig({
scopes: {
keepCasing: false
}
})