Ionic Translate


Hi, I have a doubt in Angular nx-translate service. I’m doing localisation with en as the language by default. At later point, If user wants to change the language, get the particular language resource from a remote server and make it local and pointing to that file, my language should be loaded in the rest of my application. How to achieve this. Can you help me out.


What did you try and what isn’t working yet?


I tried to create a dynamic file in the documents directory and for the TranslateLoader I give the path from the cordova plugin. But im getting Cordova not found error as Factory method called before cordova platforms ready method called.


Cordova plugin?

Check out this starter project that has full translation support:


Even in the template you shared, All my language resource should be available in assets/i18n/ folder. But my requirement is I don’t have the resource folder with me . So programatically I’m going to create this resource files and then I have to point that file in the TranslateModule.forRoot() method. Here UseFactory key was there. I want to change this factory to call dynamcially after some time like once the file is created.

My another doubt, is how to give the factory at some later point instead of defining in the app.module.ts. Is it possible if so Please guide me in it.


Read the docs of the module used to load the translations:


Can you please help me how to use the useStaticFilesLoader method for the translator in ionic2 typescript to provide the file location where all the language resource file available?


I have used TranslateService.setTranslation method to feed the new language resource and used that language. But still I dont have any idea that whats the difference between feeding json object in the above method and using factory method dependent with http to feed the language resource json file location.


for useStaticFilesLoader, in app.module.ts:

  import {TranslateModule, TranslateLoader} from '@ngx-translate/core';
  import {TranslateHttpLoader} from '@ngx-translate/http-loader';

 export function exportTranslateStaticLoader(http: Http) {
    return new TranslateHttpLoader(http, './assets/i18n/', '.json');
   imports: [
            loader: {
                provide: TranslateLoader,
                useFactory: exportTranslateStaticLoader,
                deps: [Http]


In this case, If all my language resources are not available with the app and it will be available only with web service call, then will this solution works?


Look like your question is too complicated for me sorry can’t help.


Maybe a bug, look like some people are asking the same questions today…