I was recently chatting about writing a web-based system, and the idea came up of making the interface multi-lingual. Just to be clear, this was idle chit-chat and this is not something that will be built (probably!)...but it got me thinking...
If I were to build a web-based system, how would I make it multi-lingual? In other words, all the interfaces and other wording on the site could be set to display in another language instead of the one it was originally written in.
Let's leave aside the problem of actually doing the translations as that is the same regardless of implementation. Let's also assume that we are going to use Template to build the system.
The first option is to have the template files contain just structure and the language passages.
Then to pass all the text parts to the template file from the Perl script.<h1>[% heading %]</h1> <p>[% introduction %]</p> <form method="post"> <table> <tr> <td class="label">[% form_name %]</td> <td><input type="text" name="name"></td> </tr> </table> </form>
This seems to violate the concept of MVC and involves passing huge numbers of template variables. It also makes the template file very difficult to read as there is not much text, only the variables.
The second way I came up with was to do much the same but to hold the template variables in a language template file and PROCESS that. There would be a different language template file for each language:
Again this makes the template file very difficult to read.[% PROCESS $language.tt %] <h1>[% heading %</h1> <p>[% introduction %]</p>
Lastly I considered having completely separate template files for each language. Arrange these in different directories by language and pass in language-specific variables where variables would be passed in for a mono-lingual system.
This last approach has lots of advantages. The template files are easy to read as they have all the static text, Only the necessary variables are passed into Template and it is easy to add another language. But there is a big disadvantage - although it is easy to implement, it would be very difficult to maintain. A change made to one template file would need to be made to the corresponding one in every other language. It would probably need a script to keep them all in sync.
Is there another way that I haven't thought of?
I'm sure I'm not the first person to have thought this through!
What is the "best" solution to this problem?
In reply to Multilingual design by Bod
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |