Does this module work when there are no folders in the path?

Created on 27 September 2023, about 1 year ago
Updated 6 October 2023, about 1 year ago

I'm currently working on a multilingual website, whose addressing works perfectly without installing this module and there are no problems with the menus and sidebars. But there is a serious problem, let's see:

This website uses two languages: Brazilian Portuguese (pt-br) and English (en). Portuguese is the main language and the site was built so that URLS work as follows:

Portuguese: localhost/sitename or sitename/
English: localhost/sitename/en or sitename/en

The big problem is with the links on English language content pages, as Drupal cannot see the URL indicated in the link correctly.

For example:

User browsing in English, opens a page and clicks on the "Contact Us (node 20)" link. The URL for this link should be: "localhost/sitename/en/contact/contact-us", but the results are as follows:

Link: /node/20 -> URL: localhost/sitename/contato/fale-conosco - Refers the user to node 20, in Portuguese
Link: en/node/20 -> URL: localhost/sitename/contato/fale-conosco - Refers the user to node 20, in Portuguese
Link: /en/node/20 -> URL: localhost/sitename/contato/fale-conosco - Refers the user to node 20, in Portuguese
Link: ../en/node/20 -> URL: localhost/en/node/20 - Message from Apache, informing that the URL was not found on the server
Link: /contact/contact-us -> URL: localhost/sitename/contact/contact-us - ERROR 404, in Portuguese
Link: ../contact/contact-us -> URL: localhost/contact/contact-us - Message from Apache, informing that the URL was not found on the server
Link: en/contact/contact-us -> URL: localhost/sitename/contact/contact-us - ERROR 404, in Portuguese
Link: /en/contact/contact-us -> URL: localhost/sitename/contact/contact-us - ERROR 404, in Portuguese
Link: ../en/contact/contact-us -> URL: localhost/en/contact/contact-us - Message from Apache, stating that the URL was not found on the server

Furthermore, we can see that there are no subfolders in the construction of the URLS, as in the description of this module (e.g. this.example.domain/lives/here/en or this.example.domain/lives/here/fr), a fact that makes me wonder: Will this module be able to help fix the issue with website language detection?

In a test installation, copy of the website above, I installed the Matrix module, hoping to resolve this problem. Before installation, language detection had the URL and Selected Language options enabled. I tried other settings, but they gave me more problems instead of a solution.

On localhost, I tried to configure the module using the JSON Matrix Definition and added the following code to the JSON Language Matrix:

{"pt-br":"/sitename", "en":"/sitename"}

After that, I simply added the "en" prefix to the English path and clicked save and received the following return message:

"Redirects to external URLs are not allowed by default, use \Drupal\Core\Routing\TrustedRedirectResponse for it."

I tried this configuration because the site architecture does not have folders in the path.

Based on the information above, I ask: Can this module help me to fix the issue with website language detection?? How should I configure it? Does anyone have any ideas?

πŸ’¬ Support request
Status

Needs review

Version

1.0

Component

Documentation

Created by

πŸ‡§πŸ‡·Brazil astutonet Sao Paulo, SP

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

Comments & Activities

  • Issue created by @astutonet
  • πŸ‡¨πŸ‡¦Canada joseph.olstad

    make symlinks in your docroot

    ex

    ln -s . nomdusite
    ln -s . nomedosΓ­tio
    ln -s . nameofsite
    

    set up the matrix for
    fr to correspond to nomdusite
    en to correspond to nameofsite
    pt to correspond to nomedositio

    then apache configuration changes:
    something like this:

    DocumentRoot "{DOCROOT}/docroot/html"
    Alias /nomdusite "{DOCROOT}/docroot/html"
    Alias /nomedositio "{DOCROOT}/docroot/html"
    Alias /sitename "{DOCROOT}/docroot/html"
    

    I have inserted this just prior to this entry:
    <Directory {DOCROOT}>

    restart apache, configure language matrix keys for language to correspond to Alias

    Then you'll be able to have:

     localhost/sitename/en
     localhost/nomdusite/fr
     localhost/nomedusitio/pt
    

    and your language switcher will automatically know what the other url should be, that's what this module helps with.

  • πŸ‡¨πŸ‡¦Canada joseph.olstad

    some drupal projects use web for foldername like project/web, some use html as the foldername like project/html

    however this can be other values.

  • πŸ‡§πŸ‡·Brazil astutonet Sao Paulo, SP

    I will check. Thanks for the answer

  • Assigned to wilco
  • Status changed to Needs review about 1 year ago
Production build 0.71.5 2024