If path alias is generated automatically from a given pattern we don't want to translate url alias and the url alias should not end up in the exported translation file.

Comments

Erik.Johansson created an issue. See original summary.

erik.johansson’s picture

StatusFileSize
new1.04 KB

Super simple patch for my use case.

loparev’s picture

Hi, @Erik.Johansson.

I've noticed this as well. But I think alias can be excluded from translation in another way: uncheck "URL alias" checkbox under needed content type at /admin/config/regional/content-language page and it should be excluded from generated file. Do you have any issues with this approach?

erik.johansson’s picture

Hi @Loparev
In some special scenarios we want to translate the url alias so disabling translation for url alias wont work for us.
What we need is to simply disable the url alias from ending up in the exported file, something like was implemented for fields in this issue: https://www.drupal.org/project/tmgmt/issues/1543480

loparev’s picture

Got it.

Maybe this hook can help?

berdir’s picture

Status: Active » Needs work

I agree we need to handle this better.

I also closed another issue as duplicate.

This should be done by registering a custom field processor class for the path field in #2951520: Improve path field integration, hide language, hide path if generated.

I would recommend we check if it's a PathAutoItem class and that ->pathauto is TRUE and only then skip it. Then a manual alias could still be translated. In both ways, we should skip the langcode field, which is currently also added to the translation job.

berdir’s picture

Status: Needs work » Needs review
StatusFileSize
new20.67 KB

A bit too much test refactoring but this adds a path field processor that always hides the langcode and if pathauto is enabled and an alias is generated, does not expose that for translation either. And extensive test coverage.

berdir’s picture

Also opened #2972587: Improve handling of link fields for links fields.

Status: Needs review » Needs work

The last submitted patch, 7: tmgmt-path-2951520-7.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

berdir’s picture

Status: Needs work » Needs review
StatusFileSize
new20.68 KB
new551 bytes

Made the new base class abstract.

  • Berdir committed ba8f06a on 8.x-1.x
    Issue #2951520 by Berdir, Erik.Johansson: Don't extract translatable...
berdir’s picture

Title: Don't extract translatable data for path alias » Improve path field integration, hide language, hide path if generated
Status: Needs review » Fixed

Committed. There are still possible improvements, we could add a setting if you never want to have the path in the translatable data, I'd suggest creating a new issue for that.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.