Closed (fixed)
Project:
Pathauto
Version:
8.x-1.x-dev
Component:
I18n stuff
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
14 Nov 2016 at 13:26 UTC
Updated:
26 Feb 2026 at 22:49 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
vtkachenko commentedThis patch makes field "pattern" translatable.
Comment #3
berdirThanks, but this isn't enough yet.
See #2630382: "Strings to remove" option missing translation support, we need to ensure to match the config language with the entity language, as for example bulk generation can generate aliases for different languages in the same request/language.
Comment #4
berdirThe way this is supposed to work now is to have language conditions, so you don't create translations, you create separate patterns for each language. I'm not sure about allowing translation too, that could get very complicated and confusing.
Comment #5
damienmckennaComment #6
b-prod commented@Berdir I understand your point, however you should take this into account: having a multilingual site with 20 languages, and 30 vocabularies, leads to 600 pattern rules...
With pattern translations, you only have 1 rule per pattern, so 30 patterns for the vocabularies.
Moreover, each rule requires a unique ID, which also lead to headaches when it comes to organize this.
And last point, the patterns page with 600 rules is not a thing that can be managed when looking for updating a specific rule...
What would be your suggestions for such a case?
Comment #7
tomas.teicher commented@B-Prod: "...having a multilingual site with 20 languages, and 30 vocabularies, leads to 600 pattern rules...."
Not necessarilly, one pattern can be applied to multiple languages. There is "Languages" field in pattern edit form. The problem, you described, occurs in specific situation, when pattern contains some static string (not just tokens).
Comment #8
mably commentedComment #10
mably commentedComment #11
mably commentedMake PathautoPattern
$patternproperty translatableOn multilingual Drupal sites, the URL alias pattern (e.g.
/content/[node:title])could not differ per language because the
patternproperty was defined astype: stringin the config schema, which is not translatable.Solution
config/schema/pathauto_pattern.schema.yml)Changed
patterntype fromstringtolabel,making it translatable via Drupal's config translation UI.
pathauto.services.yml)Added
@language_manageras a new argument to thepathauto.generatorservice.src/PathautoGenerator.php)Injected
LanguageManagerInterfaceand, increateEntityAlias(),added logic to fetch language-specific config overrides via
ConfigurableLanguageManagerInterface::getLanguageConfigOverride().The translated pattern string is then used for token replacement and empty-token detection
instead of the default entity value.
tests/src/Kernel/PathautoKernelTest.php)Added
testTranslatedPattern()which:/contenu/[node:title]/contenu/bonjour-le-monde/content/hello-worldUsage
With the
config_translationmodule enabled, go toAdmin > Config > Search and metadata > URL aliases > Patterns,
and use the Translate operation on any pattern to provide
per-language alias patterns.
Comment #12
berdirFine, also the clone takes care of a problem when the same object could have multiple different translations in the same request.
One thing to be aware of is that locale/potx doesn't make a difference between translatable and localizable things, at least not with type: label. This means that default patterns can end up as translatable strings on localize.drupal.org and it will also end up syncing with the locale table, which can result in some confusing situations (frequently get that with metatags and webforms), but that's hardly our fault.
Comment #14
mably commented