The language manager should make it less painful to change the current language

Created on 28 January 2019, about 6 years ago
Updated 20 November 2023, over 1 year ago

Problem/Motivation

To translate interface text, configuration content, and entity content in a specific render context is difficult. To accomplish this, you must change the site's default language, set the config override, and modify the default langcode on the translation service.

+        $this->languageDefault->set($language);
+
+        $this->languageManager->setConfigOverrideLanguage($language);
+        $this->languageManager->reset();
+
+        $string_translation = $this->getStringTranslation();
+        if ($string_translation instanceof TranslationManager) {
+          $string_translation->setDefaultLangcode($language->getId());
+          $string_translation->reset();

Proposed resolution

The LanguageManagerInterface should have a "setLanguage" method (or other naming) which streamlines this task.

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

✨ Feature request
Status

Closed: duplicate

Version

11.0 πŸ”₯

Component
Language moduleΒ  β†’

Last updated 6 days ago

  • Maintained by
  • πŸ‡©πŸ‡ͺGermany @sun
Created by

πŸ‡ΊπŸ‡ΈUnited States mglaman WI, USA

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024