This page is about Localization best practices for developers. If you are looking for information on adding Languages to you deployment go here
Ushahidi is built on Kohana which provides language some localization helpers. See the Kohana docs for more info: http://docs.kohanaphp.com/general/i18n
Tips when creating strings
Never hard code strings
Don't split strings
Example:
You're including a heading 'Approved Reports'.
There's already a translation string for 'Reports' so we could just reuse it:
However thats a bad idea..
1. it provides translators with no context
2. it assume the words will always appear in that order, when for example the French translation is more like: 'Rapports approuvés'
Use arguments and string formatting
Example:
You're including a reports count: 'Showing 10 - 20 reports'
Use explicitly ordered placeholders:
Why? Because ordering my vary in other languages. The 1st version gives translators no context and assumes all languages structure sentences the same way. Using arguments and formatted strings is much better.
In some languages the string transliterated back to English might read something like:
Exception: when there is only 1 placeholder
When theres just 1 placeholder in the string, its ok to use unordered placeholders
Don't create string in ALL CAPS
Creating strings in all caps means when the design changes and you want search in lower case.. all the translations have to change.
And if themers want the text in lower case, they have to hack the translation files.
If you do this the good way, when the design changes you can just update the code..
Even better might be to replace the string to upper call with a CSS text-transform, making life even easier for themers.
Use utf8 functions when transforming text
PHP's built in string manipulation functions don't always handle UTF8 characters. Use Kohana's utf8 library where you can instead (http://docs.kohanaphp.com/core/utf8)
Related links
- Kohana lang docs http://docs.kohanaphp.com/core/kohana?s[]=lang#use_language_strings
- Kohana internationalization http://docs.kohanaphp.com/general/i18n
- Kohana UTF8 library http://docs.kohanaphp.com/core/utf8