Questions tagged [ng2-translate]

89 questions
2
votes
2 answers

How to load a service through shared.module in a lazy loaded ngModule only instantiated once though forRoot()

How can I load a service through SharedModule as a singleton within a lazy loaded ngModule? How can I load a service as a singleton within a lazy loaded ngModule? I do have a SharedModule which provides several services like i18n and APIs. The…
Manuel
  • 9,112
  • 13
  • 70
  • 110
2
votes
1 answer

ng2-translate does not work with angular-cli build prod

I added ng2-translate to my angular-cli project. It's work well in localhost but when I try to run it from ng build prod, I got 404 not found: http://MySite/assets/i18n/en.json Failed to load resource: the server responded with a status of 404 (Not…
user3292624
  • 180
  • 2
  • 10
2
votes
1 answer

Unit tests keep failing with ng2-translate

Everything is fine when running app normally. However, I run into issues when trying to write these unit tests. I removed any project specific code/classes from the code below. The error i'm getting is Chrome 51.0.2704 (Mac OS X 10.11.6) App:…
Chris
  • 41
  • 2
2
votes
1 answer

ng2-translate: TypeError: Cannot read property 'toString' of undefined(…) on bootstrap

I have the following error on bootstrap: TypeError: Cannot read property 'toString' of undefined(…). I'm on Angular2 RC1 and using ng2-translate 2.1. Also, the issue was still there while in previous versions: Angular2 Beta-17 and ng2-translate…
Andrei Zhytkevich
  • 8,039
  • 2
  • 31
  • 45
1
vote
0 answers

Translations not working in error component angular2/6

While Application is loading I am calling a service which will load master data. If master data not loaded because of any network issue. Then I am navigating to error component by storing the error in local storage and retrieving the error in error…
1
vote
1 answer

ng2-translate in unit test returns keys instead of translations

When attempting to test a service method that uses a translation (which works fine outside of the test) I am receiving the key I pass in back from TranslateService instead of the translation. Service being tested (simplified for easiest error…
Ryan Crews
  • 3,015
  • 1
  • 32
  • 28
1
vote
0 answers

how to use ng2-translate preload translations to use in component class

I am newbie to angular2, i able to translate using ng2-translate by using PIPE in template or html for example: {{ 'test' | translate}} But any idea what if i want translate validation message or any string value inside any of component.ts…
BondLim
  • 11
  • 2
1
vote
1 answer

ng2-translate in CoreModule

In our Angular App we have Feature Modules as well as Core and Shared Module as described by the Angular - linkStyle Structure best practices. We use ng2-translate and as per doc, we should call forRoot() in App Module (root module). This is how our…
DAG
  • 2,460
  • 5
  • 33
  • 61
1
vote
2 answers

Angular2 translation after subscribing to service

I have a parent component that has a child component, I want to translate the text based on the user language I get it from an api. Here is my translation pipe transform method: transform(value : string, args: any[]) : any { if (!value)…
Hussein Salman
  • 7,806
  • 15
  • 60
  • 98
1
vote
1 answer

VS2015: "Cannot find type definition" and "File not found" errors

I have an Angular2 app which worked perfectly fine until two days ago. When I tried to build the solution in Visual Studio 2015, I got 10 errors: Build: Cannot find type definition file for 'hammerjs'. Build: Cannot find type definition file for…
Ania
  • 29
  • 3
  • 5
1
vote
1 answer

How to load JSON-Files module specific? Angular 4 - ngx-translate

I am new to Angular 4 and ngx-translate. I am looking for a way to load specific JSON-File for every module. In my app.module.ts this code loads the json files for each language: TranslateModule.forChild({ loader: { provide: TranslateLoader, …
1
vote
1 answer

Translations with many components using ng2-translate

Hi I have a problem with translations, I'm using ng2-translate and this theme: SB Admin Bootstrap 4 Angular 4 I have an header with a language select dropdown menù, if I change language only my header component is translated but not the entire page…
Alessandro Celeghin
  • 4,039
  • 14
  • 49
  • 95
1
vote
1 answer

ng2-translate on component file combined with charts.js

I am using ng2-translate on my ionic2 app, and it's working nicely on static text on html files:
LxShmkv
  • 13
  • 2
1
vote
3 answers

How to change date format angular2

Hi I want to change date format according to the choosed language, I use ng2-translate and this is my working code but it is static: {{product[col.field] | date : 'dd-MM-yyyy' >}} I want to have a format date in a current language,…
Alessandro Celeghin
  • 4,039
  • 14
  • 49
  • 95
1
vote
1 answer

angular 2 ng2-translate custom TranslateLoader not working with API

ng2-translate not working with custom TranslateLoader when fetching data from API. Below is my custom TranslateLoader translateCustomLoader.ts @Injectable() export class CustomTranslateLoader implements TranslateLoader { constructor(private…
Ravi A.
  • 2,163
  • 2
  • 18
  • 26