In this article, we will explore how to migrate an exisiting ngx-translate project to @rxweb/ngx-translate-extension which performs translation in the angular application
@rxweb/ngx-translate-extension is an extensible library available with lots of spectacular features which can be used by existing ngx-translate projects as well as non translate integrated projects. This library is designed to perform an extensible, spectatular, simplified and powerful internationalization in an angular application. To know more about this translation package view this article on Why @rxweb/ngx-translate-extension is intuitive than others ?
While looking for the best optimum solution to internationalize the angular project i went through a project on github. This project includes resolving the translation service and using attribute directives and pipes using manual language changing strategy
For existing @ngx-translate projects
Here is How To migrate the existing project and use the extensible features of @rxweb/ngx-translate-extension
I have cloned the github project of angular-localization-ngx and installed the nodemodules using command npm i
, It contains one feeback forms which language changing manaually using code in the navbar and the output is as below :
Considering this github project example we need to follow the steps as mentioned below:
Installation
In the project install the necessary packages using below command :
npm i @rxweb/translate @rxweb/ngx-translate-extension
Import Translate Module
Resolve the translate module in app.module.ts by changing the import from @ngx-translate/core to @rxweb/ngx-translate-extension and resolve the global file path as below:
Translate Service Import
In the translate service file change the import the same way as done previously in the root module
The project is now migrated and ready to use the extended features provided by these packages. To ensure whether everything is running perfect and no service is broken check the spec comparison page where the same code is copied by following same steps of @ngx-translate/core
Conclusion
Here we covered the process to migrate the existing translation project to @rxweb/ngx-translate-extension
Among all the features covered by this package the most intuitive features are decorators, sanitizers which arent available in any other translation package currently, Besides this it includes power tool to optimize the translation keys including a powerful CLI
The complete information about this package is covered into the docs, You can share your comments and and suggestions on gitter channel.
Top comments (2)
The ngx-translate project is kind of dead
I would suggest looking into Transloco instead
You are right the ngx-translate is dead project, but this articles helps that how someone can extend the translation features with rxweb/ngx-translate-extension, for more information refer to this comment