1

We have built one website in English and we want to translate it in Arabic.

Since I am new to Drupal, I am not sure how I can set a theme for English, and one for Arabic. How should I achieve this?

1 Answer 1

1

you can check the current language with the languageManager (docs here)

Drupal::languageManager()

and then you can set a different theme with the theme service

\Drupal::service('theme_handler')->setDefault('test_theme');

Hope it helps,

3
  • 1
    Maybe adding such code in a "hook_init" into a custom module, so that the theme gets automatically defined when the page loads according to the language should do the job
    – Renrhaf
    Jan 9, 2018 at 22:17
  • 1
    In D8 this would be in a theme negotiator, see drupal.stackexchange.com/questions/201530/…
    – 4uk4
    Jan 9, 2018 at 22:45
  • @lchabrand Thanks for your answer. Which file to add above code. I know about themename.theme file or this can only go in module file. I am new to drupal 8 and will try to learn making modules if this code can only go in theme file. Jan 10, 2018 at 9:09

Your Answer

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

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