Improvement described below is based on discussion about browser language detection.
The idea is to change wikipage when current language of DokuWiki interface is switched.
Below you will find a project, where you have to patch your dokuwiki installation very complex and some discussion about how to make a very simple ML support. However, try this Multilanguage Support for local.php! You simply have to paste some lines of code to your conf/local.php to get it run!
NB: Multilingual pages and UI switching can be achieved using the translation plugin which works with DokuWiki 2007-06-26 and above.
The patch provides three levels of internationalization:
First level is presently used in DokuWiki.
The second level provides the possibility to switch language of interface by browser settings or by variable 'lang' in GET request.
On third level different translations of wikipages are stored in “standard” top-level namespaces like “ru”, “en”, “de” etc. Current language depends on the first namespace of wikipage.
If you are interested in this topic, you may get the the patch for DokuWiki 2005-09-22 for testing. On my site you may see third level in action.
— Alexey Remizov 2005-07-15 15:02
dw-multilingual.diff.gzcd /var/www/dokuwiki)zcat dw-multilingual.diff.gz | patch -p1Could your patch be tuned to work against darcs current? — Guy Brand 2006-01-07 23:17I've used it only with stable snapshots of dokuwiki. But from 2005-07-13 to 2005-09-22 was changed only the numbers of the corrected lines. I guess, current version can be easy patched manually if you'll find the corresponding lines. — Alexey Remizov 2006-02-21 17:19
And also to work in last stable version 2005-09-22? — Michel Bottin 2006-02-07 19:20Yes. I published a new patch today. — Alexey Remizov 2006-02-21 17:20
And also to work in last stable version 2006-03-09? — Peter 2006-03-28 13:39
Here is a simple way to assign language depending on the URL: in conf/dokuwiki.php:
replace:
$conf['lang'] = 'en'
with:
$conf['lang'] = preg_replace('/^id=(..):.*/i','$1',$_SERVER['QUERY_STRING']);
$conf['lang'] = (strlen($conf['lang'])<>2?'en':$conf['lang']);
This will set the language variable depending on the URL:
wiki.example.com/id=en:test (english)
wiki.example.com/id=fr:test (french)
According do the docs, its better to put this proposed patch in conf/local.php.
Besides, it doesn't work for Index or Login. An improved version is given below:
$conf['lang']=preg_replace('/^(..):.*/i','$1',$_REQUEST['id']);
if (strlen($conf['lang'])<>2){
$conf['lang']=preg_replace('/^(..):.*/i','$1',$_REQUEST['ns']);
$conf['lang'] = (strlen($conf['lang'])<>2?'en':$conf['lang']);
}
It switches the interface language if there is xx namespace referenced, where xx is a two letter language code.
Default language is set to English (en).
There is a drawback: the language selection drop down menu shows really ugly in the configuration dialogs. Actually the patch breaks the configuration module - don't try to use it unless you want to end up with broken conf/local.php.
— Igor Wojnicki 2006-06-09 12:54
Actually, this way of creating multilanguage wikis is cool, but does not work in all cases, such as than $conf['useslash'] = 1. Try this replasment:
$conf['useslash'] = 1;
$conf['default_lang'] = 'en';
if ($conf['useslash']) {
$conf['lang']=preg_replace('/^(..)\/.*/i','$1',$_REQUEST['id']);
if (strlen($conf['lang'])<>2) {
$conf['lang']=preg_replace('/^(..)\/.*/i','$1',$_REQUEST['ns']);
$conf['lang'] = (strlen($conf['lang'])<>2?$conf['default_lang']:$conf['lang']);
}
} else {
$conf['lang']=preg_replace('/^(..):.*/i','$1',$_REQUEST['id']);
if (strlen($conf['lang'])<>2) {
$conf['lang']=preg_replace('/^(..):.*/i','$1',$_REQUEST['ns']);
$conf['lang'] = (strlen($conf['lang'])<>2?$conf['default_lang']:$conf['lang']);
}
}
— /lekcyc lllumukcyc 2006-06-14 14:20
Hi,Excuse for my English. I am new using dokuwiki and I am attempting through bottoms to change the language of the interface of the dokuwiki from anyone of the pages, so that the users can change the language that they want. I don't know how make it, I have read the option that you offer, but I need that the user to change it. Can you give me some idea? Thank you. Daniel Diez
The $conf['useslash'] = 1 problem could be solved with regular expressions as well! Take a look at the [:\/] section. No need to write nearly the same code twice.
$conf['lang']=preg_replace('/^(..)[:\/].*/i','$1',$_REQUEST['id']);
if (strlen($conf['lang'])<>2){
$conf['lang']=preg_replace('/^(..)[:\/].*/i','$1',$_REQUEST['ns']);
$conf['lang'] = (strlen($conf['lang'])<>2?'en':$conf['lang']);
}
However, this solution still lacks the configuration dialogs. Johannes Vockeroth
I enabled rewriting by dokuwiki, so my path looks like http://www.example.com/doc/doku.php/en:bugtracker.
Hence, $_REQUEST['id'] does not exist. Does anyone know a mean to workaround that ? Is there any other variable that contains id and ns ?
— 2007-07-05 M. Michel
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported