Skip to content

Latest commit

 

History

History
55 lines (48 loc) · 1.41 KB

README.md

File metadata and controls

55 lines (48 loc) · 1.41 KB

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.