Losing ngx-Translate translation while building with --Prod

Asked

Viewed 238 times

0

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

    export function createTranslateLoader(http: HttpClient) { 
      return new TranslateHttpLoader(http, './assets/i18n/', '.json'); 
    } 

    TranslateModule.forRoot({ 
      loader: { 
        provide: TranslateLoader, 
        useFactory: createTranslateLoader, 
        deps: [HttpClient] 
      } 
    }), 

I’m working on a project done on Ionic 3.

When I give one ionic cordova run android --livereload the translation works normally.

But when I use ionic cordova run android --prod or ionic cordova build android --prod translation no longer works, someone has already gone through this and could help me?

1 answer

0


Below is an image of how the folder structure was made for translation.

Estrutura feita para tradução

As described in the Mports of the question, I use the Globalization to pick up the preferred language of the device and in another file I use the TranslateService

import { TranslateService } from "@ngx-translate/core";

const lang = TranslateService.getBrowserCultureLang()

The function getBrowserCultureLang give me browser preference...

Both give me the extension with the culture:

lang = 'en'

or

lang = 'en-US'

What was happening was that I passed the lang in function TranslateService.setDefaultLang(lang); the way he was delivered to me.

IS necessary passes the lang with all content in lower case.

ex: TranslateService.setDefaultLang(lang.toLowerCase())

lang = 'en'

or

lang = 'en-us'

Browser other questions tagged

You are not signed in. Login or sign up in order to post.