DokuWiki

It's better when it's simple

User Tools

Site Tools


plugin:multilingual

This is an old revision of the document!


Multilingual Plugin

Compatible with DokuWiki

2008-05-05 2011-11-10

plugin Collects mechanisms that converts DokuWiki into a multilingual wiki.

Last updated on
2012-01-29
Provides
Syntax, Action
Repository
Source
Conflicts with
translation

This extension has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues.

Similar to translation, translation3

Tagged with language

This plugin tries to collect and improve on a few multilingual plugins and tips that are floating around and collate them into a single plugin that provides a consistent interface for multilingual capabilities.

Requests/Issues

You can either use the forum above, or add below for any discussion about problems/requests you might have.

Use browser language for the UI

I couldn't get the Use browser language for the UI to work, so I figured out the line below is wrong. The brackets and the dot are not escaped.

	$languages = split(',', preg_replace('/(;q=\d+.\d+)/i', '', getenv('HTTP_ACCEPT_LANGUAGE')));

I changed it to the one below and it works.

        $languages = split(',', preg_replace('/\(;q=\d+\.\d+\)/i', '', getenv('HTTP_ACCEPT_LANGUAGE')));

Viktor Söderqvist, 2009-08-14 23:34

What browser and php version were you using? Neither escaping should strictly be necessary, but have added it to the plugin as it doesn't seem to cause any problems for me.

Daniel Stonier, 2009-10-08 23:24

Why escape the brackets?

Actually it was like that for no better reason than I didn't write that part - it inherited from the translation plugin or whatever I was building from (can't recall for sure). I might review it later when I get a chance.

The HTTP_ACCEPT_LANGUAGE variable cannot have literal brackets there. And not used for back referencing either, so the brackets should go away. Current distributed code escapes them, which will not strip away the priority values. Also the value can be usually in the form of 'en-us' with country code attached and if that doesn't hit, it should look for 'en' or most time, it will miss. And I think that the interface language should inherit the page chosen language instead of the browser language. Here's the little modification to fix them.

   $languages = split(',', preg_replace(array('/;q=\d+\.\d+/i', '/-[a-z]+/i'), '', getenv('HTTP_ACCEPT_LANGUAGE')));
   array_unshift($languages, preg_replace('/^([\w\-]+):.+$/', '\1', $ID));
Actually, I think choosing the browser for the user interface is better. Most users' will always be more comfortable with their native interface. For instance, I'm rapidly becoming multilingual (english+korean), so I will often read the korean pages, but am much more comfortable having an english interface still. My colleagues at work are the opposite.
Daniel Stonier, 2009-12-26 5:24
Say, you are not on your usual computer and the language settings differ from your preferred one, you go pick the language you want on the interface, the contents are changed but the interface staying same looks odd. Average use of this is to make it feel as native as it can. I do not see much chance having multilingual users asking for multiple languages of the page with a single language interface but single language speakers asking for their native languages.
h1d, 2009-12-28
Root Page Redirection

Also, I figured I wanted the user to be redirected to a language page instead of page not found when visiting the top site without explicitly specifying the language namespace. (ex : http://my.org/wiki/doku.php) The following code (should go before 'return true' in 'multilingual_ui') will look for browser preference language first and then list of enabled languages in this plugin and check if any of the language page exists and if it does, redirects there. This only redirects the top page, since it's hard to determine if the initial part of the namespace of other pages refers to a language or not. (Maybe unless it goes through the list of ISO codes.) But then again, other pages should be linked with language preference prepended. (This does not honor the RFC for 'Location' header by not being an absolute URL, but browsers do handle these anyway…)

  if($ID == $conf['start'])
   {
      array_unshift($enabled_languages, $conf['lang']);
 
      foreach(array_unique($enabled_languages) as $language)
      {
         if(file_exists("{$conf['savedir']}/pages/$language/$ID.txt"))
         {
            header("Location: {$_SERVER['PHP_SELF']}?id=$language:$ID");
            exit;
         }
      }
   }

Anyone using 'sidebar' template can create the sidebar page at 'en:sidebar' and the likes to have separate languages displayed for sidebars. Using 'indexmenu' inside the sidebar will also automatically limit the pages shown for that particular language as well.

h1d, 2009-11-21


Hi there,

Is there anyway to make the buttons of the topbar change when i switch to another language? It would be interesting if dokuwiki's title changed as well. Has anyone got any ideas?

Thanks,

Alex

OK, already done!

Thanks!
plugin/multilingual.1327838294.txt.gz · Last modified: 2012-01-29 12:58 by 175.193.46.152

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki