4

Is there a way to internationalization html pages based on user locale? I had a website developed using html pages but now I am asked to internationalize that website in 4 different languages.

I know how to do it using Spring Framework via resource bundles but I wanted to know if there is a way to do something similar using HTML pages so that you just have to write the code considering internationalization and just keep adding the resource bundles to be picked based on user locale when a user accesses the website?

skip
  • 12,193
  • 32
  • 113
  • 153

4 Answers4

6

I've just developed a solution a little bit lighter, using CSS content property : https://github.com/k-yak/stati18n Take a look, all informations are available in the readme file.

1

How about this?

http://code.google.com/p/jquery-i18n-properties/

Eugene
  • 117,005
  • 15
  • 201
  • 306
  • After seeing the wiki, can I use this lib to directly change add the text to the html like and after I load the properties file, this will be changed accordingly? I mean is there a way to avoid setting the static text using javascript by #(...).text(jQuery.i18n.prop("title")); if no, Is there a lib to achieve this? Thank you! – JaskeyLam Mar 31 '15 at 09:04
1

Or How about this?

How does internationalization work in JavaScript?

If you can't do Javascript you'll have to use some form of templating or dispatching. That is either respectively:

  1. Use JSP and Spring's Message taglib (or any other templating language that supports i18n)
  2. For each locale you would copy all the HTML pages in a locale directory and then dispatch to the directory based on the locale (I don't recommend this).

What I personally do is use jMustache which is barely a templating language and then for each page (or many pages) I will have request controller that will load all the translations for the request locale into a Map object which I feed to jMustache (see Option 2 of my answer here: https://stackoverflow.com/a/10004113/318174).

Community
  • 1
  • 1
Adam Gent
  • 47,843
  • 23
  • 153
  • 203
0

If you keep your site static, you'll end up having multiple copies of your site, unless you can dynamically modify the page using javascript. But, you'll also want the URL's to have the language code in them to save state and be good for SEO.

I developed this free solution. http://www.sitetran.com/

Gidon Wise
  • 1,896
  • 1
  • 11
  • 11