Skip to content

Releases: tflori/angular-translator

Version 2.2.4

26 Aug 08:19
Compare
Choose a tag to compare

Changelog:

  • force injector.get(TranslatorConfig) to TranslatorConfig type to avoid typescript error (solves #53)

Version 2.2.3

12 Aug 10:01
Compare
Choose a tag to compare

Changelog:

  • moved translations from constructor to addTranslations(any) method from Fake loader

Version 2.2.1

09 Aug 15:40
Compare
Choose a tag to compare

Changeload

  • added TranslationLoaderFake to simplify testing (solves #50)

Version 2.2.0

27 Jun 05:34
Compare
Choose a tag to compare

Changelog:

  • implement Translator.observe(string|string[], any?) returning an observable (solves #44)

Version 2.1.1

22 Jun 05:00
Compare
Choose a tag to compare

Changelog:

  • provide a JitReflector for PipeResolver if available (solves #46)

Version 2.1.0

22 Apr 18:00
Compare
Choose a tag to compare
  • allow pipes in translations (solves #28)

Version 2.0.0

16 Apr 17:23
Compare
Choose a tag to compare

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 Translators 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

12 Apr 05:18
Compare
Choose a tag to compare
Pre-release

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

12 Apr 06:06
Compare
Choose a tag to compare
  • updated the readme to point out the name change for version 2.0

Version 1.4.3

07 Apr 18:26
Compare
Choose a tag to compare
  • added Default*Config classes to work around angular compile problem (solves #22)