A number of times I have needed to support multiple languages when building web sites but have yet to come up with a good way of passing the language strings from the server to the client so that they can be used in Javascript for dialogs, messages, etc.
What are your recommendations or experience with this?
EDIT: I'm leaning towards generating the javascript language files on the fly and would appreciate it if anyone knows any third party libraries that can do this.
I usually move all string specification to separate files and then include the appropriate one on the page, something like this:
In st/js/messages-ru.js:
hello = "Привет"
bye = "Пока"
In st/js/messages-en.js:
hello = "Hello!"
bye = "Good bye!"
When the page is generated, you can determine the language and insert the appropriate js file on the page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With