Localization: Two suggestions
WP localization is taking its first giant steps. (thread: http://wordpress.org/support/4/1929). I like the work Otsukare has made. There are no global translations as each translation is tied to a file. This makes it easier to translate each different situation correctly. I have not installed the script. However, my first impression is that it has one of the best formats i have seen. Very easy to work with.
As the work goes on from there i have two points. In my experience, only a few issues are required (from the code) to achieve a good-excellent translation.
I am a translator, not a coder. My ambition was to make the best translation of PostNuke and phpBB2 and some smaller apps (to a North European lang). To achieve this many parts of code had to be changed to accommodate the fluent language i was striving for. I did it but you can guess the rest: the modified code became too difficult to update, thus insecure and useless. End of story. – Now i have found WordPress 😉
Based on the experience, I will stick my neck out and state two requirements for code to be easy to translate:
1) Accommodation for different word order in different lanquages.
2) Accommodation for an alternative expression/word in different situations.
( and of course: UTF-8 )
Both are very easy to achieve. As follows:
1) Different word order.
code file: sprintf(_LANG_WELLCOME,$username);
English lang file: define(‘_LANG_WELLCOME’,’wellcome Mr. %s.’);
Japanese lang file: define(‘_LANG_WELLCOME’,’konnichiwa %s san.’);
This yields the correct greetings:
“welcome Mr. Smith.” (English)
“konnichiva Tanaka san.” (Japanese)
As phpBB2 was being developed, there was a good discussion on this matter. No wonder phpBB2 has been since translated to some 53 languages. Some examples:
‘LAST_VISIT_DATE’ => sprintf($lang[‘You_last_visit’], $s_last_visit),
English lang file:
$lang[‘You_last_visit’] = ‘You last visited on %s’; // %s replaced by date/time
$lang[‘Registered_user_total’] = ‘We have %d registered user’; // # registered users
$lang[‘Current_time’] = ‘The time now is %s’; // %s replaced by time
I have seen this point raised again and again in many forums, e.g., take a look at this thread:
“…all sentences have to be translated wholy. Variable parts are inserted into the string…” See the example.
It is my experience that NOT ‘all sentences have to be translated in whole’. Based on phpBB2 i estimate 3 to 7 % of the strings have to be coded this way to achieve smooth expression.
2) Alternative expression/word
The correct use of non-English language may require a different expression depending on the situation. How to do it? There are many approaches. This is one of the least demanding (in terms of code changes) and least confusing:
Add a small suffix (_2 or _#2 or …) to other instances and add a new line to both lang files:
echo _LANG_CX_CANCEL; // first instance
echo _LANG_CX_CANCEL_2; // second instance
echo _LANG_CX_CANCEL_3; // third instance
English lang file:
Some lang file:
This may inflate the lang files by 5 to 20 % but it is a small price to pay for wider usability. This must be accompanied with a policy to accept such a change request from a translator. It involves adding the proposed suffix to the main release and duplicating one line in the English lang file. Developers can leave other languages to the translators.
I am NOT a coder. Is it possible to code a routine to make this easier? The logic is as follows:
if the required text with suffix (“_LANG_CX_CANCEL_with_suffix”) is not available
use text without the suffix (“_LANG_CX_CANCEL”) in stead.
This would eliminate unnecessary inflation of lang files when there is no need for an alternative expression. And translations would not break as easy as they do.
This is my 2 cents.
I would be happy to see Otsukare release integrated into main codebase. It would elevate WP to the next level.
- The topic ‘Localization: Two suggestions’ is closed to new replies.