Localization in a web app using JavaScript and JSON -


i'm trying set script automatically localize web application. web application intended use html5's offline caching ability, needs able work offline. such, javascript seems me best option.

i'd prefer put strings localizations in single json file so:

{     "en": {         "application_description": "this application's description in english.",         "application_name": "this application's name in english."     },     "ja": {         "application_description": "this application's description in japanese.",         "application_name": "this application's name in japanese."     } } 

i thinking maybe of giving elements localized custom attribute linking intended message (eg: i18n="application_name").

i can retrieve browser's language using navigator.language, though think results have split first section (eg: "en-us" "en-gb" , "en-au" should refer "en").

however, javascript knowledge basic, , while i've thought it, cannot determine how implement this.

many can offer tips or examples!

you can use wikimedia's jquery.i18n.


Comments

Popular posts from this blog

Javascript line number mapping -

c# - Is it possible to remove an existing registration from Autofac container builder? -

php - Mysql PK and FK char(36) vs int(10) -