darktable-org / dtdocs

darktable user manual
GNU General Public License v3.0
74 stars 74 forks source link

Links to images do not work #249

Closed lebmich closed 3 years ago

lebmich commented 3 years ago

In the French translation no link to the images works. For example, I get: 2021_04_02_weblate_03

paperdigits commented 3 years ago

Did you translate the image path or image file name? That'll cause it not to work.

On April 2, 2021 9:44:51 AM PDT, Michel Leblond @.***> wrote:

In the French translation no link to the images works. For example, I get: 2021_04_02_weblate_03

-- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/darktable-org/dtdocs/issues/249

lebmich commented 3 years ago

I translated nothings at all. The link to the image in my browser is: 2021_04_03_weblate_04

paperdigits commented 3 years ago

@elstoc I've been looking at this problem for a while, and I don't see the solution. Hopefully I'm missing something obvious.

Because of the decision we made about storing images in a folder with the same name as the file, we use {{ .Page.RelPermalink }}j + the image file name to construct the image URL for English text. But when we translate the page, {{ .Page.RelPermalink }} includes the translated locale, e.g. fr-fr, in the URL.

I guess the proper solution would be to check if there is a translated image, and if no, then fall back to the English URL.

Any ideas?

elstoc commented 3 years ago

Haven't we decided already that it's not possible to translate the images? If so, surely the render-image partial can check if the page is non-English using .Page.Language and then if not, loop through .Page.Translations until it finds the English version (with .Lang), then use the .RelPermaLink to build the link using that page instead.

paperdigits commented 3 years ago

Haven't we decided already that it's not possible to translate the images?

Yes, I believe so.

This is a good thread: https://discourse.gohugo.io/t/how-to-get-a-specific-translation/32433/5

I've tried a few of those, but it doesn't work. The most promising seems to be {{ $p := index (where .Page.AllTranslations "Language.Lang" "en-US") 0 }} with {{ $p.RelPermalink }} but that doesn't work.

elstoc commented 3 years ago

I'm pretty sure I've fixed this on the website. We'll probably have to do something else for the pdf/epub so we should leave the issue open.

See the following German and English examples.

lebmich commented 3 years ago

A quick test shows that it seems to work. I will do more in-depth testing this evening. Thank you so much.

paperdigits commented 3 years ago

Please reopen this issue if there is a problem, but it looks fixed to me.