ngx-translate

Angular 5 and ngx-translate with shared module loose translations if refresh

僤鯓⒐⒋嵵緔 提交于 2020-08-24 12:50:10
问题 I have an angular app that uses ngx-translate. Below the versions: "@angular/core": "5.2.6", "@ngx-translate/core": "9.1.1", "@ngx-translate/http-loader": "2.0.1" In the AppModule class i added the import below: imports: [ ..... TranslateModule.forRoot({ loader: { provide: TranslateLoader, useFactory: (createTranslateLoader), deps: [HttpClient] } }) ...... ] ..... export function createTranslateLoader(http: HttpClient) { return new TranslateHttpLoader(http, './assets/i18n/', '.json'); } And i

Angular 5 and ngx-translate with shared module loose translations if refresh

梦想的初衷 提交于 2020-08-24 12:49:39
问题 I have an angular app that uses ngx-translate. Below the versions: "@angular/core": "5.2.6", "@ngx-translate/core": "9.1.1", "@ngx-translate/http-loader": "2.0.1" In the AppModule class i added the import below: imports: [ ..... TranslateModule.forRoot({ loader: { provide: TranslateLoader, useFactory: (createTranslateLoader), deps: [HttpClient] } }) ...... ] ..... export function createTranslateLoader(http: HttpClient) { return new TranslateHttpLoader(http, './assets/i18n/', '.json'); } And i

ngx translate not working on iOS device

∥☆過路亽.° 提交于 2020-07-09 13:54:26
问题 I have an ionic 3 project and I want to use ngx translate. It works in the browser and the iOS simulator but not on a real device (tested on iPhone SE, iOS 11.1). app.module.ts import { TranslateLoader, TranslateModule } from '@ngx-translate/core'; import { TranslateHttpLoader } from '@ngx-translate/http-loader'; import { HttpClient, HttpClientModule } from '@angular/common/http'; export function HttpLoaderFactory (http: HttpClient) { return new TranslateHttpLoader(http, './assets/i18n/', '

Angular Material Datepicker | Lazy Loading + CustomDateAdapter + Internationalization - RangeError: Maximum call stack size exceeded

百般思念 提交于 2020-05-28 06:53:54
问题 Structure Question I'm not quite sure If I found the right place for this 2 code lines: providers: [ { provide: MAT_DATE_LOCALE, useValue: 'de-DE' }, { provide: DateAdapter, useClass: CustomDateAdapter, deps: [MAT_DATE_LOCALE, Platform] } ] Currently they are in my material.module => which is imported in shared.module => which is imported in app.module and every lazy loaded module. CustomDateAdapter: @Injectable() export class CustomDateAdapter extends NativeDateAdapter { subscription: any;

Angular Material Datepicker | Lazy Loading + CustomDateAdapter + Internationalization - RangeError: Maximum call stack size exceeded

╄→гoц情女王★ 提交于 2020-05-28 06:53:45
问题 Structure Question I'm not quite sure If I found the right place for this 2 code lines: providers: [ { provide: MAT_DATE_LOCALE, useValue: 'de-DE' }, { provide: DateAdapter, useClass: CustomDateAdapter, deps: [MAT_DATE_LOCALE, Platform] } ] Currently they are in my material.module => which is imported in shared.module => which is imported in app.module and every lazy loaded module. CustomDateAdapter: @Injectable() export class CustomDateAdapter extends NativeDateAdapter { subscription: any;

ngx-translate .instant returns key instead of value

核能气质少年 提交于 2020-05-10 07:34:08
问题 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 problem is that method gets called before loader loads translations. My app.module.ts imports: TranslateModule.forRoot({ loader: { provide: TranslateLoader, useFactory: (createTranslateLoader), deps: [HttpClient] } }) createTranslateLoader function

ngx-translate .instant returns key instead of value

戏子无情 提交于 2020-05-10 07:33:11
问题 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 problem is that method gets called before loader loads translations. My app.module.ts imports: TranslateModule.forRoot({ loader: { provide: TranslateLoader, useFactory: (createTranslateLoader), deps: [HttpClient] } }) createTranslateLoader function

Translation Angular 2 using ngx-translate?

点点圈 提交于 2020-05-08 05:53:28
问题 I have all configuration and setting following instructions. app.module.ts import { Http } from '@angular/http'; import {TranslateModule, TranslateStaticLoader, TranslateLoader, TranslateService } from 'ng2-translate'; imports: [ BrowserModule, HttpModule, TranslateModule.forRoot({ provide: TranslateLoader, useFactory: (http: Http) => new TranslateStaticLoader(http, '/assets/i18n', '.json'), deps: [Http] }) ] Component: import {TranslateService,TranslatePipe } from 'ng2-translate';

ngx-translate default text if key is missing or translation file is being loaded

非 Y 不嫁゛ 提交于 2020-04-14 07:46:42
问题 I'm setting up a new Angular 7 app. I want to set a default text for translation. So in the translation {{ 'wait' | translate }}, I want to set text 'Waiting Now' as default text if there are any fallback. Means if data is being loaded or key is missing then passed value (in this case Waiting Now) should appear. I was trying to do something like {{ 'Intro' | translate:'localizedText' }} Not didn't worked {{ 'Intro' | translate:'localizedText' }} I expect result should come as {{ 'Intro' |

Update translations in loader of ngx-translate

余生长醉 提交于 2020-04-11 09:40:28
问题 I am creating a custom Angular ngx-translate Loader which either gets translations from cache or from an API. The point where I am stuck is Case 2 (see code below): Desired procedure: gets translations from cache (sync) returns cached translations (via observer) gets translations from api (async) compares cache and api (finds difference) sends updated version of translations <-- How? This is what I got: getTranslation(lang: string): Observable<any> { return new Observable(observer => { // get