splitbrain / dokuwiki-plugin-translation

Easily setup a multi-language DokuWiki
http://www.dokuwiki.org/plugin:translation
23 stars 24 forks source link

Restrict translations to namespace with default language installation result in bad translation links #61

Open gentakojima opened 10 years ago

gentakojima commented 10 years ago

I'm restricting translations to the namespace "names". So, links look like this: :names:page :names:langcode1:names:page :names:langcode2:names:page

Then, when entering a translated page, the original language link look like this: :names:names:page :names:langcode1:names:page :names:langcode2:names:page

Notice that the original page link is wrong. Should be :names:page.

My proposal to fix this is to modify the function buildTransID, so the links always look like this:

:names:page :names:langcode1:page :names:langcode2:page

This changes the current behaviour, but also removes unneccessary bloat on the URLs.

To do this, just replace the two occurrences of $idpart in the buildTransID function to this: preg_replace("/^{$this->tns}/", "", $idpart)

splitbrain commented 1 year ago

You're right, this feature seems to be totally broken. I might decide to remove it completely to save me some headaches...

studmed commented 1 year ago

You're right, this feature seems to be totally broken. I might decide to remove it completely to save me some headaches...

I found that quite helpful, ig it would work properly. But to the fix from @gentakojima what to change exactely? I found the function in helper.php

public function buildTransID($lng, $idpart) { if ($lng && in_array($lng, $this->translations)) { $link = ':' . $this->translationNs . $lng . ':' . $idpart; $name = $lng; } else { $link = ':' . $this->translationNs . $idpart; $name = $this->realLC(''); } return array($link, $name); }

but as I don't have any idea of programming (anymore - I did some BASIC, qBASIC, VisualBasic - but PHP and everything else is foreign to me) I do not know what exactely to change/replace there.

Maybe you could also include that fix on the Plugin-Page https://www.dokuwiki.org/plugin:Translation