@andrewwormald/i18n-extended
v1.4.2
Published
![logo](https://raw.githubusercontent.com/SwiftySpartan/i18n-extended/master/angular.png)
Downloads
86
Maintainers
Readme
Completing everything that is missing in Angular's i18n package
i18n-extended
created by Andrew Wormald
SwiftySpartan / @andrewwormald
####Notes
Installation:
Step 1:
npm install -g @andrewwormald/i18n-extended@latest --save
Step 2:
i18n-extended
./node_modules/.bin/i18n-extended
Step 3:
import { i18nExtended, I18N_EXTENDED_DATA } from '@andrewwormald/i18n-extended';
// This file is generated at the root of the app
import { i18nDataMap } from '../../../../i18n.extended.map';
providers: [
{
provide: I18N_EXTENDED_DATA,
useValue: () => i18nDataMap(),
},
]
Step 4:
import { i18nExtended } from '@andrewwormald/i18n-extended';
class myComponent {
title: string;
constructor(private translateService: i18nExtended) {
// This needs to match the <target-language> attribute value in the .xlf file>
this.translateService.setLanguage('fr');
}
myMethod() {
// Calling `translateText()` will be part of marking the text for extraction
// as well as fetching the translated text at runtime. If nothing is found or if
// the text has not yet been translated, the provided text will be returned as is.
this.title = this.translateService.translateText('I like i18n-extended!');
}
}