Releases: tflori/angular-translator
Version 2.2.4
Changelog:
- force
injector.get(TranslatorConfig)
to TranslatorConfig type to avoid typescript error (solves #53)
Version 2.2.3
Changelog:
- moved translations from constructor to
addTranslations(any)
method from Fake loader
Version 2.2.1
Changeload
- added
TranslationLoaderFake
to simplify testing (solves #50)
Version 2.2.0
Changelog:
- implement Translator.observe(string|string[], any?) returning an observable (solves #44)
Version 2.1.1
Changelog:
- provide a
JitReflector
forPipeResolver
if available (solves #46)
Version 2.1.0
- allow pipes in translations (solves #28)
Version 2.0.0
The new major version is out now!
Be careful: you really have to change something when you plan to update. It is not very much but it might be some work for you if your project is very big.
New Features
- modules
- single configuration
- easier installation
How to upgrade from angular2-translator
1. Upgrade the package
Remove angular2-translator and install angular-translator.
npm remove angular2-translator --save
npm install angular-translator --save
2. Update your setup
Angular translator now gives a simple-to-use static method for setup. This function also creates all required providers.
The usage is as follows.
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { TranslatorModule } from 'angular-translator';
import { AppComponent } from './app.component';
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
FormsModule,
HttpModule,
TranslatorModule.forRoot({
providedLanguages: ['de', 'en', 'ru'],
defaultLanguage: 'de'
})
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
3. Change the implementation from TranslateService to Translator
The TranslateService
has been renamed to Translator
. It has the same methods and can therefore be exchanged:
import { Component } from '@angular/core';
import { TranslateService } from 'angular2-translator'; // before
import { Translator } from 'angular-translator'; // now
@Component()
export class ComponentBefore {
constructor(translateService: TranslateService) {
translateService.translate('TEXT').then((translation) => this.text = translation);
}
}
@Component()
export class ComponentNow {
constructor(translator: Translator) {
translator.translate('TEXT').then((translation) => this.text = translation);
}
}
You can do this by search and replace on your own risk.
4. Change the implementation for changing the language
The Translator
has a public property language
and you can use it as before with TranslateService
. There is a new
service called TranslatorContainer
that holds all Translator
s for different modules. When you want to change the
language for every module you may want to change TranslatorContainer.language
instead. The change will be forwarded to
every Translator
.
5. Other questions
I used the
languageChanged
observable to update translations inside services and components. Do I need to change
here something?
No, the Translator
has the same observable that should be used now.
My configuration seems to be ignored after upgrade.
May be you copied your previous config. The parameters have changed: defaultLang - defaultLanguage, providedLangs -
providedLanguages, detectLanguageOnStart - detectLanguage.
Version 2.0.0 Release Candidate 2
This is a pre-release which means it is not stable. At least the documentation is not ready yet.
In the final release there will be a changelog here and in the README an upgrade guide. Stay tuned!
Version 1.4.4
- updated the readme to point out the name change for version 2.0
Version 1.4.3
- added
Default*Config
classes to work around angular compile problem (solves #22)