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

web-education/idiom

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

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!"
}

About

Context based translation system

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published