Skip to content

georgiyordanov/angular-l10n

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

L10n module for Angular.js


Installation

angular.module('MyApp', ['l10n']);

Create your own localization resources

en.js

angular.module('my-l10n-en', ['l10n']).config(['l10nProvider', function(l10n){
	l10n.add('en-us', {
		myPage: {
			myString: 'This is my string in English'
		}
	});
}])

ru.js

angular.module('my-l10n-ru', ['l10n']).config(['l10nProvider', function(l10n){
	l10n.add('ru-ru', {
		myPage: {
			myString: 'Моя строчка на русском'
		}
	});
}]

Then add it into your module requires:

angular.module('MyApp', ['l10n', 'my-l10n-en']);

Usage

As a service

angular.module('MyApp').controller('MyCtrl', function(l10n){ l10n.get('myPage.myString') })

As a directive

First you need to add l10n-tools as you module requirment

angular.module('MyApp', ['l10n', 'l10n-tools']);

then you will get following attribute directives:

  • l10n-html - set localized value as element HTML
  • l10n-text - set localized value as element text content
  • l10n-title, l10n-href, l10n-placeholder - set localized value as corresponding attribute value

See demo for more features and examples of usage.

About

L10n module for Angular.js

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 59.2%
  • CoffeeScript 40.8%