Questions tagged [ngx-translate]

NGX-Translate is an internationalization library for Angular 2+. It lets you define translations for your content in different languages and switch between them easily.

Resources:

  1. Website: http://www.ngx-translate.com/
  2. Github: https://github.com/ngx-translate
  3. Demo: https://stackblitz.com/github/ngx-translate/example
716 questions
58
votes
9 answers

Angular ngx-translate usage in typescript

I'm using this @ngx-translate/core i18n service and it works fine in templates (.html) with this syntax: {{'my.i18n.key'|translate}} Now I want to translate something in my component typescript file (.ts) but I don't know how to use it. I can…
NavCore
  • 1,115
  • 3
  • 10
  • 25
47
votes
3 answers

Angular 5 internationalization

I'm building an application using the latest Angular5 and what I need is for a user to be able to switch languages. I've never had to implement this in an Angular2+ (actually I'm using Angular5). I need to set translations in two…
Rob
  • 6,819
  • 17
  • 71
  • 131
46
votes
2 answers

How to get current language with ngx-translate in angular2

I want to get current language with this.translate.getBrowserLang(), but it always return 'en', whatever the current language is and what the supported languages is. Here is the plnkr: https://plnkr.co/edit/JEXgj8WcISYGtDg75VoR?p=preview, maybe…
Allen
  • 2,037
  • 3
  • 15
  • 21
45
votes
5 answers

Differences ngx-translate vs i18n

There are multiple methode to translate an (Angular) app, the big main methodes are : ngx-translate and Angular 2 native i18n As far I understood i18n is easier for SEO because of the clean url browsing with e.g app.com/de app.com/en on the other…
Domi
  • 1,299
  • 3
  • 17
  • 27
42
votes
6 answers

ngx-translate .instant returns key instead of value

I am trying to make a method which would accept string key and return translated string value by using translate.instant(parameter). The problem is that it returns key(parameter). Usually this is returned if it doesn't find translation. I think the…
OjamaYellow
  • 899
  • 1
  • 13
  • 27
34
votes
4 answers

put new line in string to translate

I'm using ngx-translate. How can I put a line break in a string to translate ? In my template I have : {{'STRING_TO_TRANSLATE' | translate}} In my en.json: { "STRING_TO_TRANSLATE": "text on first line.
or \n don't work. Text on second…
Lev
  • 13,856
  • 14
  • 52
  • 84
28
votes
1 answer

Ngx translate with shared/lazy loading modules

Probably one of the most common questions, while the documentation and some other questions I found try to clear up things for me, yet I am still not sure how to fix this. So this is my structure: App module is of course the main module that is…
CularBytes
  • 9,924
  • 8
  • 76
  • 101
20
votes
4 answers

ngx-translate how to test components

I've got an application which uses this library. How do I test components with it? I DO NOT WANT TO TEST THE LIBRARY. I just need to start tests of my component without multiple errors about TranslateModule then TranslateService then TranslateStore…
Sergey
  • 7,184
  • 13
  • 42
  • 85
20
votes
1 answer

Angular translate innerHTML with params

I would like to translate a source text containing tag with url param, the string text example: STRING_TEXT = 'some text some link name' I know there it is possible to translate
mtx
  • 1,196
  • 2
  • 17
  • 41
18
votes
2 answers

Angular 6 i18n runtime translation support

I've read i18n runtime support is coming in angular 6, but cant find anything in rc3. Is it postponed or not yet documented? The i18n documentation still states than one have to build a separate build for each…
RockBop
  • 181
  • 1
  • 4
17
votes
2 answers

ngx-translate with dynamic text on ts file

I'm using ngx-translate for internationalization on Ionic 3 app. I have used pipe nicely on HTML code. But now I have a situation like below on ts file. Can you tell me how to handle such dynamic use case with ngx? updateApi(topic) { …
Sampath
  • 63,341
  • 64
  • 307
  • 441
17
votes
1 answer

ngx-translate/core "Error: No provider for HttpClient!"

I've downloaded the package ngx-translate/core, and been following the documentation instructions. I can't get the translation to work. The steps i made: 1] define everything in the AppModule import { BrowserModule } from…
Willy
  • 3,506
  • 3
  • 22
  • 35
16
votes
11 answers

Angular 6 - can't resolve all parameters for AppComponent

I am trying to build an application with Angular 6 and I am still setting everything up. But it seems there is something wrong with the dependency injection in my app. It cannot resolve any constructor parameter. They all result in Uncaught Error:…
Mr.wiseguy
  • 4,092
  • 10
  • 35
  • 67
16
votes
3 answers

Use ngx-translate in component

I'm using ngx-translate with no-problems in views, using pipes. What i need to do is to use it in a component, for example to show an error message, or define a datatable column default content. I'm trying to do something…
jonyjm
  • 963
  • 2
  • 7
  • 15
14
votes
3 answers

@ngx-translate with lazy-loaded module in Angular 5

I'm using @ngx-translate for language handling in an Angular 5 app I'm creating. The app has two feature modules, one lazy loaded and one eager loaded. The problem is that the translate pipe works fine in the eager-loaded module but not the…
Saeb Panahifar
  • 479
  • 1
  • 5
  • 11
1
2 3
47 48