Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Let's assume you have a node in English (nid = 10) and a translation of that node in French (nid = 11) using the i18n module.
I tried the Internal Links filter expecting a link to node/10 on a French language page to be translated to node/11. This wasn't the actual behavior, so I'm writing a patch that will look for a translation of the node link for the current language if it's available. I'll post the patch later today.
Comment | File | Size | Author |
---|---|---|---|
#4 | translate_links-1924770-4.patch | 1.88 KB | chromix |
#3 | translate_links-1924770-3.patch | 983 bytes | chromix |
#2 | translate_links-1924770-2.patch | 1.04 KB | chromix |
#1 | translate_links-1924770-1.patch | 983 bytes | chromix |
Comments
Comment #1
chromix CreditAttribution: chromix commentedHere's the patch. It uses i18n_get_path_translations() to get the node/# link and title in the current language if it's available. Otherwise, the module works exactly as it did before. It might be that this behavior isn't actually what people want, necessarily, in which case maybe this can be configurable? I'm open to suggestions.
Comment #2
chromix CreditAttribution: chromix commentedFound a bug when langcode is set to und. This uses the global language as the langcode which seems to fix the problem overall.
Comment #3
chromix CreditAttribution: chromix commentedUpdate for this patch to use the passed-in langcode, rather than the global one.
Comment #4
chromix CreditAttribution: chromix commentedFound another bug where langcode is set to und.
Comment #4.0
chromix CreditAttribution: chromix commentedreworded a sentence in the description
Comment #5
FiNeX CreditAttribution: FiNeX commentedOk, the patch works fine, but only if the "bad links" filter is not active.