I have localization written for my wabsite, in PHP. Since I'm also working with Javascript (jQuery), to dynamically add some tags, I have problems with localization.
For example: I add comments dynamically. The user can click "Show more comments", to show the next page of comments. If all comments are shown, the text changes to "All comments displayed". But this way, nothing is localized, because it's only using Javascript.
How could I transfer the localization to javascript? My current idea is to create a PHP script, that would accept a GET variable, for example "all-comments". Then it would search for the localized version of that, and return a JSON string. Is there any better way of doing it?
$l = new Language('en');then, I add each string to translate. For example:$l->addWord('welcome_msg', 'Welcome to my website!');. Then, when I have to echo the string, I just call it:echo $l->welcome_msg;.