I tried to find documentation in AngularJS for supporting multiple languages with no success. Is localization supported?
AngularJS support has officially ended as of January 2022.
As of January 1, 2022, Google no longer updates AngularJS to fix security, browser compatibility, or jQuery issues. The Angular team recommends upgrading to Angular (v2+) as the best path forward, but they also provided some other options.
AngularJS supports inbuilt internationalization for three types of filters currency, date and numbers. We only need to incorporate corresponding js according to locale of the country. By default it handles the locale of the browser.
One promising 3rd party library is the AngularJS localization module angular-l10n. It provides translations in directives or through filters. It uses interpolations, which allow you to insert values in strings. And it even has a locale switching feature.
Take a look at angular-translate: https://github.com/angular-translate/angular-translate
for all DIY folks:
You can find localized files for angular: here
These files will help you with the build-in angular filters: date, currency and number. Amazing... so far.
Now you want to use your own texts, than all you need is the power of angular.js dependency injection. Create a new file like: "myTexts_en_us.js" and use $provide.value like this:
$provide.value("myTexts", {firstText : "This is my localized text"});
For details:
http://jsfiddle.net/4tRBY/24/
For real-world-use, you should add a filter: http://jsfiddle.net/4tRBY/41/
Tips:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With