There are a few things you need to keep in mind when developing multilingual support:
1 - Separate the code from the data (i.e. do not insert lines strictly into your functions)
2 - create a formatting binding function to eliminate differences in localization. Allow formatting strings ( "{0}" ) is better than concatenation ( "Welcome to" + value ) for many reasons:
- in some languages, the number is formatted as 1.234.678.00 instead of 1.234.567.00.
- pluralization is often not as simple as adding "s" at the end of the singular
- The grammar rules are different and can affect the order of things, so you must allow the addition of dynamic data after the translation hook: for example, "Welcome to {0}" turns into "{0} he youkoso" in Japanese (this happens in almost every language note).
3 - Make sure you can really format the lines after the translation is intercepted, so you can reuse the keys.
4 - Do not fall under any connection to the output of the translator database by the translator utility . If you have multilingual data, create separate tables / rows in your database. I saw how people often make the wrong mistakes (usually for countries and states / provinces in forms).
5 - Create coding rule rules to create keys. The function of the formatter utility (which will look something like translate ("hello world") will take the key as a parameter, and the keys with minor changes are very convenient for maintenance. For example, you can use three keys in the following example: "enter a name", "enter your name: "," enter your name: ". Choose one format (for example, without a colon, trim) and catch inconsistencies in the code views. programmatically, because it can cause false positives.
6 - Remember that HTML markup may potentially be needed in the translation table (for example, if you need to highlight a word in a sentence or have links to medical footnotes). Test it for this.
7 - There are several ways to import language strings. Ideally, you should have several versions of the language.lang.js file, switch between them with server-side code and link to the file from the bottom of the HTML file. Pulling a file through AJAX is also an alternative, but may cause delays. Merging the .js language into your main code file is not recommended as you lose the benefits of file caching.
8 - Check your target languages. This sounds silly, but I saw a serious mistake once, because the programmer did not bother to check for the presence of "é" in the key.
Leo Oct 23 '08 at 12:45 2008-10-23 12:45
source share