Type for injection token that provides fallback locale used in the module
Type for injection token that provides number of locales that should be loaded in the module
Type for injection token that provides some kind of locale loader for use in the module
Injection token that provides fallback locale used in the module
Injection token that provides number of locales that should be loaded in the module
Injection token that provides some kind of locale loader for use in the module
Simple translation loader type for e.g. inline loaders
Generated using TypeDoc
@ization/translate
Install
Install ization Core, this plugin, and other required packages:
Optionally also install
@messageformatCLI:Configure
Configure
@ization/corefirst. Then, import the main module of this plugin into your app module usingIzTranslateModule.withConfigstatic method and define configuration of this plugin:translationLoaderis a function that returns a Promise that resolves into an object of translations for that particular locale. In Angular projects, the best way is to have one code chunk per locale and load them using dynamicimport(). See Demo app for such loader, including how to use messageFormat CLI to generate these chunks from YAML files.You can override locale code used by this plugin in
IzCoreModule.withLocalesobject viatranslateLocaleCodeproperty.Use
izTranslatePipe'TRANSLATION_KEY'- Translation key to look up in loaded translations. Translations can be nested, in such case translation key uses dot as a separator. Locale to use is choosed automatically via@ization/coreand using configuration of this module.params- Translation params. An object of (mostly) strings to use for variable interpolation and formatters. See Demo app for examples and MessageFormat docs for more info.Returns translated string. Until
@ization/coreis initialized, returns empty string. When translation key is not found in any loaded locale, returns empty string and emits a warning into console.Develop
Build
Run
npm run build:translateto build the package into thedist/translate/directory.Unit tests
Run
npm run test:translateto execute the unit tests.Linter
Run
npm run lint:translateto run linter on all code, including spec files.