Jump to content

for loop...array


jimfog

Recommended Posts

The selector for remove is using a ">". This means remove should be applied to #adrserror descendants (perhaps needed .each()). you can instead remove the ">" and use .empty() if you prefer.

 

As for the translation, I don't know much. looking around a little shows that you can try and use google's translate API, link to Bing's translate API, or resort to using Ajax calls and having the translation done server-side. I don't know of many other options.

Link to comment
Share on other sites

Now,I want to mention a last thing about the loop...the fields array contains the items in English...I want though the displayed messages to be in Greek(my native language). What can I do?

 

The text fields come from the English-speaking user?

Link to comment
Share on other sites

 

The text fields come from the English-speaking user?

Τhe text comes from Greek user.That is why the error messages must be in Greek.

But, in the server script the array keys are in English and these are what is returned from the server to the client with ajax.

So there must be a match between the English array keys and the Greek error messages

 

Meaning...when an array key is returned false from the server(after the checks have been made)the corresponding Greek message appears.

Link to comment
Share on other sites

But, in the server script the array keys are in English and these are what is returned from the server to the client with ajax.

So there must be a match between the English array keys and the Greek error messages

 

Meaning...when an array key is returned false from the server(after the checks have been made)the corresponding Greek message appears.

 

Oh, you can just create an array of translation strings. In fact you could use the same keys.

Link to comment
Share on other sites

 

Oh, you can just create an array of translation strings. In fact you could use the same keys.

And how this could be implemented...an example would help

Link to comment
Share on other sites

For example, instead of Ajax returning a data object full of trues and falses. You return and object full of empty strings (instead of true) and translated strings (instead of false). Your server side code may know whether to use English or Greek depending on either a session variable, or ideally server side via by checking the http header "accept-language" which browsers will send to you by default on every request (I think that includes Ajax calls). I once saw how a game handles localization wherein each language was stored in separate files and in each file was a huge list of variables, like variable t_00879 ="hello, welcome!" in the English file, and in the Spanish file t_00879="Hola, bienvenido!". And in the game, it only tracks the variable name t_00879, not the strings themselves. The game will load the right localization based the gamer's preferred language.You may not have to separate the languages out into separate files, but you could divide the string definitions by if else/switch blocks

Link to comment
Share on other sites

For example, instead of Ajax returning a data object full of trues and falses. You return and object full of empty strings (instead of true) and translated strings (instead of false). Your server side code may know whether to use English or Greek depending on either a session variable, or ideally server side via by checking the http header "accept-language" which browsers will send to you by default on every request (I think that includes Ajax calls).

 

The alternative you propose(empty/translated strings) seems OK to me...I will see to it.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...