Page 1 of 4

database collections based on language

Posted: Tue May 05, 2015 1:29 pm
by Dennis

Can I choose between different database collections based on what language my phone is set to? Using this guide for different labels today: https://devcenter.appery.io/tutorials...

Really hope someone can help me.


database collections based on language

Posted: Tue May 05, 2015 6:44 pm
by Serhii Kulibaba

Hello,

Sure, you can change collection based on language.
1) Change url for service from
{database_url}/collections/collection1
to
{database_url}/collections/{collection_name}

2) add request parameter collection_name to this service

3) set this parameter based on your language. Appery.io automativcally change {collection_name} to it's value


database collections based on language

Posted: Tue May 05, 2015 8:26 pm
by Dennis Nygaard Nielsen

I just can't get it to work...

Right now it is just displaying the collection name instead of the content of the DB.
I have edited my query to collectionName, the service and the translation file...

Hope you can see what I am doing wrong.

For the translation file I have:

{
"collectionName":"Nozzles_EU",
"second_input":"Another input text"
}

Image Image Image


database collections based on language

Posted: Fri May 08, 2015 2:46 am
by Yurii Orishchuk

Hi Dennis,

You should move this parameter to "Query String" subTab.

See details on screen shot: http://prntscr.com/72sejj/direct

Then don't forget to link correct value to this parameter in service "before send" mapping.

Regards.


database collections based on language

Posted: Sat May 09, 2015 6:09 pm
by Dennis Nygaard Nielsen

Thank you so much! did the trick :)

What if I then would like a label shown in the same specific language?
I choose the language from a drop-down list


database collections based on language

Posted: Mon May 11, 2015 3:48 am
by Yurii Orishchuk

Hi Dennis,

Please clarify your question with more details.

Regards.


database collections based on language

Posted: Thu May 14, 2015 2:02 pm
by Dennis

I would just like to use my translation files by using the same drop down language chooser I made for selection of databases, for the rest of the text in my app.
Today I use the browser language, but how can I choose to use the chooser instead?


database collections based on language

Posted: Fri May 15, 2015 3:24 am
by Yurii Orishchuk

Hi Dennis,

If you talk about static text on the labels buttons and other components you need to use i18n.

Please pass the tutorial below to understand how it works:
https://devcenter.appery.io/tutorials...

Regards


database collections based on language

Posted: Fri May 15, 2015 10:10 am
by Dennis

I am already. Followed the guide, but instead of using the browser language, I want the users to choose their language from a drop down menu


database collections based on language

Posted: Fri May 15, 2015 3:35 pm
by Dennis Nygaard Nielsen

Ok. My language selection is now working.
I have a dropdown with the different languages which is working fine. I would though also like my database to change according to this.
My dropdown has the following values:
Image

And in my translation files I have:

"collectionName":"Nozzles_EU", as one of the lines to choose my DB.

For my dropdown I have value change JS:

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

As request string for my query I have collectionName as name and nothing as value. If I put in the value Nozzles_EU or Nozzles_US, everything works great. But I would like it to take these values from the translation files instead.

Should this not be enough?

Check out the app here. Type in 20 in both input fields: http://appery.io/app/mobile-frame?src...