(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
- Open the lang-codes.txt and add the language code coresponding to the language you want to add (eg. de_DE.utf8,Deutsch)
- 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.
- Open that default.po file by using the PoEdit application
- Open the Catalog -> Properties menu and edit the translation properties and source path
- 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)
- 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.
- 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.
- 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).
How to update an existent language
- 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
- open the PoEdit program then open the *.po file
- follow the step (6) above
PoEdit (how-to) references
- http://localization-guide.readthedocs.org/en/latest/guide/poedit.html
- http://wiki.lxde.org/en/Translate_*.po_files_with_Poedit
- https://wiki.tine20.org/Contributors/Howtos/PoEdit
- https://en.opensuse.org/SDB:Configuring_poedit
- https://www.youtube.com/results?search_query=poedit
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)
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.
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.
- The display language on Windows depends on the OS version you have:
- XP : http://windows.microsoft.com/en-us/windows/language-packs#lptabs=xp
- Vista : http://windows.microsoft.com/en-us/windows/language-packs#lptabs=vista
- Win7 : http://windows.microsoft.com/en-us/windows/language-packs#lptabs=win7
- Win8+ : http://windows.microsoft.com/en-us/windows/language-packs#lptabs=win8
- on LINUX like systems:
- to determine which locale are installed run this command: locale -a
- to determine the current running locale run this command: locale (it should be the same as per /etc/locale/conf)
- for more info check your distro manual.
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
- 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