_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 =====
There are several config options, all accessible through the config manager.
You can define a [[:namespace]] in which translation should be done (used here to enable the plugin in the ''wiki'' namespace only). This is optional, leaving it empty will enable the plugin for the whole wiki.
Similar to the above setting you can also set a regular expression to be matched against pagenames. When it matches, the translation switcher will not be displayed. This can be used to automatically keep out certain namespaces from the translation. The regexp is applied to the full pagename which starts with colon.
You need to setup the languages you want your pages be translated to. Separate each language with a comma or space. The default language will be added automatically, so do not add it here.
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 option accordingly.
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 configuration.
=== Manual configuration ===
If you don't use the [[plugin:config|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']['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']['about'] = 'wiki:translation:about'; // page describing the translation process to users
Skip your default language! So if your dokuwiki starts with english, set
$conf['plugin']['translation']['translations'] = 'fr,de,it'; // available languages
Otherwise the language menu will show 'en' twice.
===== 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 top of the page:
~~NOTRANS~~
===== Requests =====
==== Sidebar translation? ====
I´ve installed the plugin, it works, but only for the content (and the user interface - if selected) - not for the sidebar which is defined in sidebar.txt-file in the translation-namespace (en). \\
I´m using the arctic-Template with left sidebar configueres. If I set in the configuration the content of the sidebar to "main" and "namespace" this shows on translated pages both, the sidebar in the original language (German) (this comes from the "main"-sidebar) and the translated (english) which is the sidebar in the "en"-namespace. In the original language it´s only the German-sidebar ("main"-sidebar). I guess, I have to switch off the "main"-sidebar if a translated page is used.\\
How could I manage this?\\
Thanks - Bernhard Henselmann / 27.1.2008
>This is now fixed. The arctic template plays well with the translation plugin, there is a ''main_sidebar_allways'' setting you can turn off to do so. --- //Guy Brand 2008/08/01 20:56//
>This is a fix that i did on a site, its not for arctic but for the [[http://www.jandecaluwe.com/testwiki/doku.php/navigation:intro|Better Navigation]]
>Lets say you have english and german languages on your dokuwiki, and english is default, in this case all the pages in german would be in the namespace **de**.
>The default sidebar for english would be **sidebar**. And the default for german would be within **de** namespace like so **de:sidebar**
>hope you get some ideas from this, good luck
> You can define a specific sidebar for each page so there won't be any conflicts between the sidebar's namespace system and the translation namespaces . Here's how i do it :
>
>If you have a page called 'foo' you just have to edit the 'sidebar_foo' page.
> Hope this helps !
> Daamien / 29.8.2008
==== Flags ====
Could you add some national flags instead of the iso codes? At least for the most used languages. --- scy
> Please don't or at least combine the two. Flags for languages is a very European view of the world. We use a wiki in South Africa which has 11 official languages. Which flag should we use? --- dwayne
>> Oh, ok. I recommend both versions anyway. --- scy
{{http://nohair.com/code/_media/computers:translations1.gif }}
>>> I've created a flag based translation modification. Andy, if you want, please add this to the next release. [[http://nohair.com/code/doku.php?id=computers:dokuwiki_plugin-translations-flags | See Flags Demonstration]]
==== Dropdown menu ====
A dropdown menu would be much more easy to integrate in a template than a huge horizontal list of codes ! Most sites provide language selection through a dropdown menu. It would be great if we could have this option. --- manu
> In case of a drop-down menu you'll be unable to see to which languages the page has been already translated. ---wojtek
==== No translation zone ====
Some namespaces are probably not suitable for translation (e.g., users' wiki pages, the playground, or wiki pages for the localised translation, etc.). Could we have something similar to the exact opposite of "If you only want translations below a certain namespace, put it here."?
===== Discussion =====
===fallback language===
I seem to have found a way to get the content of a page to fallback to the default language if no translation is available. the rest of the page refers to the (non-existing) translated page, so the bottom of the page still says "create this page", and any sidebar / tabs / menuus will still refer to the 'current' language. But the content shows the untranslated version, without edit options.
In lib/plugins/translation/syntax.php, add
/**
* returns fallback html if the current page does not exists
**/
function _fallbackContent() {
global $ACT,$ID;
if ($ACT=="show" && $this->_currentLang()) {
resolve_pageid(getNS($ID),noNS($ID),$exists);
if (!$exists) {
//see if the default lang exists
$rx = '/^'.$this->tns.'(('.join('|',$this->trans).'):)?/';
$defid = preg_replace($rx,'',$ID);
resolve_pageid(getNS($defid),noNS($defid),$exists);
if ($exists) {
return p_wiki_xhtml($defid);
}
}
}
return "";
}
.. in your main template, where you would write
tpl_content();
now write
$transplug = &plugin_load('syntax','translation');
$fallback = $transplug->_fallbackContent();
if ($fallback) print $fallback;
else tpl_content();
I'm pretty sure that code can be improved. nevertheless, it seems to work sofar.
$2c,
*-pike
===hide the untranslated page links===
This patch will just disable the untranslated page links from the translation menu. It's useful for those who don't want search engine on the untranslated pages.
--- lib/plugins/translation/syntax.php.orig 2008-02-26 15:02:31.000000000 +0100
+++ lib/plugins/translation/syntax.php 2008-02-26 15:02:12.000000000 +0100
@@ -135,7 +135,8 @@
$out .= '';
$out .= ' - '.$this->_buildTransLink('',$idpart).'
';
foreach($this->trans as $t){
- $out .= ' - '.$this->_buildTransLink($t,$idpart).'
';
+ resolve_pageid(getNS($t.':'.$idpart),$page = noNS($idpart),$exists);
+ if ($exists) $out .= ' - '.$this->_buildTransLink($t,$idpart).'
';
}
$out .= '
';
$out .= '';
Hope this will help somebody!
--
[[http://www.zeitoun.net|Stéphane Gully]]
===Place Language at the End===
This patch will append the language to the end of the existing page instead of creating a new namespace
Old Style:
\\
translate:project
\\
translate:
--- lib/plugins/translation/syntax.php.orig 2007-07-15 04:27:36.000000000 -0400
+++ lib/plugins/translation/syntax.php 2008-07-30 15:10:53.000000000 -0400
@@ -97,7 +97,7 @@
global $conf;
global $saved_conf;
if($lng){
- $link = ':'.$this->tns.$lng.':'.$idpart;
+ $link = ':'.$this->tns.':'.$idpart.':'.$lng;
$name = $lng;
}else{
$link = ':'.$this->tns.$idpart;
@@ -123,8 +123,10 @@
$meta = p_get_metadata($ID);
if($meta['plugin']['translation']['notrans']) return;
- $rx = '/^'.$this->tns.'(('.join('|',$this->trans).'):)?/';
- $idpart = preg_replace($rx,'',$ID);
+ $rxns = '/^'.$this->tns.'/';
+ $idnons = preg_replace($rxns,'',$ID);
+ $rx = '/('.join('|',$this->trans).')$/';
+ $idpart = preg_replace($rx,'',$idnons);
$out = '';
$out .= ''.$this->getLang('translations');
This makes sense for separating translation projects into their own namespaces such as:
* translate:project1:language
* translate:project2:language
\\
Someone should find this useful!
--
[[http://www.digsby.com|Jeffrey Rogiers]]
=== Bullets in Firefox ===
I found that this line in lib/plugins/translation/style.css:
''list-style-type: none;'' needs to be changed to ''list-style: none;'' - otherwise Firefox will still display the bullets which will disturb the language link left of it. // Bernd
====== Right to Left (rtl) css ======
rtl.css does not seem to work with translation plugin. Also it would be better to load rtl.css as a separate file than as part of css.php. Andy, can this be done by the ?s=rtl get string? Or maybe loading rtl as a separate css is prefered behavior. Can someone help with this?
====== install problems and dokuwiki ======
i was unable to install the plugin via the plugin-manager so i just extracted the folder per hand into the plugins directory. Worked very fine.
To make the plugin work with the dokucms-theme i had to edit the file:
**/lib/tpl/dokucms/main.php** and add those lines:
_showTranslations();
?>
before this line:
-Thank you for this great plugin, i really love it. -[[http://spielend-programmieren.at|Horst]], 2008-07-17
- I have problems in showing the spanish flag: cannot get it, it's showing the mexican one instead. Same ws for the US/GB, but I renamed the two files (swapping the names) and solved it. Believe it or not, if I rename the MX.gif in MX.gif.bak and ES.gif in MX.gif, the preview in windows explorer changes to show again the mexican flag!! this wasn't happening with GB/US, I now have an icon called US.gif but containing the uk flag.. Omar 07/08/08