I've to implement globalization in a phonegap app. Question is if I should go for translation before compiling the app, or translation on run time.
I can go 2 directions:
- First one is using a plugin like
gulp-i18n-localize
to translate the source code into every language I want and then compile every translated source code into different folders (en,sp,it, etc..). And then in the app call the folder I need depending on what I get fromnavigator.language
. - The second one is creating a service that I will be calling every time I load a component or controller, that will translate
every word/phrase to the target language before presenting it.
Something like:
global.trans('Save')
. It will also be getting the language fromnavigator.language
.
- It's an app so there will be no big paragraphs but just words or small sentences used in titles, buttons, labels or messages/alerts.
- Data will come from the server already in the desired language thanks to a language parameter sent when calling apis.
- App for sure will have some modifications in the future, so main source code should be centralized to not be having to perform the same changes in several sources cause of different languages every time we go for an update.
Has someone already implemented one of these solutions and has encountered any issue with it? Or has thought about issues that one of these can have or think which should be the best solution? Any other options you can think about?
Only issue I see is that in the first case the apk will grow in size cause will have a "site" per language and that I will have to modify the gulpfile.js every time I want to add a language (Apart from the dictionary). And in the second case it will add some load to the app as it will be translating every word/phrase given (Translating meaning calling the service, and the service searching the dictionary (json) for the word/phrase/language and returning the value, although there's not much to translate per page/screen).