Translations: assets or by http-service?


#1

Hi all

I’m wrinting my first mobile app (also with my Ionic framework) and now I’m at the point
where I have to think about the internatioalization or globalization.

During my investigations I saw mostly examples, where the translation data is stored
in assets and in that way deployed to the mobile-device.

From my point of view, there is also the possibility to load the translation data, depending
on the device-language, by a http-translation webservice.

Is the service approach not a good idea for ionic or general mobile app development?

Thank you for your feedback.

P.S
Every link to examples for internationalization are welcome.

regards,
Oliver


#2

Well use, https://ionicframework.com/docs/developer-resources/ng2-translate/ for how to do it in Ionic.

And the comparison you make may not be not fully sound as you need to use HTTP to access the assets in the assets folder. So what is difference from a http-translation webservice other then the webadress (local vs remote)?

Best practice is to put data stuff in a provider (aka service) and let the components interact with it.


#3

Thanks for your answer.

I did not realize that the TranslateHttpLoader is built on HttpClient.

That means the TranslateHttpLoader can also get its data from a webservice.

So far I understand you, it doesn’t matter, whether the TranslateHttpLoader get its data.
From a remote webservice or locally on device from the assest-folder.

I hope that I’m right.
But for sure, I will have a closer look now on ng2-translate.

thx for the hint

regards,
Oliver


#4

I’d imagine it would make a difference when offline or if you have a slow connection.

Is there value added with a remote translation service?


#5

HI@SigmundFroyd
The only value I thought would be, to be able to change translations without deploying an new update of the app via store.

But I see for me as a Mobile and Ionic beginner a lot more questions are popping up now.:grimacing:

  1. They built the TranslateHttpLoader depending on the HttpClient class, so I think they did it, to load for example a translation file via webservice and store it then in the assets folder on the device?

  2. the other point you mentioned is the ‚offline‘ case. Honestly at the moment I was not thinking about that, but I need to do it. Exists there a plugin to check, whether the device is online or not?

  3. I saw, I could write a CustomHttpLoader to load the translations. But when does it fire the trigger to load the translations? I think the translation has to be loaded on the startup.

  4. If I would load the translation via webservice, what happens when I switch the language at runtime? Would the new language be loaded just in time via wenservice?

Sorry due to this many questions, but I‘m really
new in Mobile app development.

But I‘m grateful for every opinion to those questions.

Regards,
Oliver


#6

There’s a lot here. I’ll do two things.

  1. If you build your app correctly, you shoudn’t need to update through the app store. Your app comes packaged with a translation file(s). Put a timestamp on that file. If a newer version is available, you download it from your backend and update the timestamp. Then you just need a way to check for a new timestamp.

  2. To check whether a database is online, build a heartbeat function into your backend and listen to the heartbeat. If the heart stops beating, you know you are offline. If it starts beating again, you know you are back online. An example is the connect address of Firebase, which is a Boolean Observable that emits true while connected, and “emits” false while not connected.


#7

Thank you for helping me out @AaronSterling
Point 2: your tip seems clear for me. I will have a look for this approach.

Point 1: are you talking about this nativ file plugin?
And with timestamp you mean a kind of metadata field I can set on the file?