Dennis
Posts: 0
Joined: Tue May 05, 2015 1:29 pm

database collections based on language

Really hope someone can help me out here :/

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

database collections based on language

Hi Dennis,

i18n works only with html elements. And there is no built-in relative with service.

So if you want to get service request parameter from translation file - you need to:

  1. Set this translation in some label(how to do it see here: https://devcenter.appery.io/tutorials... )

  2. In service "before" send mapping use following JS code to get current label text :

    pre

    return Apperyio("labelname").text();

    /pre

    Regards.

Dennis
Posts: 0
Joined: Tue May 05, 2015 1:29 pm

database collections based on language

Translation is not the problem. Choosing the database collection from the same drop down as the language chooser is my struggle.

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

database collections based on language

Hi Dennis,

You need to map appropriate language to collection name.

Here is an example how you can do it:

pre

var langCollectionMapping = {
"en-GB": "britanCollection",
"en-US": "britanCollection"
};

var val = Appery("mobileselectmenu10").val();

var currentCollectionName = langCollectionMapping[val];

alert("currentCollectionName = " + currentCollectionName);

/pre

Regards.

Dennis
Posts: 0
Joined: Tue May 05, 2015 1:29 pm

database collections based on language

But where would I put this? When value is changing for the language selector?

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

database collections based on language

Hi Dennis,

Yes, you need to use such js logic in select change event handler to get current collection name. After you do with this information what you need.

Regards.

Dennis
Posts: 0
Joined: Tue May 05, 2015 1:29 pm

database collections based on language

Hi Yurii
Again, I am really pleased for your help. This is pretty much my last issue before I am able to finish my app, so I really appreciate what you are doing. I just can't figure this out. I have now taken screen shots of everything I have been doing regarding this. It seems if I change language, the language is changing and the variable is choosing fx the US database according to the alert. But the data is not showing up from the database. If I "hard code" the url to Nozzles_US or Nozzles_EU it works great. It keeps thinking the database is called en-GB:

api.appery.io/rest/1/db/collections/en-GB?where=%7B%22%24and%22%3A+%5B%7B%2....33+%7D%7D%2C%7B%22filter_high%22%3A+%7B%22%24gte%22%3A0.33+%7D%7D%5D%7D:1 GET https://api.appery.io/rest/1/db/colle... 404 (Not Found)

Image Image Image Image Image Image

Dennis
Posts: 0
Joined: Tue May 05, 2015 1:29 pm

database collections based on language

Please?

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

database collections based on language

Hi Denis,

As i can see did not have a code to convert language to collection name.

You need to use following js code in JS section for request parameter:
Details: http://prntscr.com/7da8x8/direct

pre

var langCollectionMapping = {
"en-GB": "britanCollection",
"en-US": "britanCollection"
};
//var val = Appery("mobileselectmenu10").val();
var currentCollectionName = langCollectionMapping[val];
alert("currentCollectionName = " + currentCollectionName);

return currentCollectionName;

/pre

Regards.

Dennis
Posts: 0
Joined: Tue May 05, 2015 1:29 pm

database collections based on language

Thanks Yurii! This works. But how do I integrate the language selector in the same drop down? When I use the code from my screen shot, it crashes the drop down menu.

Return to “Issues”