Migration guide to angular-l10n v9 for Angular v9
angular-l10n v9 is basically a new library built on top of new Angular Ivy's view engine. The best way to upgrade from a previous version is to follow the new README step by step.
-
Update Configuration: except for boolean
cache,fallbackanddefaultRouting, all other attributes are required. -
Customize services: the services offer only the basic functionalities, and according to the needs you have to customize them by implementing the class-interface and passing the token during the configuration. If you are using json files or a Web API, you have to implement
L10nTranslationLoaderclass-interface. -
Update Pure pipes:
translatepipe: no changesl10nDatenow it uses Intl.DateTimeFormatOptionsl10nDecimal,l10nPercentandl10nCurrencyare nowl10nNumberpipe, that uses Intl.NumberFormatOptions
Language, DefaultLocale, Currency and Timezone decorators are no longer available, and you must replace them with the injection token
L10N_LOCALE.Also extended classes such as
TranslationandLocalizationare no longer available, but you can easily implement your own superclass by providing theL10nlocale. -
Update Directives:
l10nTranslatedirective: no changesl10nDatenow it uses Intl.DateTimeFormatOptionsl10nDecimal,l10nPercentandl10nCurrencyare nowl10nNumberdirective, that uses Intl.NumberFormatOptions
-
Update APIs: all the translation APIs are now provided by
L10nTranslationService. The APIs for localizing dates and numbers are provided by the new classL10nIntlService. -
Update Validation: the new validation is only a skeleton that needs to be customized. You can find an example in the sample app. The old
LocaleValidationclass is still available here
forChild method is no longer supported. Use a resolver as explained here
Except for routing, translation of title and meta tags, as well as JSON-LD, are no longer available. However, these classes and components are still available in the old branch:
This is no longer available. You can find the old class here