NetaliDev / dokuwiki-deepl-autotranslate

https://www.dokuwiki.org/plugin:deeplautotranslate
GNU General Public License v2.0
2 stars 2 forks source link

Picture links get changed by translation #10

Open Basti504 opened 1 year ago

Basti504 commented 1 year ago

Hi,

Thanks for this great plugin, I started to translate my wiki. But one thing is holding me back, all image links are changed, causing them to no longer be displayed untill I manually edit them.

In the origional page the image links is as follows: {{ ::applicatieoverzicht.png?nolink |}} After translation is becomes this: {{ applicatieoverzicht.png?nolink |}}. The :: in the link disappear, then they do not longer work.

Is there a way to prevent this from happening?

NetaliDev commented 1 year ago

The plugin normalizes all links and converts them into absolute paths so that the original images can be displayed on the translated page. This is done by using the builtin link functions in DokuWiki, but I've never seen the link-syntax you use before. Should this be a relative link to a image in the same namespace of the wiki page? Then the correct syntax would be {{ .:applicatieoverzicht.png?nolink |}} and this should be substituted with a absolute link after the translation.

The DokuWiki link syntax is explained here: https://www.dokuwiki.org/namespaces#creating_namespaces

Basti504 commented 1 year ago

Ok, I understand why the images do not load.

All images are in the root namespace, the translated pages should keep using the origional images. As I understand now the image does not load because {{ applicatieoverzicht.png?nolink |}} used in the en:test page is searching the image in the en namespace, while the image is not their. Good to know if in the future I want to provide translated images.

However, when I make a test page with the following syntax.

page name is: test (in root namespace) Hallo, dit is een test {{ .:actions1.png?nolink |}} {{ ::actions2.png?nolink |}} {{ actions3.png?nolink |}} {{ .:actions4.png?nolink |}} The actions3.png loads because the page is also in the root namespace, and therefore relatively correct.

The result I get for the translated page: en:test

Hello, this is a test {{ actions1.png?nolink |}} {{ actions2.png?nolink |}} {{ actions3.png?nolink |}} {{ actions4.png?nolink |}}

All images do not load anymore. It looks like the images are now made relative to the current en namespace, instead of the fixed root namespace :

NetaliDev commented 1 year ago

You can use {{ :actions1.png?nolink |}} to reference a image in the root-namespace and this should work.

Basti504 commented 1 year ago

Thanks.

Page test Hallo, dit is een test {{ :actions5.png?nolink |}}

Unfortunately that also gets converted to a relative image.

Page en:test Hello, this is a test {{ actions5.png?nolink |}}