Layout: browser / user chooses display language?

started by Bradanderson on Mar 30, 2005 — RSS Feed

Bradanderson Bradanderson
Posts: 10

I write pages in both Japanese and English. I want to have the same basic content on each page (especially ones with photos, etc). Is it possible to write the page in both languages and through CSS have either the user or the browser select which language to display based on their defaults?
Currently I am just duplicating content and making individual pages.
Thanks in advance,
Brad
I Did That Photography - ididthat.biz
bridalsnap.com

Baxter Baxter
Posts: 157

Yes, with some caveats.. the easy way to do it is to have all the text, place all english text in one box with an id, then all the foreign language text in a box with another id.

If you have to have text here and text there (like for menus, for example) use classes instead of IDs.

Then just use a simple javascript switch to hide one and display the other using display block and display none. Same basic concept as a stylesheet switcher.

Then go one step further and save the preference to a cookie, and load the appropriate stylesheet dependent on the cookie value.

The trick is getting the japanese characters to display, and working past text direction issues, but I'm assuming you've already sorted those out.

Bradanderson Bradanderson
Posts: 10

Baxter, thank you for your reply. I had considered the idea of using classes or id's for this, but wasn't sure how to go about switching it for the appropriate language/browser.
You said javascript would be able to do that. Unfortunately, I am not very good at JS. Could you point me to a link or article on how to do this? I imagine it's difficult to make this?
Thanks in advance,
Brad

Baxter Baxter
Posts: 157

What you need to do is hunt around for style switchers. There's js based ones, php based ones, etc.

In your case, you probably want one that stores the preference as a cookie or something.

Your document will have two divs, say "en" and "jp" with the appropriate language in each one. Your 'en' stylesheet will display:none on the 'jp' div and vice versa.

Besides stylesheets, you could also take a look at how sitepoints expanding/collapsing sidebar works... basically the same concept.

Maskodok Eko Maskodok Eko
Posts: 170

TOP SEO | Jasa SEO Profesional

TOP SEO | Jasa SEO Profesional RajaPoker88.com Agen Texas Poker Dan Domino Online Indonesia Terpercaya IDRPoker.COM Agen Texas Poker dan Domino Online Indonesia Terpercaya POKERSTAR88.com Agen Texas Poker Dan Domino Online Indonesia Terpercaya D

You must login to reply