DEV Community

Cover image for Extend @ngx-translate/core Feature with @rxweb/ngx-translate-extension
Ushmi Dave
Ushmi Dave

Posted on

3 1

Extend @ngx-translate/core Feature with @rxweb/ngx-translate-extension

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 :

article4.gif

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

article1.gif

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:

article2.gif

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

article3.gif

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.

AWS Q Developer image

Your AI Code Assistant

Ask anything about your entire project, code and get answers and even architecture diagrams. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Start free in your IDE

Top comments (2)

Collapse
 
waterstraal profile image
Mike Markus • Edited

The ngx-translate project is kind of dead

I would suggest looking into Transloco instead

Collapse
 
ushmidave profile image
Ushmi Dave

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

👋 Kindness is contagious

Explore a trove of insights in this engaging article, celebrated within our welcoming DEV Community. Developers from every background are invited to join and enhance our shared wisdom.

A genuine "thank you" can truly uplift someone’s day. Feel free to express your gratitude in the comments below!

On DEV, our collective exchange of knowledge lightens the road ahead and strengthens our community bonds. Found something valuable here? A small thank you to the author can make a big difference.

Okay