Giter VIP home page Giter VIP logo

angular-ngi18n's Introduction

angular-ngi18n

Provides internationalization to angularJS projects. Requires $resource

bower install angular-ngi18n

Get Started

<script src="dist/angular-ngi18n.js"></script>
...
angular.module('yourApp', ['ngI18n'])
...
.controller('MainCtrl', function ($scope, $i18n) {

Demo

Demo

Configuration

(angular-ngi18n.js)
var config = {
    files       : 'i18n/:lang.json',    //Ex : 'i18n/en.json'
    languages   : ['en', 'fr']          //config.languages[0] == default
};

Sample

I am 26 years old

<i>{{'how.old.are.you' | i18n:[26]}}</i>

Sample

This is the translation of 'key.in.i18n.file' key
<i>{ {'key.in.i18n.file' | i18n} }</i>

{
    ...
    "key.in.i18n.file" : "This is the translation of 'key.in.i18n.file' key",
    ...
}

Sample

<form ng-submit="submitForm()">
    <div class="form-group">
        <label for="exampleSelect">{ {'choose.language' | i18n} } :</label>
        <select id="exampleSelect" ng-model="currentLang" ng-change="changeLanguage()">
            <option value="en" selected="selected">English</option>
            <option value="fr" selected="selected">Français</option>
        </select>
    </div>
</form>
...
$scope.currentLang = $i18n.getLanguage();

$scope.changeLanguage = function(){
    $i18n.changeLanguage(this.currentLang);
};

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.