ngx-translate

Cannot find module @angular/common/http Ionic 3 app

被刻印的时光 ゝ 提交于 2019-12-12 04:18:11
问题 I have done the Ionic 3 app's internationalization using ngx-translate .It gave me below error. I have done that using official doc here. Cannot find module '@angular/common/http' 回答1: The issue was @angular/common/http is only available in angular 4.3+ .But on Ionic 3 we're using Angular 4.1.3 . So this is the solution: I have removed @ngx-translate/http-loader npm uninstall @ngx-translate/http-loader --save And add an older version of it: npm i @ngx-translate/http-loader@0.1.0 --save You

How to extend ngx-translate pipe

拜拜、爱过 提交于 2019-12-11 07:44:10
问题 I want to extend ngx-translate's pipe to make it potentially multi purpose within my app. My pipe: import { Pipe, PipeTransform } from '@angular/core'; import { TranslatePipe } from "@ngx-translate/core"; @Pipe({ name: 'msg' }) export class MsgPipe extends TranslatePipe implements PipeTransform { transform(value: any, args: any[]): any { return super.transform(value, args) } } In order to wait for the relevant translate modules to load, I have used Angular's APP_INITIALIZER: app.module:

Unable to translate text using ngx-translate's service-translate.get

我是研究僧i 提交于 2019-12-11 04:39:33
问题 I am able to translate text using translate pipe but currently struggling to load translations using translate service's get and instant method. Below is my code in app.component.ts export class AppComponent { event : string; constructor(private translate: TranslateService) { translate.addLangs(["en", "fr"]); translate.setDefaultLang('en'); let LangChangeEvent : {} let browserLang = translate.getBrowserLang(); translate.use(browserLang.match(/en|fr/) ? browserLang : 'en'); this.translate.get(

ngx-translate - No provider for InjectionToken DocumentToken

半世苍凉 提交于 2019-12-06 13:52:02
问题 I'm very new to ionic 3 and Angular 4. I'm trying to translate a page but when I run the app I get this error. I added the libraries and imported everything as the documentation said, and I added the translate service in the providers array in app module, but I still get this error app.module.ts import { BrowserModule } from '@angular/platform-browser'; import { ErrorHandler, NgModule } from '@angular/core'; import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular'; import

ngx-translate not showing any text in lazy-loaded module

纵饮孤独 提交于 2019-12-06 02:26:38
问题 We are using Angular 6 in our application. We recently started to prepare our app fro lazy-loading. Application has multiple lazy-loaded routes. We want to use a single language file for all routes (don't need to separate it into chunks. But load all translations on bootstrap). First thing I tried was just to import and configure ngx-translate in AppModule (forRoot) and nowhere else. For that purpose I created a configuration file for TranslateModule with the following code: import {

Angular 4 Ngx-translate pipe not working

依然范特西╮ 提交于 2019-12-06 02:26:31
问题 I want to make an angular 4 app that is multilangual. I have followed the answer on Angular 2 - Multilingual Support but it doesn't work. I did every step, from 1 to 5 on that page and my appmodule looks the same. I have a file en.json in a folder i18n, located in my assets folder. The file contains { "TEST":"little test"} and in my HTML: <a [routerLink]="['/home']" class="tile waves-effect waves-light btn-large"> <span> {{ "TEST" | translate }}</span> </a> And when I use it I get TEST

ngx/translate - translate only part of a string

 ̄綄美尐妖づ 提交于 2019-12-05 21:18:22
I need to translate strings coming from a server using ngx/translate . It works fine when i need to translate a string but in some case i need to translate only part of the string. For example: 'hello Shay' or 'hello John' And i need to translate only 'hello' and leave the name as is. I tried: this.i18n.instant('hello {Shay}') and in the en.json file: "hello {var}": "Hello {var}" but with no success. Any Ideas how it can be done? You are looking for parametrized translations. You do not need that parameter in the translation key. Try it like this: en.json: "hello_name": "Hello {{name}}"

How can I use two translators first for JSON file and second for firestore?

不问归期 提交于 2019-12-04 20:42:55
JSON File Method export function createTranslateLoader(http: HttpClient) { return new TranslateHttpLoader(http, './assets/i18n/', '.json'); } JSON File Loader TranslateModule.forRoot({ loader: { provide: TranslateLoader, useFactory: (createTranslateLoader), deps: [HttpClient] } }), AngularFirestore Method export function FirestoreTranslationsLoaderFactory(db: AngularFirestore) { return new FirestoreTransLoader(db); } AngularFirestore File Loader TranslateModule.forRoot({ loader: { provide: TranslateLoader, useFactory: FirestoreTranslationsLoaderFactory, deps: [AngularFirestore] } }), Note: I

ngx-translate - No provider for InjectionToken DocumentToken

北战南征 提交于 2019-12-04 19:49:06
I'm very new to ionic 3 and Angular 4. I'm trying to translate a page but when I run the app I get this error. I added the libraries and imported everything as the documentation said, and I added the translate service in the providers array in app module, but I still get this error app.module.ts import { BrowserModule } from '@angular/platform-browser'; import { ErrorHandler, NgModule } from '@angular/core'; import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular'; import {HttpClientModule, HttpClient} from '@angular/common/http'; import { MyApp } from './app.component'; import

ngx-translate not showing any text in lazy-loaded module

做~自己de王妃 提交于 2019-12-04 09:11:45
We are using Angular 6 in our application. We recently started to prepare our app fro lazy-loading. Application has multiple lazy-loaded routes. We want to use a single language file for all routes (don't need to separate it into chunks. But load all translations on bootstrap). First thing I tried was just to import and configure ngx-translate in AppModule (forRoot) and nowhere else. For that purpose I created a configuration file for TranslateModule with the following code: import { MissingTranslationHandler, MissingTranslationHandlerParams, TranslateLoader, TranslateModuleConfig } from '@ngx