Translate your angular application with angular translate by Pascal Precht. It's a module consisting of filters, services and directives for translating various strings.
11. How do I include this in my
App?
1. Load the Script!
<script src="angular-translate.js"></script>
12. How do I include this in my
App?
2. Include it into your module!
var app = angular.module('translate',
[‘pascalprecht.translate']);
13. How do I include this in my
App?
3. Configure it!
app.config(function($translateProvider) {!
$translateProvider.translations('es', {!
HELLO: '¡Hola'!
});!
$translateProvider.preferredLanguage(‘es’);!
$translateProvider.fallbackLanguage(‘en’);!
});
14. How do I include this in my
App?
4. Include the translate filter in your templates!
<h1>{{ 'HELLO' | translate }} {{ name }}</h1>
17. Change the language?
1. Some buttons with ng-click!
<button ng-click="translate('de')">deutsch</button>!
<button ng-click="translate('en')">english</button>!
<button ng-click="translate('es')">español</button>!
<button ng-click="translate('jp')">日本の</button>
18. Change the language?
2. The $translate-Service in the controller!
app.controller('contentCtrl', ['$scope',
'$translate', function($scope, $translate) {