Search code examples
angularjslocalizationinternationalizationlocaleangular-translate

AngularJS: Need language information in angularjs from language code


In android, I am able to retrieve the language information from the language code itself using Locale class as shown below.

Locale locale = new Locale("fr");
locale.getDisplayName(locale); // Français
locale.getDisplayName(Locale.ENGLISH)); // French

I need the above information to be retrieved in angularjs from the language code alone. Is it possible to retrieve in HTML directly ?


Solution

  • A little late on this one, though there is a native API for this, window.Navigator.language.

    For example:

    console.log(window.Navigator.language);  // 'en-US'