Translation Plugin

translation plugin by Andreas Gohr
Help with translation efforts in a multilingual wiki

Last updated on 2009-10-25. Provides Syntax, Action.
Compatible with DokuWiki 2009-12-25+.

Conflicts with multilingual!
Similar to flex, multilingual, nsrelation, translation2.

Tagged with language.

This plugin shows a list of available translations for a page. It is very simple and was built with the needs of www.dokuwiki.org in mind and is used for documentation translation efforts here. There are a few limitations:

  • separate namespaces are used to store translations
  • translated pages need to have the same pagename as the main language page

Download

Use the download link given above to download the file manually or through the plugin manager.

Changes

Installation

  1. Download and install the plugin through the Plugin Manager.
  2. Configure it through the Config Manager
  3. Add the following code in your template's main.php (or put it in a lib/tpl/default/pageheader.html file for the default template)
<?php
$translation = &plugin_load('helper','translation');
echo $translation->showTranslations();
?>

Note: add this piece of code not at the top or the bottom of main.php but instead in-between where it makes the best optical impression. You need to experiment a bit to find the best spot.

If you have several themes or skins installed you need to add this piece of code into each main.php to allow the translation-plugin for every skin.

Configuration

First, there are two ways how to set up a multilingual wiki:

  1. a default language in the root namespace and translations in sub namespaces
  2. no pages in the top namespace and all languages in sub namespaces

Here at dokuwiki.org the first method is used. Certain features OTOH will only work with second method.

There are several config options, all accessible through the config manager.

The most important thing to configure is a list of languages you want to use in the translations setting. It is good practice to use ISO language codes for this. Your translation namespaces will be named like the options you set here. Separate each language with a comma or space. Depending on the type of setup you want to use add your default language (the one configured in lang) here or omit it.

  1. for the default language in the top namespace, omit it from the config
  2. for namespaces for all languages add it here as well

By default a list of translation links is shown. This can take quite a bit space when you have many translations. Enabling the dropdown option should help here.

If you want to restrict translations to a certain namespace you can define it in the translationns option. This is optional, leaving it empty will enable the plugin for the whole wiki.

Similar to the above setting you can also disable translations for certain pages or namespaces using the skiptrans setting. It expects a regular expression to be matched against pagenames. When it matches, the translation switcher will not be displayed. The regexp is applied to the full pagename which starts with colon.

You can optionally choose to let the plugin translate the whole user interface of DokuWiki too when a non-default language page is selected. Just enable the translateui option accordingly.

If you decided to go with a type 2 setup, then your root namespace is pretty useless. Enabling the redirectstart setting will redirect users to the start of a translation namespace based on their browser language. This option only works when the above translatui setting is enabled, too.

When you have a default language that gets translated to other languages, it might be helpful to warn visitors on outdated translations. Enabling the checkage option will do that by comparing the age of the translation page with the one of the original (default language) page. It also tries to find the last revision of the original page that was edited before the translation and links to a diff view.

Finally you might want to explain how the translations work on your wiki to your users. To make this description easily accessible from the language selector, enter the pagename of your description in the about configuration setting.

Manual configuration

If you don't use the Config Manager and prefer configuring your wiki editing the config file, the useful lines which have to be added to your local.php configuration file are:

$conf['plugin']['translation']['translations']  = 'en,fr,de,it';                        // available languages
$conf['plugin']['translation']['dropdown']      = 1;                                    // use a dropdown
$conf['plugin']['translation']['translationns'] = 'wiki';                               // namespace where to activate translation
$conf['plugin']['translation']['skiptrans']     = '^:(plugin|template):';               // what to skip (regexp)
$conf['plugin']['translation']['translateui']   = 1;                                    // translate the wiki user interface too
$conf['plugin']['translation']['checkage']      = 1;                                    // show notice on outdated translations
$conf['plugin']['translation']['about']         = 'translation:about';                  // page describing the translation process to users

Usage

The plugin does its work automatically by being called from the template (see installation), but you can disable it for a certain page by adding the following code to the page:

~~NOTRANS~~

Place language list on the same line

(tip provided by lazyfrosch)

If your wiki doesn't have a huge amount of translations, you might want to save vertical space by placing introductory text on the same line. To do that, add this to style.css in the plugin directory :

.dokuwiki div.plugin_translation span { float: left; }

Hide the label in front of the selector:

.dokuwiki div.plugin_translation span { display:none; }

You might need to change the width of div.plugin_translation if there are many languages.

 
plugin/translation.txt · Last modified: 2010/06/09 11:22 by 80.171.53.135
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0 Unported
Imprint Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki
WikiForumIRCBugsGitXRefTranslate