There are a number of approaches to making your website multilingual, and as with all design decisions, the requirements of your site should dictate which way to go in the final analysis. In this article I’m not going to examine the pros and cons of each approach, but instead we’re going to take a look at a custom multilingual framework that makes things easier for translators.
All text on the website, whether it’s a word, sentence, paragraph, link, or whatever, is stored in a back-end database and accessed using a key, ie. an integer and a language identifier, for example, EN. So you can have a pair of registers like: 1, IN, “Hello” and 1, YOU, “Salam”. You can also have fields indicating which page the text can be found on, which is useful later in the translation app.
Each website content page exists once for multiple languages. It is not necessary to replicate the source code of each page. Using this approach, I built a php-based application and whenever text appeared in the HTML, it was replaced with a php function that looked like this: p(“Hello”,1) The ‘p’ function prints the word ” Hello” in whatever language is currently active. If English is on, the function simply returns the English text that was sent to it. If another language is being used, the function looks for that text entry in the required language and returns it. The active language can be stored in a GET or Session variable. An obvious benefit of this approach is that the “Hello” text stays where it belongs in the page font and is easy to read and maintain. Other approaches sometimes leave you with nothing more than a cryptic text key and you have to search for the text manually in order to read the HTML.
Since you’re probably not interested in keeping track of a large database of text identifiers by hand, eg Hello = 1, Goodbye = 2, there are simple approaches to automation. For example, when programmers write “Hello”, they simply encode p (“Hello”). Later, a utility runs, finds the virgin “Hello”, assigns it an id, and updates the code to look like p(“Hello”, 1). The same utility can check existing text entries to see if the English text (or whatever its base language is) has been updated, and then make a note in the database that will alert translators that the translation should also be updated. update. We keep track of the current English text and the previous English text in our database so that translators can see the history of the text change.
What about the efficiency you ask for? To avoid database lookups for each text screen, we load the entire text database for a particular language into a session array variable each time a user switches languages. This is quite fast and not noticeable to the user. If you have a large website, you may want to load only select parts of the site into the matrix at any given time. The ‘p’ function then does a very fast array search to return the appropriate text. Of course, the base language doesn’t require any lookup, since it’s already passed into the function.
With all the text in one database, it’s easy to create applications for translators to add an entirely new language or update text that has been modified on the source pages. Translators do not need to know html to do their job. A nice feature is being able to copy a translation of a particular text that is the same across multiple pages. Be careful about reusing translations, as the translation may need to vary depending on the context of the page.
This is not an exhaustive description of what needs to be done to make your site fully multilingual. There are many issues ranging from simple things like displaying the date and currency to more subtle culture-driven issues like what images or colors do you use. You can now display at least one design framework option for your multilingual site. Here is a site where this method has been used: www.goodneighboraz.com Good luck with globalization!