How to translate streber into other languages.
How Translation works in streber π
Streber uses translation tables. You can find them in directory
There are typically two files for each language. The
contains the actual translation table as an associative array. This file looks like:
'English|for language selection' =>'Englisch',
'Home|Tab in top navigation' =>'Home',
'%s error(s) occured' =>'%s Fehler is aufgetreten',
As you can see in the example, the orignal string consists of two parts separated by a pipe ( '|' ) symbol. The second part is optional and clarifies the context. Do not translate this ;-)
At the end of some lines there might be comments starting with "#". You can ignore them.
Inside the codeπ
Inside Streber, strings that require translation are used like this:
echo __("Home", "Label inside navigation tab");
Translation keys (
) are defined in plain English and will be used for the English version of streber. They can have an additional description to clarify its meaning or usage (
Label inside navigation tab
). In this examples, the translation should be very short, because it will be used inside navigation. The two underscores are actually a function name. This function looks into the translation table of the current language and searches the Key
Home|Label inside navigation tab
. If found, it will be used. Otherwise we try the key withough clarification (
), and if this fails too, the original English string will be printed (of course without the context part).
Strings containing dynamic attributes contain
and are built with the sprintf(). Like:
echo sprintf( __("%s error(s) occured"), __("No"))
If translation keys are not found (e.g. for "No"), they are stored in an internal list of missing language-keys. You can display this list at the footer of each page by adding this line to your
Although this might be good for testing a tranlation, it is cumbsersome to get all strings that need translation. For this we wrote a small perl-script called
. It scans all source files in all of the project's directories and looks for strings inside the __() functions. It then looks for languages in /lang/*.inc and writes a list of untranslated strings to files called
. One file for each language.
If you have translated streber into a language, please check the release of each new version for a ".changes"-file concerning your language and add those keys to your translation.
How to translate Streber into a new language π
- Start with a copy of
- Rename the copy to the shortform of your language (like
- Open the new file with a text editor capable of utf8 editing
- Add your translation into the quotes. (Keep in mind to ignore the part after "|")
- Save the file using the "UTF-8 without BOM" encoding.
- Search for
g_languages and add your language like:
- Add the following lines to your
customize.inc.php. This will warn you on missing translation keys when testing the translation.
- For testing make your language the default-language or adjust your profile accordingly. To customize.inc add:
confChange('DEFAULT_LANGUAGE','??'); #<- replace ?? with your new language
- Start using Streber and check your translation. Esp. check for layout problemns when translated words (e.g. column-headers) get too long.
- If the context for the translation is not clear enough, please drop a comment to ?. Pixtur will check this.
- If you are done...
- Don't forget to place your credits into the header.
- Add a new Folder at Translations and attach the new file. We will add it to the next release.
Some hints for translatorsπ
- Avoid line breaks inside strings (inside quotes)
- Avoid quotes inside strings
- Keep it short! Long texts not only clutter the layout, but it slows the user down. Be as brief as the context allows.
- Make it shorter! For column-headers do not hesitate to use abbreviations. All column-headers have tooltips.
Localization of datesπ
Localization of dates is being performed though the PHP functions
, which needs the proper locale to be set with function
. Each language file must provide a list of locales to be passed to
as a translation of the string
'en_US.utf8,en_US,enu|list of locales'
. You should provide at least three locale names in the translation. For example the Italian translation would be
'it_IT.utf8' is the name of the locale for libc-based PHP implementation (for example under Linux) with proper utf-8 support. Names in this form are language_country with two letter ISO names for both language and country;
'it_IT' is the same name for those platforms who lack proper utf-8 support;
'ita' is the three letter name for Windows-based platforms.
for a list of supported names.
The formatting string themselves needs to be translated. In particular:
'%b %e, %Y|strftime format string' for dates like Jan 16, 2007 used in very many places;
'%I:%M%P|strftime format string' for time strings like 4:48pm used in very many places (the only meaningful translation for this string is
'%H:%M' for those languages that prefer 24-hour format);
'%a %b %e, %Y %I:%M%P|strftime format string' for long timestamps like Tue Jan 16, 2007 4:48pm used in many places;
'%A, %B %e|strftime format string' for dates like Tuesday, January 16, currently used only in page titles.
reports that some PHP implementation do not handle the
formatter (day of the month from '1' to '31') properly. In those cases the
formatter (which is the same but from '01' to '31') although not as good-looking should be used instead.
For further details about
, please refer to the respective doc pages: http://php.net/manual/en/function.strftime.php
Thanks for your support!