views:

129

answers:

2

For a website I'm doing, I'm only using static content such as HTML, javascript, CSS, images (no PHP or server-side language).

I want to be able to localize in English and French, but I'm unsure what would be a good solution. Here are the solutions I have in mind so far:

Duplicate HTML pages
Pros: simple, SEO friendly
Cons: a pain if I decide to change anything, I'll always have to do it twice

Dreamweaver templates
Pros: SEO friendly, update friendly
Cons: so many places to add regions that it would double the HTML size, messy code

JST: javascript templating
Pros:update friendly, code friendly
Cons: SEO?, not made for this?

Any other ideas or further advice on the current list?

+1  A: 

A hybrid solution may work for you:

  • Develop the main HTML content, all in DIVs with IDs, in English (SEO-friendly for English at least).
  • Create links on the page to switch to another language
  • When the user clicks the link, rather than loading more static files, run some JavaScript that loads a static JSON array of IDs and translated language, loops through the array and replaces the InnerHTML of the DIVs.
  • As a bonus, have that code also change all internal links on the page to add #language-en or whatever to all links. Then, when your page loads, have the Javascript check for a language argument in the URL and automatically load the preferred language.

Use JQuery to handle all the messy ID selection and AJAX calls to load language files.

If images need to be replaced, make your JSON data more robust by having three columns: element ID, attribute name (to switch either "src" or "InnerHTML" or whatever), and the content (which, for an image, would be a localized src, and for a DIV, the replacement text).

richardtallent
Thanks. I'll sleep on it, it's getting late here in France.The Cons I see with your solution would be the number of Id I'd have to add, and the SEO for non-English languages, but I still like it.I have no image to localize, I went for @font-face.
JB Hurteaux
+1  A: 

Use a little PHP to replicate the pages on your side. Treat the HTML pages like PHP files, localize the PHP files, then use the web server to compile your PHP into static web pages (using file_get_contents). Just compile the HTML into a language directory and have English be the default root. Even if your production server fails to have PHP, you can save yourself some time by using PHP on your side.

MathGladiator
I do like this idea as well. Thanks.
JB Hurteaux