localService setup translations angular code example

Example 1: i18n angular

content_copy
      
      <span i18n>Updated: {minutes, plural,
  =0 {just now}
  =1 {one minute ago}
  other {{{minutes}} minutes ago by {gender, select, male {male} female {female} other {other}}}}
</span>

Example 2: i18n angular

content_copy
      
      ng xi18n --out-file source.xlf

Example 3: multilanguage site angular

//Installing:
//Terminal
$ npm install --save-dev angular-translate
//Embed in the html doc
<script src="path/to/angular-translate.js"></script>
//In the component.ts
var app = angular.module('myApp', ['pascalprecht.translate']);

app.config(['$translateProvider', function ($translateProvider) {
  $translateProvider.translations('en', {
    'TITLE': 'Hello',
    'FOO': 'This is a paragraph'
  });
 
  $translateProvider.translations('de', {
    'TITLE': 'Hallo',
    'FOO': 'Dies ist ein Absatz'
  });
 
  $translateProvider.preferredLanguage('en');
}]);
//In the component.html
<h1>{{ 'TITLE' | translate }}</h1>
<p>{{ 'FOO' | translate }}</p>