Page 2 of 2

i18next and collections

Posted: Thu Mar 27, 2014 8:16 pm
by Michael4771079

thanks Nikita, kind of you to ask,
I just want to clarify some things about this plugin.

am I correct that this plugin does not machine translate?

if thats correct and Its bind translation,
I create a set of spanish collections,
do I have to implement all of the collection read services and mapping for this language?
or with code can we substitute the english collection for the spanish collection and use the same services and mapping?

cheers


i18next and collections

Posted: Thu Mar 27, 2014 10:13 pm
by Nikita

Hi,

This plugin doesn't translate text. If your data aren't related to the language, you should use the same service and a collection for all the languages. If you've created for each language a separated collection with similar structure, then you should use following URL in service settings:
{database_url}/collections/{collectionName}/
and pass to request-parameter "collectionName" collection name for particular language.


i18next and collections

Posted: Thu Mar 27, 2014 11:06 pm
by Michael4771079

Cheers Nikita,
thats what I need to be clear on, if there are any other info available please post it.

So is this the sequence
plugin detects spanish language,
some js runs and saves collection url in localstorage
map local storage to what?
invoke service with new collection url
were now in spanish

thanks again
theres very little info available for this


i18next and collections

Posted: Fri Mar 28, 2014 8:33 pm
by Nikita

Hi Michael,

Yes, you understand it right. You need to associate localStorage variable and collectionName parameter of this service by mapping. Appery.io will automatically replace collection name in service URL with this value.


i18next and collections

Posted: Fri Mar 28, 2014 8:58 pm
by Michael4771079

Great stuff Nikita,

I will research this, a tutorial on collections for i18 would be good, it will help lots of users.

But can I ask this,

the code above is run on deviceready to id the language,
then with js the a request parameter with the collection id is set and service is invoked, and collection for identifed lang is used

so it must need an if and else for all the langs you have collections for,

for example
meatpizzaEN
meatpizzaES
meatpizzaGER

if you have a sample of the code needed or a link it would help alot

really appreciate your time on this

thanks again


i18next and collections

Posted: Fri Mar 28, 2014 9:12 pm
by Nikita

Hi,

Just save collection name in localStorage:
localStorage.setItem("language", "meatpizzaES");
Then bind variable language with request-parameter collectionName by mapping:
http://docs.appery.io/documentation/r...


i18next and collections

Posted: Fri Mar 28, 2014 9:48 pm
by Michael4771079

AAAAHHH!
got ya,
so the code looks for the lang on device and for variable it sets the collection for the lang identified,
I'm always thinking it more complicated than it is

cheers Nikita,