RSS

The best Multilanguage Plugin For WordPress

Sat, Jul 19, 2008

Plugin

Installation

  1. Download qTranslate plugin

http://wordpress.org/extend/plugins/qtranslate/

Or

http://www.qianqin.de/qtranslate/download/

  1. Extract all the files.
  2. Upload everything (keeping the directory structure) to the /wp-content/plugins/ directory.
  3. There should be a /wp-content/plugins/qtranslate directory now with qtranslate.php in it.
  4. Activate the plugin through the ‘Plugins’ menu in WordPress.

Usage

  1. To enable the system build-in gettext translations, you must download your language files (.mo files).

http://svn.automattic.com/wordpress-i18n/

If in yourSiteName/wp-content/ directory, there is not a folder named languages (usually a localized version of WordPress has this folder, but original version doesn’t), then you should create one, and copy all the language files you download at above mentioned site into this folder.

PS. What is build-in gettext translation? Once you have installed a localized version of WordPress, you will get almost the whole interface which is translated. That’s what gettext did. As you did all the things I told above, you will get your interface such like the title of widget (like “categories”, ”meta”…or something like that) to be translated immediately.

  1. To add your new languages to qTranslate

DashboardàpluginàqTranslate Configuration

For example

Japanese

language codeja

language localeja

After you complete your setting, just enable your new ones in qTranslate.

  1. Add the qTranslate Widget to let your visitors switch the language. DashboardàDesignàWidgetàAdd qTranslate to your sidebar
  2. To translate things in the template, you have to use Language tag

<?php _e(“[English tag]english text[/English tag][ Chinese tag]中文文本[/Chinese tag][Japanese tag]日本語テキスト[/Japanese tag]”); ?>

English tag=lang_en

Chinese tag=lang_zh

Japanese tag=lang_ja

  1. Let qTranslate work in the dashboard

Insert <?php echo qtrans_generateLanguageSelectCode(’both’); ?> to yourSiteName/wp-admin/index.php you will get language switcher to appear in your dashboard. But, it will disappear whenever you go to somewhere else in the dashboard, like manage or somewhere else. The solution is to add the code above to each script in wp-admin directory. For example, edit.php for manage pages.

  1. Let qTranslate work with XML Sitemap Generator for WordPress 3.1.0.1

Search some code like below in sitemap-core.php

//Add it $this->AddUrl($permalink,$this->GetTimestampFromMySql(($post->post_modified_gmt && $post->post_modified_gmt!=’0000-00-00 00:00:00′?$post->post_modified_gmt:$post->post_date_gmt)),($isPage?$cf_pages:$cf_posts),$prio);

Insert following code before the that code

if(function_exists(’qtrans_convertURL’)) {

global $q_config;

foreach($q_config['enabled_languages'] as $language) {

if($language!=$q_config['default_language'])

$this->AddUrl(qtrans_convertURL($permalink,$language), $this->GetTimestampFromMySql(($post->post_modified_gmt && $post->post_modified_gmt!=’0000-00-00 00:00:00′?$post->post_modified_gmt:$post->post_date_gmt)),($isPage?$cf_pages:$cf_posts),$prio);

}

}

  1. To use qTranslate outside of widget

Just insert following code into anywhere you want.

<?php echo qtrans_generateLanguageSelectCode(’both’); ?>

  1. Pretty language switcher CSS

Because the original code produced by script is like

<ul class=”qtrans_language_chooser”>

<li class=”active”><a href=”/qtranslate/faq/” class=”qtrans_flag qtrans_flag_en”><span>English</span></a></li>

<li class=”active”><a href=”/de/qtranslate/faq/” class=”qtrans_flag qtrans_flag_de”><span>Deutsch</span></a></li>

</ul>

So, you can add some CSS to change the appearance of language switcher, for example:

To remove bullet points:

.qtrans_language_chooser { list-style-type:none }

To get a Horizontal List can be made by adding this CSS line:

.qtrans_language_chooser li { float:left; margin-right:3px }

  1. Let qTranslate work with DD Sitemap

STEP1. open sitemap-generator.php under right the Dragon Design Sitemap Generator directory.

STEP2. find this line about 2531 in my edition(version 3.14)

$content = str_replace(’<!– ddsitemapgen –>’, ddsg_create_sitemap(), $content);

STEP3. change this line as following

$content = str_replace(’<!– ddsitemapgen –>’, _e(ddsg_create_sitemap()), $content);

Related Posts

Tags: , , ,
Trackback URL:

This post was written by:

cXY - who has written 23 posts on cXY Lab.


Contact the author

Leave a Reply