14

I want my site's content to be multi-lingual. I have a language switcher that can toggle between both the English and Spanish translations of a page. I want the administrative interface to always be in English, no matter whether you navigate to it from a Spanish or English translation of the page.

Here is my configuration at /admin/config/regional/language/detection:

enter image description here

Here is my configuration at user/1/edit:

enter image description here

My admin interface is always in English, but now my content is also always in English, no matter if I toggle the page to Spanish.

I have tried many settings, including the settings in Content language detection.

What is the correct configuration to achieve this?


/es/node/1

enter image description here

/admin/config/regional/language/detection/url

enter image description here

/admin/config/regional/language

enter image description here

  • What happens if you change the URL path manually on an English page to a Spanish path? Also, try putting URL first and account admin pages second. – Patrick Kenny Sep 27 '17 at 16:48
  • The content remains in English, but the surrounding interface is in Spanish. Screen shot added to question. – 24ma13wg Sep 27 '17 at 16:55
  • In your user settings you set site language to english what happens if you logout? – Jdrupal Sep 30 '17 at 7:09
  • If I logout, it works correctly I can toggle between the English and Spanish content. – 24ma13wg Sep 30 '17 at 11:28
16
+100

On a fresh install, I could get it working that way:

In admin/config/regional/language/detection

  • put Account administration pages on top of Interface text language detection an enable it of course.
  • enable URL method as second choice
  • enable Content language detection and put URL on top of detection methods.

     Home Administration Configuration Regional and language Languages

In user/1/edit language settings :

  • set Administration pages language with your preferred language

There are various issues on D.O about that, maybe this is the most relevant one : When content language detection is different from interface language detection, the detected language is not applied to the rendered content.

Apply these patches :

Empty caches :

  • $ drush cache-rebuild

Language dropdown switcher and everything else seems now to be working fine !

An example of spanish content, strings passed through t() are translated, admin toolbar in english...

An example of spanish content

The same page edited: admin interface fully in english, but content shows the correct translation....

admin interface fully in english, but content shows  the correct translation

  • If I understand your answer correctly, the problem with your configuration is: (a) the language switcher disappears (when URL is disabled in Interface text language detection; and (b) only the content is translated at es/node/1: anything in code run through t() or |t remains untranslated. For example: 'Powered by Drupal' does not transform to 'Funciona con Drupal'. I only want /admin pages to be English-only. – 24ma13wg Oct 3 '17 at 14:07
  • @24ma13wg my bad ! Right, I'v been working a bit more around your problem, and I believe this is working fine now. I'm going to edit the answer. Check in 15mn ;) – Kojo Oct 3 '17 at 16:21
  • @24ma13wg, for the sake of clarity and future reference, I rewrote the answer with exact setup and patches. – Kojo Oct 5 '17 at 13:42
  • 1
    Seems to work. Good answer :-) – 24ma13wg Oct 5 '17 at 15:44
  • 1
    thank you! I cannot understand why this solution is still not out of the box patch less enabled in core... in 2018 August! – mogio Aug 22 '18 at 7:52
0

User preferred language is Chinees (zh-hans). When I am logging into site URL does not have language prefix. While switching the language on dropdown language for all the langauage its getting translated as expected. When I am switching the language to English (Site Default Language) and its remain as user preferred language.

Note: I am using dropdown_language for language switching.

Kindly help on this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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