One of my greatest problems working with EE has been making a bilingual site that works. EE being a very flexible tool allows for so many ways to try out the best solution. The simplest and easiest way I’ve come up with is the following.
I try to be as modular as possible, which means that I create separate weblogs, template groups and category groups for each language. Different weblogs means that I can direct searches to different pages in different template groups, and searches generally won’t work with only one weblog. What title to display? Which extract? It all turns into a mess.
It also means that I can use the same entry form for all languages without having to create different custom fields and different templates for each language. I only have to assign different variables and parameters to the templates so that the ‘wrong’ language won’t be displayed.
I then link the english version via the related_entries tag to the swedish, where I use the reversed_related_entries tag in the template to ensure that nothing goes wrong (and it’s simpler than to link back and forth in the forms).
The template groups I call “en” (english) and “se” (swedish). This allows me to script what should be displayed on each page by adding a conditional {if segment_1==“se”} this {if:else} that. Of course one could keep a single template group and just add the segment “en” etc to each URL.
I also assign categories in both languages to each entry. This has been the main problem, and still is to some extent. How do I tell EE what category to add in the URLs between the languages? While it works to add {segment_2} or to use the category:weblog_heading tag in the URL, the page linked to displays as it should, except if I want to show the category heading, for instance, in the title of the page. There I get the ‘wrong’ or both both languages.
If I use the categories tag and the show not parameter I would have to do a lot of hard coding each time a parent category was added. No point in adding show=”{segment_2}
This could be improved if the category_group parameter were allowed in the categories tag, then it would be possible hardcode the URL once.
Finally, I only have to add this code for each language to make the linking work just fine.
{if segment_1==“se”}
{exp:weblog:entries weblog=“my weblog_se” limit=“1”}
{if category_request}<a href=”{path=en}{segment_2}”>english</a>
{if:elseif url_title==”{segment_2}”}{reversed_related_entries}<a href=”{path=en}{url_title}”>english</a>{/reversed_related_entries}
{if:else}<a href=”{path=en/}”>english</a>{/if}{/exp:weblog:entries}
{if:else}
{exp:weblog:entries weblog=“my weblog_en” limit=“1”}
{if category_request}<a href=”{path=se}{segment_2}”>svenska</a>
{if:elseif url_title==”{segment_2}”}{related_entries id=“my_custom_field”}<a href=”{path=se}{url_title}”>svenska</a>{/related_entries}
{if:else}<a href=”{path=se/}”>svenska</a>{/if}{/exp:weblog:entries}
{/if}
