Page 2 of 2

Using localStorage to Support Multilingual

Posted: Wed Aug 13, 2014 10:01 am
by Hawk

Hi,

Thank you for trying to help me. I have removed all events and added only one event for selectmenu with the script you posted above. Now when I test the app, I am expecting when I change the option from 'English' to 'German' in selectmenu, the caption text (which is originally 'English Language') and the label text (which is originally 'This is a demo'), I expect them to show in German:
English Language : Deutsch Sprache
This is a demo: Dies ist Demo

Unfortunately, that did not happen. Nothing has changed!

Are the translation.json files correct?

en-EN: { "header":"English Language",
"This is a Demo":"This is a Demo"}
de-DE: { "header":"Deutsch Sprache",
"This is a Demo":"Dies ist Demo" }

Do I need to change anything in selectmenu properties?


Using localStorage to Support Multilingual

Posted: Wed Aug 13, 2014 11:44 am
by Evgene Karachevtsev

Hawk,

Could you please clarify, have you made all the necessary markings as in the tutorial:
http://devcenter.appery.io/tutorials/... ?
Also please specify, are there any errors in console?


Using localStorage to Support Multilingual

Posted: Wed Aug 13, 2014 11:57 am
by Hawk

Hi,

Yes, for header component, the marking is identical to the one in the tutorial. The label component, the marking is : (data-i18n : lable)

The console does not show any error/warning at all.

Are the translation.json files correct (given that the selectmenu options values are en-EN & de-DE)?

en-EN: { "header":"English Language",
"This is a Demo":"This is a Demo"}
de-DE: { "header":"Deutsch Sprache",
"This is a Demo":"Dies ist Demo" }

Do I need to change anything in selectmenu properties?
What is the significance of the identifier 't' in '$.i18n.init(option, function(t)'?


Using localStorage to Support Multilingual

Posted: Wed Aug 13, 2014 12:32 pm
by Evgene Karachevtsev

Hawk,

Could you please provide us with public link to your project, we'll test: http://devcenter.appery.io/documentat...


Using localStorage to Support Multilingual

Posted: Wed Aug 13, 2014 1:11 pm
by Hawk

Hi Evgene,

This is the project link

https://appery.io/app/projects/45516c...

Not sure if this is what you asked for. In order to share the project I need your email, right?

Your help is deeply appreciated


Using localStorage to Support Multilingual

Posted: Wed Aug 13, 2014 1:40 pm
by Evgene Karachevtsev

Hawk,

You have the wrong name for the folder with json files, it should be called locales (you have locals). And in the code it should be
prevar option = {lng: val, resGetPath: 'locales/lng/ns.json', fallbackLng: 'en-US'};/pre
You have inaccuracies in resGetPath.


Using localStorage to Support Multilingual

Posted: Thu Aug 14, 2014 1:27 am
by Hawk

Hi Evgene,

I have renamed the folder to 'locales' and the the code to:

var val = Appery("typeList").val();
var option = {lng: val, resGetPath: 'locales/lng/ns.json', fallbackLng: 'en-US'};//Pass the initialization language,
//set the translation files path and fallback language
$.i18n.init(option, function(t) {
$(document).i18n(); //Once the translations are loaded translate the whole document
});

It is still not showing the translation in German when I change the option in selectmenu from English to German. The console does not show any error/warning either!


Using localStorage to Support Multilingual

Posted: Thu Aug 14, 2014 7:05 am
by Evgene Karachevtsev

Hawk,

Sorry, there was a typo in my last reply. You should use understreck, like here:
http://devcenter.appery.io/tutorials/...


Using localStorage to Support Multilingual

Posted: Thu Aug 14, 2014 7:54 am
by Hawk

Thank you Evgene for all your help!