dokuwiki-plugin-translation icon indicating copy to clipboard operation
dokuwiki-plugin-translation copied to clipboard

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

Open gentakojima opened this issue 11 years ago • 2 comments

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)

gentakojima avatar Oct 01 '14 08:10 gentakojima

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

splitbrain avatar Feb 01 '23 20:02 splitbrain

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

studmed avatar May 23 '23 17:05 studmed