From LifeType Wiki
LifeType can be translated to any language, easily. In order to translate LifeType to a new language, it's a good idea to start based on the English locale (locale_en_UK.php) Make a copy of it, name it according to the rules below and translate the messages.
Where LL is the language code in lowercase letters and CC is the country code in uppercase letters. So locale_ca_ES.php means the Catalan (ca) locale used in Spain (ES)
As of Lifetype 1.2, locale files are split in two parts: one part for the blog front-end and one part for the administration back-end. The reason for this approach is that there is no need to load 1000+ lines of PHP strings for the blog front-end where hardly 100 of those are used, and the result is a few hundred kilobites of memory saved.
Front-end locale file are stored in the locale/ folder while back-end locale files are stored in the locale/admin/ folder. Both files follow the same naming scheme and internal format.
Locale files should be saved using a certain encoding. When working with western language, it is most likely enough to use iso-8859-1 but when working with other languages, it is advisable to use UTF-8 as it will make things easier further down the road. Please bear in mind that the front-end locale is the one that defines the encoding, direction and other parameters (so it is not possible to have the back-end locale using a different encoding from the front-end one)
Locale files are nothing more than a PHP file with one big associative array. Any line of a locale file looks like this:
$messages["key"] = "message";
When translating, only the message on the right side of the equals sign needs to be translated. The left part is what is used to refer to this message in the code and if changed, it would cause the right message not to be displayed.
All work basically consists in working line by line and provide a translation to our language of choice to each one of those lines.
Some of the lines have special tokens such as "%s", "%1" or "%2". These tokens do not need to be translated, and they are only placeholders that indicate the locale engine in LifeType where to place certain bits of dynamic text. For example, the message that is used to inform users that an article was successfully deleted looks like this in the English locale:
$messages['article_deleted_ok'] = 'Post "%s" deleted successfully';
Here %s means that the topic of the artible that was just deleted will be dynamically embedded in that message, so it is important not to remove it. It is possible, however, to change its location in the message according to our language.
At the top of a locale file there are a few lines which are not messages but special values that tell the LifeType locale engine how to handle certain parameters of this locale file:
- encoding: encoding in which this file was saved. It is important to set here the same encoding as with which the file was originally saved. This parameter is used in all pages and responses generated by LifeType so if the file encoding and this parameter don't match, we will most likely get gibberish in our pages.
- locale_description: description of the locale (used in the user interface)
- date_format: the default date format (based on [these parameters])
- direction: Set it to "ltr" for left-to-right languages or "rtl" for right-to-left languages. If not set, it will default to "ltr".
- days: an array containing all the weekdays in their "long" form.
- daysshort: another array with the 2-letter version of the days.
- months: an array with the list of months
- first_day_of_week: set it to '0' to make Sunday be the first day of the week or '1' to make it be Monday. If not set, it will default to '1' (Monday)
Updating a locale file
Once a locale has been created, it needs to be maintained for future releases.
Usually the development team works on the English locale and places new and updated strings at the bottom of the file after a certain mark. For example in the case of LifeType 1.1, this is marking the place where new strings have been added:
// // new strings for 1.2 //
In order to update a locale file, all that needs to be done is copy all the strings below this mark to the locale file that we are currently maintaining and translate the messages.
Locale files which have not been translated are moved to the locale/unported/ folder, please move it back to the locale/ folder so that it is visible to LifeType.
Once the locale has been updated, please submit it via http://bugs.lifetype.net so that the development team can update it in the Subversion repository.