Ionic globalization work in ios but not in android

#1

HI, i am beginner of using ionic framework. I have using ionic native globalization and ng2-translate to deal with the translation in app, below is my translation json in src/assets/i18n/en.json

{
  "Tab.Home": "Home",
  "Tab.Travel": "Travel",
  "Tab.Add": "Add",
  "Tab.Notice": "Notice",
  "Tab.Me": "Me"
}

it works in ios:

But not work in android:

In Chrome inspect, it said fail to load:

Does anyone know why this will happen or experienced before? I am beginner of ionic so Thanks a lot again~

#2

The path of your translation files doesn’t work on Android. Please show us how you define the path to be used (assets/i18n…).

#3

Hi, Sujan12, thanks for your reply. Here is my definition:
export function createTranslateLoader(http: Http) {
return new TranslateStaticLoader(http, ‘./assets/i18n/’, ‘.json’);
}

#4

Have you tried variations? Without the Slash at the end?
If this is triggered by ‘vendor.js’ (which your screenshot implies), is ./assets a path that is available? Probably only ../assets, right?

#5

Yes, i have tried before, but android still not have translation. I am very confused of this issue.
You means In android the path should be …/assets/en.json??

#6

No, I mean that in general the correct path might be a different one and it only accidentally works on the other platforms.

#7

So, Do you know the path of the i18n need to located on the ionic? sorry, because i am the beginner of ionic2. Thanks again.

#8

I am reference from this tutorial:

#9

In this tutorial it says

return new TranslateStaticLoader(http, 'assets/i18n', '.json');

which is different from what you posted.

#10

Hi. Sujan12, i have tried ‘assets/i18n’ and ‘assets/i18n/’ two are the same result.