Multilingual Support

Created on 5 July 2021, almost 4 years ago
Updated 22 March 2024, about 1 year ago

Problem/Motivation

As of now, module does not support multilingual very well. Like a node can have different url alias per language, while this is not supported by the module.

Steps to reproduce

1. Enable Content Translation, create node and add translations.
2. Create Views, add url alias field

You will observe duplication of records. Because table has as many records of node based on translations being added.
Impt: Calling views_url_alias_node_rebuild will resolve the issue of duplication, but that's not the solution, as this actually is just a temporary solution, the moment we add translation to the node, records are again duplicated.

Proposed resolution

Let's store langcode as well in the table.
Support entity translation operations for adding / updating records. As well update existing functions to save corresponding langcode.
Also, we will have to write hook_update to add this field.
I'ld start with creating a patch for this, including following issues as well:
https://www.drupal.org/project/views_url_alias/issues/3104606 πŸ“Œ Implement path alias changes in 8.x-1.x Needs work
https://www.drupal.org/project/views_url_alias/issues/3036345 πŸ› No indexes created on 'views_url_alias_node' table Fixed

Remaining tasks

User interface changes

API changes

Data model changes

✨ Feature request
Status

Needs work

Version

3.0

Component

Code

Created by

πŸ‡ͺπŸ‡ΈSpain purushotam.rai

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡¨πŸ‡¦Canada dstorozhuk Chicago πŸ‡ΊπŸ‡Έ, Toronto πŸ‡¨πŸ‡¦, Kyiv πŸ‡ΊπŸ‡¦

    This issue still valid in term of adding the language filter.
    I fixed in 3.x-dev the issue with saving the language dependent data to views_url_alias, but the filter or view query still need to added to make sure we can filter by specific/current language.

  • murat_kekic β†’ made their first commit to this issue’s fork.

  • The latest code wasn't selecting the correct entity translation.
    It always picked the entity translation in the current user's language because the entity was resolved with the router service.
    This issue can be reproduced by running a Pathauto bulk regenerate for all aliases on a multilingual entity.

    I refactored the views_url_alias_get_path_entity_type function to ensure it handles entity translations properly when applicable.

    However, I had to remove the views_url_alias_pathauto_alias_alter hook function. The comment in the hook says it’s for saving aliases during bulk updates

    function views_url_alias_pathauto_alias_alter(&$alias, array &$context) {
      // Save alias during bulk update.
    

    , but I don’t see how that’s the relevant place to save the data. Is it a workaround for something?

  • πŸ‡΅πŸ‡°Pakistan dewancodes

    After I had installed this module on Drupal 10.2.3, I added a relationship in the views for 'URL alias', the related views page is broken. It is not working correctly on a multilingual website.

  • πŸ‡ͺπŸ‡ΈSpain manuel garcia

    Im not sure if this is 100% the same problem as this, but I couldn't find anything closer already opened and this seems to be at least related, so I wanted to leave here a report of the problem we are having with the module in a multilingual installation:

    So we have two nodes, one in english and one spanish, both with different URL aliases:

    • English node has this URL alias: /testing123
    • Spanish node has this URL alias: /testing123345345

    However this is the results displayed by the view:

    There are two problems:

    • The english (original) row displays the URL alias of the Spanish translation.
    • The spanish (translated) row displays nothing .

    Looking at views_url_alias_save() looks like the entity's language are being taking into account, so not sure what is causing the problem...

  • πŸ‡ͺπŸ‡ΈSpain manuel garcia

    Spent some time on this today, turns out that the langcode was not being saved correctly to the DB among other things.

    In the attached patch:

    • Added proper langcode handling in path alias operations
    • Added language field support in views integration
    • Added language-aware relationships in Views
    • Fixed multilingual URL alias handling

    With this we are able to list the correct URL alias depending on the language of the entity being displayed:

Production build 0.71.5 2024