0

At the moment I am working on a multilingual page (German/English). I finished adding my German content, and want to add my English version, so I can access it like examplesite.com/examplepage (German) --> examplesite.com/en/examplepage (English).

The steps I did so far:

  • I enabled the right custom language settings for translation
  • I added the needed pathauto-patterns
  • added a path-prefix-configuration for English "en"

My problem now is the fact, that I can't access these pages after adding the translations.

This means when I access a German site in the front end, and click the language switch to the English version, it won't link me to the translated content but only refreshes the page.

The same weird behaviour is shown in the backend on the content-overview page. The translated pages all exist in the list and if I hover over the title it will show me the right URL like e.g. examplesite.com/en/examplepage but when I open the url it will just show me a 404. It seems that the content is not connected to the right, translated urls.

Am I missing something?

2
  • Have you enabled and configured your language URLs in admin/config/regional/language/detection?
    – CG Monroe
    Apr 30, 2018 at 19:34
  • Yes, I chose "path prefix" as detection and set the default path for my default language German. For my English version I chose the prefix /en. Like I mentioned before, I get the right links shown in the content overview page when I hover over the translated pages but I can't access them anymore.
    – tinytree
    Apr 30, 2018 at 20:05

2 Answers 2

0

In addition to the Regional and language configuration (as listed in the other Answer) it is really important to flush the cache for the configuration to take effect properly.

Flushing cache through the Admin links is problematic because of the same issue we're trying to solve, the link to flush cache is also affected by content not being refreshed to follow the new language settings. You can delete the language prefix manually from the browser addressbar yourself and then Enter to actually flush the cache. But it can still be confusing and difficult to know whether this had an effect.

The way to go in this case is to use Drush script, because it doesn't depend on the internal Drupal language configuration (cache-rebuild for Drupal 8):

$drush cr

or through the Performance page (Administration > Configuration > Development > Performance (/admin/config/development/performance)) button Clear all caches.

0

In addition to enabling "URL" Detection method (path prefix or domain) and positioning it to be used first, you also have to Configure it.

  1. Set German as your Default language under Administration > Configuration > Regional and language
  2. Go to the Language Detection and Selection page and enable the "URL" Detection method
  3. On the Language Detection and Selection page click through the Configure button for the URL (/admin/config/regional/language/detection/url)
  4. Select "Path prefix" as the " Part of the URL that determines language" option
  5. Delete the de from the "German (de) path prefix (Default language)" option
  6. Clear cache! This can be tricky through the interface if you're using the admin module because the /de/ might linger on the menus but will lead to a Page not found. Delete the /de/ in your browser Location bar from the flush cache link to make it work.

After this you should have the correct Home in German, without the /de, German content and links without the prefix and English content and links with /en/.

6
  • Thank you prkos for your precise answer. I already configured my URL detection method before, but I re-configured it again - just in case. I followed your steps but it didn't change a thing on my issue. The German language is set as the default URL without the de path prefix and the English version is set with the en prefix. The language switch shows me the right links when I hover over the English button on a German site but when I click on the link it shows me the right url in the adress bar with a 404 page not found.
    – tinytree
    May 1, 2018 at 12:23
  • There is a similar behaviour when I go to the content section of the page. If i hover over a specific English page link it will show me the right URL, but after clicking on it it will link me to the German version instead of the English one. When I type it in manually it will give me a 404 again.
    – tinytree
    May 1, 2018 at 12:24
  • This sounds like the changes haven't taken all the way through, which happens if the Flush cache hasn't been done. The menus are aware of your Language changes but Language negotiation hasn't cleared out the old references. Are you sure you have successfully cleared all cache? Can you do it through Drush and not the interface just to make sure? I don't think pathauto has anything to do with it. Any other language-related config you're using?
    – prkos
    May 2, 2018 at 1:01
  • That did the trick for me. Thank you! Flushing the cash via backend isn't enough in that case and you have use drush command like drush cr to make it to work.
    – tinytree
    May 2, 2018 at 7:44
  • Please copy your last comment as a new answer, so I can mark it as solved.
    – tinytree
    May 2, 2018 at 7:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.