MyBackup Localization

(WP) MyBackup has been created having multi-language support in mind.

Internally all its captions, labels and messages are expressed in English by default. This is the primary (default) localization resource that is used.

If you want to add a new language translation or to update an existent translation you should know that this is possible with the aid of PoEdit program available on Linux, Window and MacOS. Check these references for how it works.

How to add a new language

  1. Open the lang-codes.txt and add the language code coresponding to the language you want to add (eg. de_DE.utf8,Deutsch)
  2. Create a plain-text file called default.po in ./lang/<lang-code>/LC_MESSAGES/default.po. You may use the ./lang/default.po.sample sample file as a starting point.
  3. Open that default.po file by using the PoEdit application
  4. Open the Catalog -> Properties menu and edit the translation properties and source path
  5. Open the Catalog -> Update from sources menu; it will scan the .php sources and will create a list with the default English strings (on the top) that you may translate one by one (on the bottom)
  6. Start translating each string selected on the top list (Source text) at the bottom (the Translation). Read also the Notes for translators/Comment note fields because they may contain important information from developer addressed to you, the translator.
  7. Once you have finished with the translation then save the changes (the File -> Save menu). It will generate besides the default.po file an object representation called default.mo. That is the Machine readable Object file (thus .mo) that the application will actually use. You may continue from the step (3) above at a later time.
  8. To make sure the new translated text will be used make sure you restart your web server application (ie. restart the Apache/IIS/Nginx service).
Note: if you want to take advantage of the PoEdit automatic translation then open the Edit -> Preferences menu then choose the Translation Memory tab. Add a new language then press the Generate database button. It will scan your system for source/object files that might be used to create a ad-hoc language dictionary.

How to update an existent language

  1. Go to our website and grab the .po source file: http://wpmybackup.mynixworld.info/lang/<lang-code>.po

Ex: for the Swedish language the language code is sv_SE so you should download the file http://wpmybackup.mynixworld.info/lang/sv_SE.po

  1. open the PoEdit program then open the *.po file
  2. follow the step (6) above

PoEdit (how-to) references

If you are interested in a depth insight of how it works then please continue reading below.

To make possible the representation in other languages (locales) few things were created:

  • a small function library called locale.php; it is automatically used to detect and activate any other languages
  • a small plain-text file called lang-codes.txt; it is used to inform the application what languages are available and what is their locale codes
  • a locale folder where different translations files may be installed

 

locale.php

This PHP file defines the following functions:

  • getAvailableLanguages – scans the lang-codes.txt file in the root/locale folder in order to know what locales are installed and where
  • getSelectedLangCode – parses the current selected language from the page URL
  • setLanguage – loads the specified language file and make it active

 

lang-codes.txt

This file defines what locale are installed, the rate of translation (between 0-100%) and where is located the translation file. As of 2015-06-28 it contains (apart from comments) the following lines:

,English
ro_RO.utf8,Româna,58
sv_SE.utf8,Svenska,1

The format of a line consists of 3 different information fields separated by a comma (ie. they are comma-delimited): [lang-code].[codeset],[lang-name],[percentage]

  • lang-code is the language code (eg. en_US, en_GB)
  • codeset is the codeset/charmap used for the specified language (eg. UTF-8,ISO-8859-15)
  • percentage (optional) is the percentage of translation (if missing then 100)

Note that the (default) predefined English language has lang-code=”” (ie. empty)

Each line should be terminated with CRLF. Whitespaces will be stripped. Any line that starts with `#` will be ignored (is regarded as a comment) as well any other empty line.

Important: in order to make these locales to work they should be supported/installed on the host OS.

 

The supported locale on Linux are found at: /usr/share/i18n/SUPPORTED.
A list of supported locale on Windows (XP, 2K3) can be found here. For Windows you may also want to see this.

You might also want to check the PHP manual regarding setlocale or binding the domain`s codeset:

 

locale folder

This folder is located in the root of MyBackup plugin/application and must have the following structure:

  • it must contain the files: locale.php, lang-codes.txt
  • it must contain a subfolder called lang:
    • this lang subfolder must contain a subfolder for each language code (eg. sv_SE) installed which name is given by the language code (ie. if the language code is sv_SE then the subfolder name will be called the same sv_SE). Within this language code dependent subfolder we must have a file called default.mo which is the object form of the default.po language file