Problem/Motivation

In images, we can configure that only title and alt texts are translated, and not the original file.
I think it will make sense in some cases to do the same for links, where you may want to allow to translate the title but not the url.

Proposed resolution

Add columns to modules/link/src/Plugin/Field/FieldType/LinkItem.php definition.

Add a UI mark depending on #3152587: Add a mark when editing a field property will affect all the translations as we do with fields themselves outcome.

Remaining tasks

  • Ensure this is an acceptable feature request.
  • Have a working patch
  • Add tests
  • Right now, the (*all translation) markers doesn't work for subfields, so it's not obvious that this will affect all translations (see #3152587: Add a mark when editing a field property will affect all the translations as we do with fields themselves). We need to figure out a way to do that before this lands, as the UI would remain the same but you won't know you are updating all the translations.
  • Decide on the defaults: should be translatable or not by default?
  • Add an upgrade path: for existing sites, the url should be always translatable on upgrade, for avoiding to change the expected behavior on sites upgrading.
  • Add upgrade path tests.

User interface changes

TBD

API changes

TBD

Data model changes

TBD

Release notes snippet

TBD

Issue fork drupal-3152582

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

penyaskito created an issue. See original summary.

penyaskito’s picture

Title: Permit to translate only the title on links, not the url itself » Allow to configure translation per property on link fields (for translating only the title, not the url itself)
Issue summary: View changes
Related issues: +#3152587: Add a mark when editing a field property will affect all the translations as we do with fields themselves

Added related task and retitled.

penyaskito’s picture

Status: Active » Needs review
StatusFileSize
new918 bytes

Changes in the LinkItem are quite straightforward, the biggest task here is the UI issue related to #3152587: Add a mark when editing a field property will affect all the translations as we do with fields themselves

penyaskito’s picture

StatusFileSize
new88.68 KB
new2.11 KB

If that issue went in, for links it should be as the patch attached.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

penyaskito’s picture

Issue summary: View changes

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

technotim2010’s picture

What is the current status of this issue and this patch?

Considering it's use on a heavily multilingual website and would like to know if there are any known issues, blockers or other reasons progress appears to have stalled. Has it for example been overtaken by other core developments?

Thanks as always for all you do for the Community and Drupal.

Regards

Tim

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

Status: Needs review » Postponed (maintainer needs more info)
Issue tags: +Needs tests, +Needs Review Queue Initiative, +Needs subsystem maintainer review

This issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request as a guide.

Think it's a valid request to be able to translate links but isn't that already possible?

During content translation you can change the title text to the language you are translating too.

If the desire is to use for user interface translation not sure that's the correct way but tagging for subsystem maintainer for their thoughts. Would also leverage the #contribute slack channel.

penyaskito’s picture

@smustgrave Right now, you can translate all or nothing. The issue is about adding that granularity. You might want to let translators translate the link title, but not the url destination itself. As we do with images.

penyaskito’s picture

Issue summary: View changes
StatusFileSize
new6.15 KB

Adding screenshot so it's more clear.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

Status: Postponed (maintainer needs more info) » Needs work
Issue tags: -Needs subsystem maintainer review

We did something very similar for image fields lately so don't see why links could be any different.

DuaelFr made their first commit to this issue’s fork.

duaelfr’s picture

I rerolled @penyaskito's #4 patch on 11.x in a new MR

duaelfr’s picture

Status: Needs work » Needs review

Rerolled on the latest 11.x
+ added the ability to configure link options translatability (might be used by contrib like Link Target)

smustgrave’s picture

Status: Needs review » Needs work

Thanks for reviving, Moving to NW for test coverage.

ipitbiz’s picture

Hi all,

I add a patch for version 10.3 and 11 because the one that is visible now only works for 10.2.

dahousecat’s picture

The last patch fails on 10.2.7 as LinkItem now provides it's config via annotation.

lobodakyrylo’s picture

Patch #23 doesn't work for the 10.4 version.

dcam’s picture

Title: Allow to configure translation per property on link fields (for translating only the title, not the url itself) » [PP-1] Allow translation of individual Link subfields
Status: Needs work » Postponed

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.

duaelfr’s picture

MR rerolled
Patch attached for composer