The first phase of edu 2.0 internationalization is almost complete, so I thought I'd write a little more about the process and infrastructure works.
As anyone who's gone through internationalization knows, it's time-consuming and tricky. So investment in a nice infrastructure to support it usually pays dividends. Since edu 2.0 supports community-contributed content, we decided to make the translation process itself something that the community could contribute to.
Here's how it works.
First of all, we maintain a database of languages. To streamline the initial phase, we only currently support common left-to-right languages. Here's a screen shot of the language table, which includes various items for each language including its flag and country code.
Each language has an associated set of translators, who are usually volunteers from our site. These translators have permission to translate the labels associated with their language. For example, here are the translators for Spanish:
We maintain a master database of labels with their English values; it currently contains 998 entries and will probably grow to around 1100 entries by the end of the initial translation process. We add new labels and their English values via a web form; translators don't use this form, since they translate labels rather than adding them. Here are the first 5 entries in the labels table:
When a translator wants to translate some labels, they log in and select the category of label they'd like to translate. For example, to translate the labels for all the buttons, they'd click on "Button text" in the following screen, enter the translated labels, then press Save.
Here are the first few entries for the Portugese version of the site:
When the system is started, the labels are loaded and cached together with all their translations. In addition, a global variable (which start with a dollar sign in Ruby) is created for each label with a name equal to the name of the label and value equal to the label itself. For example, $accept points to the label "accept" whose English string is "Accept" and whose Portugese string is "Aceitar".
All the Ruby templates and code use $accept whenever they want to include the text meaning "Accept", and the runtime system selects the string associated with the user's session.
For example, the Ruby code:
link_to $accept, :controller => 'moderate', :action => 'accept', :id => @material
creates a link whose text is set to the user's native translation for "accept".
Of course, there are other aspects of internationalization that have to be dealt with, such as:
- passing appropriate flags to third party code such as the FCK Javascript editor
- translating dates and times
- detecting the prefered language for the user's browser
- allowing the user to change and save their preferred language
- alerting translators when new labels are added or old labels are changed
We didn't originally intend to translate our site for about a year, but the number of foreign visitors to our site combined with our invitation to present in Spain changed our plans. It's taken about 4 weeks of hard work so far, but I think it will be worth it.
Recent Comments