Hi everyone,
Apologies that this is a long post. A while back, I had spoken about my
idea for a simple language bar.
Background
For a site I’m building, there are a number of technical articles. Some
(not all) of these have been translated into other languages (not all
languages). So, what I wanted to achieve was to have a simple language
bar that included links to translations of the same article with
minimal effort.
Current Solution
I have come around to the idea that the whole site should be organized
with each language site being put under the root. So, under the home
page, there is “en” for English, “jp” for Japanese and so on. Each
language site is set up as having the exact same structure. I require
the slug for the page to be the same for translated articles. So,
‘intro_to_radiant’ would be the slug even if the exact URLs are:
→ example.com/en/tech/intro_to_radiant
→ example.com/jp/tech/intro_to_radiant
→ example.com/kr/tech/intro_to_radiant
Now, I’ve created a couple of tags that render the language bar by
iterating through the languages and changing the language base in the
URL. If find_by_url finds the language article, a link is rendered to
it.
Further, this is in a snippet and can be rendered quite neatly with
minimal effort.
Problems
OK, here’s the problem. Right now, I have 2 tags - one is something
like <r:site:lang_each> and the other is <r:site:langlink> – one
iterates over each of the languages in the list and the other renders
the link if it exists.
[1] The problem is that my <r:site:lang_each> iterates over each of the
languages without knowing if the translation exists. On the other hand,
the <r:site:lang_link> renders a link only if it exists. If I use a
list to render the links to the translations, it shows one bullet for
each iteration of the lang_each. I don’t know what to do.
[2] The other way would be to iterate over the possible languages in the
link tag itself (call it something else) and render the full language
bar. This affects how I can style it (things like separators, etc.)
Any ideas what I can do?
Cheers,
Mohit.
10/31/2007 | 1:57 AM.