ng-translate

1.0.3 • Public • Published

ngTranslate

Simple multi language in an AngularJS application

This repo is for distribution on npm only.

Install

You can install this package with npm only.

npm

npm install ng-translate

Then add ngTranslate as a dependency for your app:

angular.module('myApp', ['ngTranslate']);

Initialize ngTranslate on run of application

$translate.Config({
  default :'en_US',
  languages :[
    'nl_NL'
  ]
});

Create folder in the root of your applicatie with name: languages

You will place your language files inside the language folder. File name format as follow: en_US.lang.json. An example file:

{
    "locale": "en_US",
    "name":"EN_LANG",
    "words": {
        "APP_TITLE" : "Example App",
        "SETTINGS":"Settings",
    "EN_LANG": "English",
    "NL_LANG":"Dutch",
    "LANGUAGE":"Language"
    }
}

Using in your application

Change the language in the application

$translate.ChangeLanguage('nl_NL');

Get current language name, name must be exists in the *.lang.json file

$translate.GetCurrentLanguage();

Use translation as filter inside your template

<div id="example">{{ 'APP_TITLE' | translate }}</div>

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.3
    7
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.3
    7
  • 1.0.2
    0
  • 1.0.1
    0
  • 1.0.0
    0

Package Sidebar

Install

npm i ng-translate

Weekly Downloads

7

Version

1.0.3

License

MIT

Last publish

Collaborators

  • psykosoldi3r