A Nice Language Switching Widget
I’ve been looking out for ways to format multilingual content in blog entries—we intend to eventually start having translated content in the present blog as a test case.
Simple interfaces are the best, and I ran across a simple intuitive, implementation of “language toggling,” if you will:

You can see from our astonishing animated GIF technology that the content changes right there in place: click on the language you want to see, there it is, right there.
It hardly even merits the title of “widget.” But the best interfaces are like that—they’re so simple you might not even notice them, or even if you do, you don’t stop to think that there could be another way.
I like this because the text remains in place, and you don’t have to wait for the whole page to reload, since it’s just toggling the visibility of two divs with some Javascript.
- Somehow highlight the name of the “current” language—put the language names in tabs or something?
- It should be possible not just to toggle between languages in a single post, but also to save preferences for the blog as a whole.
Some techier notes…
That said, the Javascript itself is inline: it’s coded right into the onclick attribute of the links. I poked about in the navigation of Wouter’s site, and this language toggling functionality doesn’t seem to be applied to other posts on seweso (they seem to be either in Dutch or English, but never both as in this post). So this was probably a quick solution—and it works very well as such.
For a blog that has regular multilingual content, then (and possibly some views in Blogamundo’s aggregator), this kind of functionality would be available on every post.
Which would probably involve one final change:
- Factor out the Javascript into external files that can be used for more than one post.
This leaves the question of how to mark up all this stuff. I believe it’s possible to select divs with Javascript by referring to the lang attribute, so maybe it’d be something like… er, this is a whole ‘nother ball of wax.
I’ll get back to you, we’ll do lunch.
5 comments.
Technorati tags: Code, javascript, translation, ui
Have you ever heard of a