Score:2

How do I create multilingual user path aliases?

de flag

I'm setting up a multilingual site, and I need the user path aliases to be multilingual.

Users are set up as translatable: User Translation Configuration

Language Detection: URL (path prefix)

  • English: /en
  • Japanese: No prefix

Pathauto patterns:

  • English: /en/users/[user:name]
  • Japanese: '/users/[user:name]

Pathauto Patterns

Example:

  • Username: Admin

Expected paths:

  • English: /en/users/admin
  • Japanese: /users/admin

Actual:

  • English: /en/user/1
  • Main language: /users/admin

I've cleared the registry, regenerated the URLs, manually unset path aliases on the user then checked the box and re-saved, but I have not found any combination that results in multilingual path aliases.]

Update

I've tried the following, which also did not work:

Screenshot of alternate attempt

Berry Dingle avatar
cn flag
Did you enable "URL detection mehtod" in Admin -> Configuration -> Regional and languages -> Languages -> Detection and selection? Aslo configuration translation and Content language translation module should be installed. Then you can set path auto patterns for each language. URLpattern will be www.youdomain.com/en/yourpattern. But the main language will also have the language code in the URL like /en /de /ru /fr - whatevery your base language is set to.
Jaypan avatar
de flag
Thank you. I have tried your suggestions, but still no luck. I have updated the post with screenshots and additional information.
Razeem Ahmad avatar
ru flag
Have you tried with the the user original token like `users/[user:original:display-name]` and checking both the languages[en, jp] in one pattern config.
Jaypan avatar
de flag
I just tried that (screenshot added to original post), and after deleting and regenerating all User aliases, still no luck. Thank you though.
in flag
What exactly do you want to achieve? Show the user detail page on the url users/{some_user} and /en/users/{some_user}? Please correct me if I am wrong.
Jaypan avatar
de flag
I want to achieve what I outlined in the 'Expected' section of the post. For the path `/users/admin` the profile page of the Admin user is shown. for `/en/users/admin`, a 404 page is shown.
Stefanos Petrakis avatar
in flag
@Jaypan did you figure out sth more about this in the end?
Jaypan avatar
de flag
Not yet, but there is a new post below I need to try. I will update after I have tried it.
Score:1
in flag

I followed your setup on a vanilla D9 and can report on the following:

  • Pathauto aliases are created as expected enter image description here but only for translated users enter image description here That is an expected outcome looking at Pathauto's code, since it will start generating language specific aliases based on a pattern only for the translated languages of each entity during bulk updates and only for the active language of an entity during hook_entity_update.
  • A manually created path alias enter image description here for an untranslated language of a user entity does work and resolves properly. enter image description here

In short, the answer is:

Multilingual user aliases are created automatically by Pathauto for each translated language of a user entity, or can be added manually for non-translated languages of a user entity.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.