Hi,

I have a issue in rendering the translated content for different languages after adding the country path as suffix.

Modules used :
Domain access, country path and enabled multilingual for the site.

Example path :

http://example.com/usa/en

after i'm switching the url to

http://example.com/usa/es

It's picking the english content only instead of spanish.

Could anyone help me out to fix this issue?

Thanks in advance.

Regards,
Guru

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

gurumurthy@drupal created an issue. See original summary.

gurumurthy@drupal’s picture

Issue summary: View changes
shaisamuel’s picture

Same issue here. This is similar to #2790683-11: Conflict with Path prefix for language detection drupal 8:

D8-8.2.5 with installed modules:

  • Country Path 8.x-1.0-rc1 (Jan 24, 2017)
  • Language 8.2.5
  • Content Translation 8.2.5 (2 Languages are defined)
  • Domain 8.x-1.0-alpha7
  • Domain Access 8.x-1.0-alpha7
  • Domain Language 8.x-1.0-alpha1 (optional)

If a country path is there in the URL, it always returns default language contents. Works with Domain Language default language, but disregard the Language choice. Both returns English version (default domain language):

  • example.com/us/en/node/1
  • example.com/us/es/node/1

Same for front page choice, both will return English documents ((default domain language):

  • example.com/us/en
  • example.com/us/es
itsekhmistro’s picture

Hi,

Could you specify what configuration do you have for Language Detection at /admin/config/regional/language/detection ?

I will try to look into details tonight.

shaisamuel’s picture

Hi itsekhmistro,

It's the defaults, URL and Select language. Part of the URL that determines language=Path prefix

Thanks

Languages detection and selection

Part of the URL that determines language

shaisamuel’s picture

Any update?

axooh’s picture

Same issue here as described in #3.

itsekhmistro’s picture

Status: Active » Closed (cannot reproduce)

From what I see the issue was related to the Cache context. And it was fixed.

Please let me know if it is still actual for you.

yivanov’s picture

I can confirm that the issue still persists. I have the same problem now with the language switching.

yivanov’s picture

Status: Closed (cannot reproduce) » Active
zrashevskaya’s picture

Status: Active » Postponed (maintainer needs more info)

Hi yivanov, could you please provide detailed steps and configuration details to reproduce this issue.
I can't reproduce it with the last release of country_path module and basic settings from #5.

arulraj’s picture

Status: Postponed (maintainer needs more info) » Active
Steps to reproduce this issue:
  1. Install Drupal version 8.5.6
  2. Install Domain module (8.x-1.0-alpha13)
  3. Install Configuration Translation, Content Translation and Interface Translation module from drupal core
  4. Add following domain using add-domain-record form
    • a. drupal8.com
    • b. drupal8.com/us
    • c. drupal8.com/uk
  5. Enable translation options for Article content type.
  6. Create node under article content type and view the drupal8.com/us/node/[nodeid]
  7. Now add translation for the same node and check drupal8.com/us/es/node/[nodeid], you will get same results for both the url.

Expectation: Need to display translated content based on language selected.

Wilfred Waltman’s picture

I experience the same issue as mentioned in #12

sergei_semipiadniy’s picture

FileSize
174.47 KB

Hi all,

As far as Country Path module provides own language negotiation plugin I think we should try to use it to correctly detect language prefix on domains like drupal8.com/us.

@arulraj, I add several steps to your list, they are bolded:

  1. Install Drupal version 8.5.6
  2. Install Domain module (8.x-1.0-alpha13)
  3. Install Domain Country Path (8.x-1.1)
  4. Install Configuration Translation, Content Translation and Interface Translation module from drupal core
  5. Add following domain using add-domain-record form
    • a. drupal8.com
    • b. drupal8.com/us
    • c. drupal8.com/uk
  6. Enable translation options for Article content type.
  7. Change language detection method on Detection and selection page (admin/config/regional/language/detection). Please see attached image.
  8. Create node under article content type and view the drupal8.com/us/node/[nodeid]
  9. Now add translation for the same node and check drupal8.com/us/es/node/[nodeid], you will get same results for both the url.

@wilfred-waltman, @arulraj have you used contry_path's detection method ?

Thanks in advance!

Wilfred Waltman’s picture

@sergei_semipiadniy,

I have the Domain Country Path module installed, and selected the country_path selection method. And the most recant versions of Drupal, Domain, and Domain Country Path. So basicly just the way you suggest in #14 and with that setup I experience the issue.

sergei_semipiadniy’s picture

FileSize
1.34 KB
1.34 KB

@wilfred-waltman,

I tested country_path (v1.1) with latest stable versions of Drupal and domain (8.6.3 and 1.0-alpha14). And it works fine for me.
Also, I attached my composer.json file as example.

Maybe other contrib modules impact on country_path's behavior.
@wilfred-waltman, could you please attach your composer.json, so that I could build Drupal instance with yours set of contribs?

Regards!

sergei_semipiadniy’s picture

Wilfred Waltman’s picture

FileSize
3 KB

@sergei_semipiadniy, here it is...

sergei_semipiadniy’s picture

FileSize
14.78 MB

@wilfred-waltman,

I set up Drupal instance using your composer.json and I tested it successfully.
I recorded small video. Please look on it and let me know if you find some difference with yours reproducing.

Regards!

Wilfred Waltman’s picture

The only things I see is that I didn't have all the Domain sub modules enabled. And I do have the Pathauto module enabled. Other then that I have the sam setup. But I will give it another go with the other modules enabled as well.

Thanks for your time and responses.

dipikas’s picture

Hi All,

Pathauto module is conflicting with country path module.When I am adding URL pattern for content type its showing node/1, not showing the page title.If anyone has got solution please suggest.

Thanks,
Dipika

nikolay.sh’s picture

Status: Active » Closed (cannot reproduce)

Hello,

I'm also cannot reproduce the issue described in the comment #12.
( tested with enabled cache and under anonymous user )
Works correctly as for @sergei_semipiadniy.

Drupal Core: 8.6.13
Domain: 8.x-1.0-alpha15
Country Path: 8.x-1.2
Pathauto: 8.x-1.3

Pathauto patterns also works correctly (comment #21).

Closed for now. Feel free to reopen if issue still persists

Thanks.

adinac’s picture

Hello,

I'm also experiencing this issue, with:
Drupal Core: 8.7.3
Domain: 8.x-1.0-alpha16
Country Path: 8.x-1.2
Pathauto: 8.x-1.4

I have two domains:
https://example-site.lndo.site/int - with just English (the default language, and has no language prefix)
https://example-site.lndo.site/ch with English and German (with 'de' as the language prefix)

A "Test Page" node which is translated in both English and German, and also has a path alias, which is also translated in English and German, and is available only on the Switzerland domain https://example-site.lndo.site/ch

If I access
https://example-site.lndo.site/ch/test-page - all is ok
https://example-site.lndo.site/ch/de/de-test-page - Page not found
https://example-site.lndo.site/ch/de/test-page - displays the English translation of the page

JamieP’s picture

I was having this issue and resolved it with a 1 line configuration update after a lot of debugging. I'm running:

  • Drupal 8.9.13
  • Country path 8.x-1.4

In language.types.yml, ensure that "country-path-language-url" is enabled under language_url, for example:

language_url:
    enabled:
      country-path-language-url: -8
      language-url: 0
      language-url-fallback: 1

Background

The UI at /admin/config/regional/language/detection only allows interface & content language types to be enabled/configured. There doesn't seem to be a way to do this for url language types.

The LanguageNegotiationCountryPathUrl plugin annotation indicates the negotiation method is applicable to LanguageInterface::TYPE_URL, but for some reason this was not picked up during my initial config export. The site was installed from a custom profile, so this may be related to https://www.drupal.org/project/drupal/issues/2666998.

As the plugin was not enabled under language_url, aliases were not working (relates to https://www.drupal.org/node/1125428).

My setup was as follows:

Domains

Language URL prefixes
(configured at /admin/config/regional/language/detection/url):

  • English (en) path prefix (Default language): en
  • French (fr) path prefix: fr
  • German (de) path prefix: de

Test cases
When I created a new node in English with the URL /my-page (without creating any translations), navigation resulted in the following:

However, the site did behave as expected when accessing nodes with unaliased paths:

Analysis
The reason for this was that my region path suffixes (de & fr) are also valid language codes, so the default language_url negotiator was detecting the first argument as the langcode, rather than the second.

When I accessed www.example/fr/en/my-page for example, the system was looking for "/my-page" in as an fr language alias, not en.

The /world/en URL only worked because "world" is not a valid langcode, and therefore the language_url defaulted to en, so the "/my-page" alias was found.

After updating language.types.yml, all URLs worked as expected because the country path negotiator was active during url alias detection.

Hope that helps anyone else that finds themselves in this situation.

JamieP’s picture

JamieP’s picture