ng-kumo-languagemanager

LanguageManager factory that allow easy management for HTTP headers/amplify/gettext/dynLocales.


Keywords
angular, dynamic-locales, gettext, amplify, coffeescript
License
MIT
Install
bower install ng-kumo-languagemanager

Documentation

LanguageManager for angular

Easy peasy bro

This simple turnkey solution that combines gettext, dynamic language, amplify local storing and a $rootScope.language.

It's only a singleton angular factory called languageManager. Setting a language will do all these things:

  • Set the gettextCatalog and the angular translation.
  • Set add $rootScope var "language" representing the current language.
  • Add an "Accept-Lanauge" header to all $http requests (ex format: 'fr').
  • Switch the dynamic language file for all dates and other ng integrated strings.
  • Store the language code in amplify via the 'language' key

Be sure to follow these steps for a complete setup

  • Setup the angular i18n files to this kind of path /angular/i18n/angular-locale_am-et.js

  • Build some translation.js using angular-gettext

  • Simply activate the languageManager via something like this.

    angular ("yourmodule", ['language-management']) .run (languageManager) -> languageManager.set()

Getting current language

languageManager.current() # fr_CA
languageManager.showCurrent() # fr

Setting current language

languageManager.set("fr_CA")

Handling language changes

languageManager.onChange().then (code) ->
  console.log code #logs fr_CA