digitalfabrik/integreat-cms

Update internal links when translating (with XLIFF & DeepL)

Closed this issue · 15 comments

If a page contains an internal link, the link target will not change during the translation process. As a result, users of other languages than the source language end up in the source language page. It should be our goal that users see the translated page. There might be some exceptions, where authors intentionally want users to end up in one page that is valid for all languages (we could argue that in these cases the live content function could be used). As we now have the fallback translations, we always want to link to the current language.

During XLIFF import, all internal links should be checked if they refer to another language. If yes, the link should be redirected to the current language of the translation. The importer function could scan for all internal links, look for the translated page, and substitute the link target.

a-tags that link to internal pages can get additional attributes to make the process more efficient, for example:

<a href="https://integreat.app/testumgegbung/en/welcome" internal="true" pageid="5">

We can then use an xpath expression to scan all pages for elements that are internal links:

//a/[@internal='true']

The fix_internal_links command should probably be extended to add the required attributes for all links that are pointing to internal pages.

This could be related to #1382

I think it makes sense to fix this issue together with #1382 and #1383 . Other opinions?

Yes, although I would differ between the generic search/replace and link search/replace, because the latter can be done with the lxml function rewrite_links(), see e.g.:

translation.content = rewrite_links(
translation.content,
partial(self.replace_link, old_url.url, new_url),
)

Probably we can generalize the solution for the link replacement of the broken link checker and use it for this issue and #1383.

We had a discussion in the Service Team, that it would be necessary to have this for the Maps feature as well.

We got some more requests regarding that feature...guess we need to reschedule it because Q3/2022 is not realistic

Any news on this feature and its possible implementation?

Any news on this feature and its possible implementation?

No, sadly nobody wanted to tackle this complex issue yet. I increased the prio of the ticket to increase the incentive a bit.

The scope changed. We want to update all links during XLIFF import. That should make things easier.

HIX and DeepL features are more important.

osmers commented

Is this an issue we could tackle in Q3 possibly? Since HIX and DeepL are done now :)

osmers commented

Oh and just wondering - if we now translate within the system, there is no need to upload xliffs anymore and thus no way to change internal links during upload. Any ideas how we can solve this?

osmers commented

@timoludwig @svenseeberg we got another question regarding this feature - is there any chance that this can be done in Q3 bcs many municipalities really want to have the links point to the correct language?
Sorry for nagging :)

@osmers I can only speak for myself that I probably won't have time to fix this issue in the near future.

osmers commented

How about somebody else? @svenseeberg @JoeyStk

I also don't see myself tackling this issue in the near future - due to both lack of time and lack of experience in this field :/