News

The latest post about xili-language trilogy

More about .mo

xili-language multilingual plugin, since his creation five year ago, is based on two main things:

  1. the language of post (and custom post) is defined by the custom taxonomy “language”.
  2. the ‘live’ translation of terms is mainly based on .mo file of current theme (like translation in a localized website) of the current language. The plugin choose the right language according the current language assigned to the single displayed post, the home page or a list of posts.

Case of a standalone theme (w/o parent)

With a current theme with textdomain twentyfourteen (without child), for a french context, the file fr_FR.mo is loaded. (and if created by xili-dictionary or by hand with poEdit, the local-fr_FR.mo).
If the files are not found in a sub-folder of the theme, if, available in subfolder wp-content/languages/themes, the files twentyfourteen-fr_FR.mo and twentyfourteen-local-fr_FR.mo are loaded.
Be aware about that:
if a term or sentence (msgid) and his translation (msgstr) are in the fr_FR.mo and in the local-fr_FR.mo, the translation of local-fr_FR.mo has priority. It is a good thing if you are not satisfied by the translation delivered by the theme’s author!
local-xx_YY.mo currently contains translations of terms et sentences from the website itself (title, date format, categories,…).

Case of child and parent themes:

By default, only the .mo files availables in child theme are loaded.
To help translation strategy and versioning, it is now possible to use also files from parent theme languages folder. xili-language is able the define how will be done the merging between child and parent files.
As in above case, a local file is loaded from the current (here child) theme and has full priority.
For the other files (child and parent), you can define the priority, child or parent… By example, if you don’t want to modify the parent .mo files, so define child files as a priority.

The form is inside the screen under the 4th tab of xili-language settings.

merging .mo files option
merging .mo files option

xili-language version 2.11 shipped

Latest release (2.11) of xili-language shipped today.

Some new things for theme’s developers:

A conditional function – is_xili_curlang():
/**
* Test the current language of displayed page.
*
* @since 2.11
* use for other function elsewhere
* @param "" for undefined, slug of tested language alone or an array list
* @return true or false
*/
function is_xili_curlang( $lang = false ) {

This function is also usable in plugin xili-postinpost widget.

The oldest function of xili-language – the_curlang() – is improved and now is able to return the desired property of current language. Useful for choosing condition of part display according language.
/**
* Return the current language of theme.
*
* @since 0.9.7
* @updated 2.11.0
* use by other function elsewhere
* @param slug, iso, full name, alias, charset, hidden, count
*
* @return by default the slug of language (used in query).
*/
function the_curlang( $by = 'slug' ) { // soon obsolete
return xili_curlang( $by );
}
function xili_curlang( $by = 'slug' ) {

More available preset languages in list:

Now using list provided by jetpack, an almost complete list of languages is available with english name, native name and more…
In the list, if the native name is followed by a *, the language is not associated with wp_locale (an official language managed by WP.)

xili-dictionary version 2.6 shipped

xili-dictionary extension is shipped (2.6) and include now plugin language file management.
With taxonomy “Origin”, msgid and msgstr are assigned to the target plugin and it is easy to import terms in dictionary and to create, update language files of the target plugin.

xili-dictionary analyse header of plugin’s sources and this two items ‘Text Domain’ and ‘Domain Path’. If author omits to define them, xili-dictionary try to specify them according language files yet available in plugin’s folder.

M.