This post follow the tests about multilingual themes published in May.
When studying FAQ of xili-language about some themes with localization (lots of theme’s creator forget to add in tags – localization or international, translation-ready,…), we discover that lot of improvements can be done during creation/design steps to easy transform them in a real multilingual theme.
With examples like with themes – INOVE or ARCLITE, FUSION or ATAHUALPA, we will illustrate here some features that must be considered.
As introduction :
localization and multilingual :
a theme is localizable if the language of the theme can be set by the webmaster according the language of the admin dashboard (in config.php). The .mo file of the language must be present inside the theme’s folder.
A multilingual theme change LIVE his texts when, depending some rules, the language of the post or the visitor’s browser change.
With few modifications, a well made localizable theme can be multilingual with help of xili-language plugin.
Chapter One
What we observe with the themes choosen as example :
ARCLITE, FUSION by digitalnature.ro
After our previous post, thanks to the author who includes the few lines of code inside the source… If xili-language is active, all the theme becomes live- multilingual.
End of august, we hope to provide more improvements to place languages selector (widget) with better design (as permitted by hooks inside xili-language plugins).
INOVE by www.neoease.com
The languages are in a sub-folder named « languages ».
Only one line in functions.php must be modified :
/** l10n */ function theme_init(){ load_theme_textdomain('inove', get_template_directory() . '/languages'); } |
to :
421 422 423 424 425 426 427 428 429 430 431 432 433 434 | /** l10n */ function theme_init(){ /* * xili-language PLEASE DO NOT DELETE * @since 090422 */ if (class_exists('xili_language')) { define('THEME_TEXTDOMAIN','inove'); define('THEME_LANGS_FOLDER','/languages'); } else { load_theme_textdomain('inove', get_template_directory() . '/languages'); } } |
But inside the theme, by instance in sidebar.php some texts remain coded as « hard » and don’t incorporate multilingual function __() or _e()… below « Categories » on line 121.
115 116 117 118 119 120 121 122 123 | <!-- sidebar east START --> <div id="eastsidebar" class="sidebar"> <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('east_sidebar') ) : ?> <!-- categories --> <div class="widget widget_categories"> <h3>Categories</h3> <ul> <?php wp_list_cats('sort_column=name&optioncount=0&depth=1'); ?> |
ATAHUALPA by BytesForAll
Here there is only the .pot file, you must create both .po and .mo files for expected languages. You must use PoEdit to complete the file by instance for french (fr_FR.po) or german (de_DE.po) and compile them in .mo (fr_FR.mo, de_DE.mo,…). The theme’s author leave these files inside folder and not in a sub-folder.
the present line of code inside functions.php :
// Load translation file load_theme_textdomain('atahualpa'); |
the lines modified :
3 4 5 6 7 8 9 10 | // Load translation file if (class_exists('xili_language')) { define('THEME_TEXTDOMAIN','atahualpa'); define('THEME_LANGS_FOLDER',''); } else { load_theme_textdomain('atahualpa'); } |
Chapter Two
Dynamic elements and live translations : Categories, tags, widget’s titles must be also dynamic translatable. You can check all these english terms and add it with poEdit but it is far easiest to use xili-dictionary to complete the .po (and .mo) files. See the posts inside this website and also read the review of Jacob here.
as a preliminary conclusion
the core and the hooks
Provided as a core to offer live selections of languages according rules (post or browser), xili-language plugin remains a way to implement rich and customized solutions for CMS or blogs – the hooks are here for that. xili-tidy-tags and xili-dictionary reinforce the toolbox.
webmaster or end-users
The first target of the plugin are webmasters with knowledges in WP (php and html). The future will be for end-users… with the help of theme’s designers.
next steps
After WP 2.8.2 release that introduces some powerful librairies, it will be possible soon to provide plug and play kit for non-developer people.
Michel July 22th
Ping : Integration of xili in Atahualpa « Forums of xiligroup.dev