xili-language plugin : release 1.2.0

September 17, 2009 - 09:13 - - This post in "français"
xili-language - [Update = January 21, 2010 - 08:31]
xili-language provides for a multilingual website an automatic selection of language (.mo) in theme according to the language of current post(s).

Description

Logo xili-languageLogo xili-language

xili-language plugin provides an automatic selection of language in theme according to the language of one post. xili-language use on the fly the .mo files present in the theme’s folder.

Themes with localization can be easily transformed in multilingual site.
It is dedicaced for theme’s creator or webmaster with knowledges in CMS and WP and having tools to create .mo language files. The plugin add automatic tools (or links or filters) for sidebar or top menus. Categories lists are translated also. xili-language provides also series of functions which can be hooked in the functions.php file of the theme that you create i.e. for a multilingual cms like website.
With xili-tidy-tags plugin [here], it is now possible to display sub-selection (cloud) of tags according language. With xili-dictionary plugin (beta), it is easier to create online via admin UI the files .mo of each languages.

New !

1.2.0

Full tests with lastest wp 2.9.1. New admin UI localization joined (RU – © see header of xili-language-ru_RU.po)

1.1.8, 1.1.9

Intermediate release
Optional improve hooking ways to be compatible with l10n cache of Johan’s plugin see line 2200. Automatic detection of theme_text_domain and languages (.mo) sub-folder in theme’s folder.
New Special Sidebar BoxMore infos in Settings UI Special sidebox.
Fixes title of wp_get_archives links with current permalinks. Possible that very special permalinks need to use hook named xiliml_get_archives_link.

This release adds new features dedicated to multilingual theme’s creators and webmasters. Some new php functions, a folder to include functions shared by themes (not necessary to put functions in functions.php of the current theme); example with a shortcode to insert link inside content toward another post in a language. A post explaining these improvements can be found in this post . Since 1.1.8, xili-language is also tested with future wordpress 2.9-rare.

1.1

improve function and theme tag «  xiliml_the_others_posts() »
(this template tag displays list of links of linked posts in other languages – by example in subtitle)

  1. to be used in multilingual category loop and
  2. by option (array) to return an array of linked posts in other languages (useful for CMS webmasters) (array of lang and id ) – the id is easily transformable in permalink with function get_permalink() when using this array.
    IMPORTANT : if this function was previously hooked for your theme, it works but you must review the hooking function of your functions.php to include new array option (see plugin code).
1.0

This version 1.0 to salute Wordpress 2.8. and some adds : new ways to choose language of home page through a popup in settings page. Ready to have more customized functions in a specific folder (and not only in functions.php of current theme). Reserved to theme’s designers…

0.9.9.6

Multiple Languages List WidgetMultiple Languages List Widget
xili-language list widget is now « multiple » ready. If the theme contains more than one sidebar, it is possible to adapt the list of languages for each sidebar. Designers of theme will be happy to find a way to change html tags of list.
More… a new item is added in widget : Type. This option offers a way to select type of languages list.
Enrichable through hooks and your function in functions.php, the available default option « typeone » deliver a list (without the selected language) and the link when in categories pages go a subselection in this language and this category.
See this post to enrich your list with flags or other behaviours depending which part of website is displayed (front-page, categories, search….)

Tested with wordpress 2.8-beta2-11509

A technical post

A new post about template tags here

0.9.9.5

php doc enhanced, link to modify linked posts in post edit UI
link to edit directly post in other languagelink to edit directly post in other language

compatible with old server in php4 !?
0.9.9.4
New widget for recent comments that can subselect those for current language. (a function `xiliml_recent_comments()` is also available if you want to create a template tag with resulting objects array). Sub selection of archives for `wp_get_archives()` with &lang= : see installation notes.

If frontpage is a page, select correlated page according language see Other notes.
0.9.9.3
sub selection of pages for `wp_list_pages()` with &lang=, some fixes (other posts, options when activate,…)
Example 1 :

wp_list_pages('title_li=&lang='.the_curlang() );

will display only pages of current lang
Example 2 :

wp_list_pages('title_li=&setlang=0&lang='.the_curlang() );

will display pages of current lang AND pages with lang undefined (polyglot pages).

and soon examples how to install selected rss as visible here in the left sidebar.

0.9.9.2

fixe class of metabox has-right-sidebar for 2.8 – some other admin UI sizing, W3C – improved template-tag default function `xiliml_the_other_posts()` display (if you had hook it in previous version, verify the hook of your functions.php, see php code lines 1314, 1650).

0.9.9

now provides infos about **text direction** *ltr* ou *rtl* of languages (arabic, hebraic,…) of theme and of each post in loop see note [direction in installation](http://wordpress.org/extend/plugins/xili-language/installation/). Soon more infos and demos for designers if multilingual theme. Some fixes (thanks to Jacob about QuickEdit UI bug when post update).

Installation

1. Upload the folder containing `xili-language.php` and language files to the `/wp-content/plugins/` directory,
2. Verify that your theme is international compatible – translatable terms like `_e(‘the term’,'mytheme’)` and no text hardcoded –
3. define domain name of your theme – see note at end list below,
4. Activate the plugin through the *’Plugins’* menu in WordPress,
5. Go to the dashboard settings tab – language – and adapt default values if necessary by adding your languages in the catalog. You can set the order (1,2,3…) of the series. (used in `language_attributes()` template_tag).
6. Modify each post by setting (checking) the language flag in xili-language sub-windows at the right of the editing window before publishing.

See this post about template tags here

SPECIAL NOTE FOR VERSION >= 1.1.9

With the cost of 50 lines more, plugin now detect automatically (if theme is good) the theme_text_domain and languages (.mo) sub-folder. It not mandatory to declare the two constats (but compatible with previous settings).
Only encapsule the `load_theme_textdomain()` like in that example for a theme named fusion:

if (!class_exists('xili_language')) { // class in not (!) present...
   load_theme_textdomain('fusion', get_template_directory() . '/lang');	
}
NOTE

In the functions php file of the theme : replace by commenting `load_theme_textdomain` line `//load_theme_textdomain(‘mythemename’); ` by a *define* `define(‘THEME_TEXTDOMAIN’,'mythemename’); //second text must be used in theme texts with _e( , ) or __( , )` where ‘mythemename’ is `’kubrik’` in default international theme.

Another example with fusion theme that offer localization :

replace

function init_language(){
	load_theme_textdomain('fusion', get_template_directory() . '/lang');
}

by

function init_language(){
	if (class_exists('xili_language')) {
		define('THEME_TEXTDOMAIN','fusion');
		define('THEME_LANGS_FOLDER','/lang');
	} else {
	   load_theme_textdomain('fusion', get_template_directory() . '/lang');	
	}
 
}

see the [recent post](http://dev.xiligroup.com/?p=427 « Transform a theme with localization »).

Browser detection
To change the language of the frontpage according to the language of the visitor’s browser, check the button in right small box in settings.

text direction, since 0.9.9

Examples *for theme’s designer* of functions to keep text **direction** of theme and of current post :

<?php 
	$themelangdir = ((class_exists('xili_language')) ? the_cur_lang_dir() : array ()) ; ?>
<div class="inside <?php echo $themelangdir['direction'] ?>">
...

example in loop :

<?php while (have_posts()) : the_post(); 
$langdir = ((class_exists('xili_language')) ? get_cur_post_lang_dir($post->ID) : array());
?>
      <div class="story <?php echo $langdir['direction'] ?>" >

minimal example in css :

.rtl {direction: rtl; text-align:right !important; font-size:130% !important;}
.ltr {direction: ltr; text-align:left !important;}

Caution : multilingual theme with both ltr and rtl texts needs a rigourous structure of the css !

Archives selection

Archives tags is a very complex template tag in his background and not very easy source hookable. So we decided to add few features : by adding query in vars of the function, it will be possible to display a monthly list of archives for a selected language

wp_get_archives('..your.vars..&lang=fr_fr')

or the current the theme language

wp_get_archives('..your.vars..&lang=')

The displayed list of links will be translated and link restrited to display only archives of this language.

Wordpress 2.8 beta

Today, xili-language is ‘compatible’ with ‘nightly’ of next WP release.

F. A. Q.

Are the default rules (functions) of xili-language plugin hookable ?

Yes, by theme’s developers. In plugin’s php script, all is documented and the hooks can be added in functions.php file of the theme. Here one example to create a languages list with flag as here in left sidebar.

Where can I see websites using this plugin ?

dev.xiligroup.com (« why xili-language ? »)
and
www.xiliphone.mobi (« a theme for mobile ») also usable with mobile as iPhone.

JacobandEric informs that these two websites are powered by xili-language :
http://terranovasite.com/blog/
http://altitude-blog.com/

Screenshots

1. an example of wp-content/themes folder of a theme with localization files (.mo)
an example of wp-content/themes folderan example of wp-content/themes folder
2. the admin settings UI
the admin settings UIthe admin settings UI
3. the language setting in post writting UI
the language setting in post writting UIthe language setting in post writting UI
4. coding extract with ‘international’ text in ‘xiliphone’ theme
coding extract with 'international' text in 'xiliphone' themecoding extract with 'international' text in 'xiliphone' theme
5. Admin Tools UI – pre-set default language of author according his browser’s language.
Admin Tools UI - pre-set default language of author according his browser's language.Admin Tools UI - pre-set default language of author according his browser's language.
6. xili-tidy-tags : Admin Tools UI – see this compatible plugin to group tags according languages
xili-tidy-tags : Admin Tools UI - see this compatible plugin to group tags according languagesxili-tidy-tags : Admin Tools UI - see this compatible plugin to group tags according languages
7. xili-dictionary : Admin Tools UI – list of translated terms
xili-dictionary : Admin Tools UI - list of translated termsxili-dictionary : Admin Tools UI - list of translated terms

Other Notes

What happens if frontpage is a page ?

Before publishing an ‘how-to‘, since 0.9.9.4, the plugin incorporates now features that are formerly possible through the hookable functions of xili-language. The page frontpage must have her clones in each other languages. As for posts, if the user’s browser is not in the default language, xili-language will display the page in the corresponding language if set by the editor. Be patient, a detailled post will arrive soon…

The first beta releases was for theme’s creator or designer.

See also the other posts about xili-language here.

and the [Wordpress plugins forum].

Download

The current version is available in the Wordpress Plugins Directory repository.

 
 
xili-language: posts series for experts
  1. xili-language plugin : release 1.2.0
  2. Q&A about xili-language plugin, release 1.1
  3. xili-language : hooks, filters, class and so on...
  4. From a theme with localization to a multilingual theme with xili-language : technical and general notes.
  5. xili-language - release 1.1.8 - new libraries
 
 
 
xili-language: posts series for authors
  1. xili-language plugin : release 1.2.0
  2. xili-language: a helpful shortcode
 
 
Tags: , , ,
14 Comments »
  1. Can you explain « automatic » selection of language ?

    Comment by Calitinilo — June 04, 2009 @ 19:31

  2. Instead some other multilingual site, with xili-language, all the post in different language are in the SAME wordpress database. No need to do two or more databases. After setting the plug-in, when you create a post, you have only to check the language of the created post. And when a visitor read this post, the theme (with basic rules) will be in the same language as the post language by automatically selecting the .mo file attached to the theme.
    M.

    Comment by admin — June 04, 2009 @ 19:37

  3. Hey guys I have a question for you… i’m trying to install wordpress through wordpress’ admin panel and I’m getting the following error:

    ‘Parse error: parse error in D:\wamp\www\wordpress\wp-content\plugins\xili-tidy-tags\xili-tidy-tags.php on line 1486′.

    Line 1486 is the last line of the file… nothing wrong there.. I looked the whole file and I can’t spot anything wrong with the code… here is what I’m using, PHP: 5.3.0.

    Any help appreciated ;)

    Comment by Giannis — July 17, 2009 @ 19:34

  4. Hello Giannis !

    I am not sure but

    Try to erase & in both instantiations at the end

    $xili_tidy_tags = new xili_tidy_tags (false, false);

    $xili_tidy_tags_cloud_widgets = new xili_tidy_tags_cloud_multiple_widgets ();

    Also :

    When the error is at the end…. it is often when a control flow (if { or }…. is not correct … is php 5.3 more rigourous !

    Thanks for your observations

    Comment by admin — July 17, 2009 @ 19:52

  5. Hi once again! I tried what you suggested but with no luck ;/

    I also rolled back to PHP 5.2.0 and got a « unexpected $end » as you said. the thing is that I scanned again the whole file, I used Aptana and xDebug and I cant find the parse error… I also did this:

    I erased the first class ‘xili_tidy_tags’ from the file and I managed to install the plugin correctly, so I suppose that the problem is somewhere in that class.

    Has anybody else faced the same kind of trouble?

    Thank you

    Comment by Giannis — July 18, 2009 @ 0:15

  6. You are the first who describe that pb with PHP 5.2 and 5.3 on his server… Here I test on PHP 5.2.6 (mamp local server) and xiligroup online server (php 5.2.10) and one client use it on PHP4 (it is why the instantiation used =& code)… read you email for other texts…

    Comment by admin — July 18, 2009 @ 10:06

  7. Hello, how to force on demand lang=en_us to deduce a theme en_us.php? And on demand
    ? lang=en_rus to use other theme.

    Comment by DEHuCKA — August 12, 2009 @ 15:09

  8. Our other plugin xilitheme select is able to select a theme according the browser of the device (here mobile). (http://dev.xiligroup.com/?cat=395&lang=en_us) – It will be note very difficult to do a language theme select but do you think it will be a good idea ?
    How many users ask this ?

    Michel of dev.xiligroup

    Comment by xiligroup dev — August 28, 2009 @ 10:43

  9. This message keeps popping up, and in firefox, it doesn’t even show the website:
    no theme domain in index.phpxili-language plugin : THEME_TEXTDOMAIN UNDEFINED

    Before I updated the plugin version, this didn’t happen.
    Help!!

    Comment by Ildikó — January 21, 2010 @ 2:28

  10. Thanks for your question. I visit your site and see that your use only page (and not post) to fill your bilingual site… To engage an efficient dialog, I will open a forum discussion here.
    Michel
    dev.xiligroup team

    Comment by xiligroup dev — January 21, 2010 @ 8:21

  11. Hi there

    few questions if you can direct me:
    1.how do i make the mo.files?
    2.what plugin you used in your website to make the tabs in the post?

    thanks

    Comment by yoav — January 31, 2010 @ 4:03

  12. 1) two ways to build .mo files from .po files : a) on desktop computer, poEdit app is good on all OS (I use it on MacOsX), b) on WP itself, install xili-dictionary plugin which is able to build .po file and .mo file.
    2) The Tabs : It is not yet a stand alone plugin – As you can see in js source, the tabs javascript is SimpleTabs from Harald Kirschner modified for mootools by Daniel Sturm and us.
    Hope that help you !
    M for dev.xiligroup.com

    Comment by xiligroup dev — January 31, 2010 @ 9:34

  13. thank you . i will start by testing the xili-dict’ plugin.

    Comment by yoav — January 31, 2010 @ 17:49

Citations :

  1. xiligroup dev » Extension xili-language : version 0.9.9.4

RSS feed for comments on this post. | TrackBack URI

Leave a comment