Skip to content
This repository has been archived by the owner on Jan 30, 2019. It is now read-only.

Latest commit

 

History

History
44 lines (34 loc) · 1.18 KB

README.md

File metadata and controls

44 lines (34 loc) · 1.18 KB

idiom

Idiom is a new translation system for AngularJS that allows you to read in the current scope to provide context-based translations - no more thing(s), s/he, his/her, you actually know what you're writing about.

#Usage

Add a folder to your project containing one json file per language (en.json, fr.json, de.json...). In the file, a simple key-value system allows you to write your translations :

{
    "title": "Title",
    "description": "This is my description"
}

You then need to set the translation folder and add the directives to your module:

idiom.addTranslations('/path/to/my/folder', function(){
    idiom.translate('my.key');
});
var module = angular.module('app');
idiom.addDirectives(module);

In your view, you can use the directives to translate content :

<i18n>my.key</i18n>
<input type="button" i18n-value="my.key" />
<input type="text" i18n-placeholder="my.key" />

Your translations can directly use your current scope:

{
    "welcome": "Welcome, {{user.name}}!",
    "description": "<span ng-if="user.male">He</span><span ng-if="user.female">She</span>'s awesome!"
}