Chris@0: drupalCreateUser(['administer blocks', 'administer languages', 'access administration pages']); Chris@0: $this->drupalLogin($admin_user); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Functional tests for the language switcher block. Chris@0: */ Chris@0: public function testLanguageBlock() { Chris@0: // Add language. Chris@0: $edit = [ Chris@0: 'predefined_langcode' => 'fr', Chris@0: ]; Chris@0: $this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language')); Chris@0: Chris@0: // Set the native language name. Chris@0: $this->saveNativeLanguageName('fr', 'français'); Chris@0: Chris@0: // Enable URL language detection and selection. Chris@0: $edit = ['language_interface[enabled][language-url]' => '1']; Chris@0: $this->drupalPostForm('admin/config/regional/language/detection', $edit, t('Save settings')); Chris@0: Chris@0: // Enable the language switching block. Chris@0: $block = $this->drupalPlaceBlock('language_block:' . LanguageInterface::TYPE_INTERFACE, [ Chris@0: 'id' => 'test_language_block', Chris@0: // Ensure a 2-byte UTF-8 sequence is in the tested output. Chris@0: 'label' => $this->randomMachineName(8) . '×', Chris@0: ]); Chris@0: Chris@0: $this->doTestLanguageBlockAuthenticated($block->label()); Chris@0: $this->doTestLanguageBlockAnonymous($block->label()); Chris@0: } Chris@0: Chris@0: /** Chris@0: * For authenticated users, the "active" class is set by JavaScript. Chris@0: * Chris@0: * @param string $block_label Chris@0: * The label of the language switching block. Chris@0: * Chris@0: * @see testLanguageBlock() Chris@0: */ Chris@0: protected function doTestLanguageBlockAuthenticated($block_label) { Chris@0: // Assert that the language switching block is displayed on the frontpage. Chris@0: $this->drupalGet(''); Chris@0: $this->assertText($block_label, 'Language switcher block found.'); Chris@0: Chris@0: // Assert that each list item and anchor element has the appropriate data- Chris@0: // attributes. Chris@0: $language_switchers = $this->xpath('//div[@id=:id]/ul/li', [':id' => 'block-test-language-block']); Chris@0: $list_items = []; Chris@0: $anchors = []; Chris@0: $labels = []; Chris@0: foreach ($language_switchers as $list_item) { Chris@0: $classes = explode(" ", $list_item->getAttribute('class')); Chris@0: list($langcode) = array_intersect($classes, ['en', 'fr']); Chris@0: $list_items[] = [ Chris@0: 'langcode_class' => $langcode, Chris@0: 'data-drupal-link-system-path' => $list_item->getAttribute('data-drupal-link-system-path'), Chris@0: ]; Chris@0: Chris@0: $link = $list_item->find('xpath', 'a'); Chris@0: $anchors[] = [ Chris@0: 'hreflang' => $link->getAttribute('hreflang'), Chris@0: 'data-drupal-link-system-path' => $link->getAttribute('data-drupal-link-system-path'), Chris@0: ]; Chris@0: $labels[] = $link->getText(); Chris@0: } Chris@0: $expected_list_items = [ Chris@0: 0 => ['langcode_class' => 'en', 'data-drupal-link-system-path' => 'user/2'], Chris@0: 1 => ['langcode_class' => 'fr', 'data-drupal-link-system-path' => 'user/2'], Chris@0: ]; Chris@0: $this->assertIdentical($list_items, $expected_list_items, 'The list items have the correct attributes that will allow the drupal.active-link library to mark them as active.'); Chris@0: $expected_anchors = [ Chris@0: 0 => ['hreflang' => 'en', 'data-drupal-link-system-path' => 'user/2'], Chris@0: 1 => ['hreflang' => 'fr', 'data-drupal-link-system-path' => 'user/2'], Chris@0: ]; Chris@0: $this->assertIdentical($anchors, $expected_anchors, 'The anchors have the correct attributes that will allow the drupal.active-link library to mark them as active.'); Chris@0: $settings = $this->getDrupalSettings(); Chris@0: $this->assertIdentical($settings['path']['currentPath'], 'user/2', 'drupalSettings.path.currentPath is set correctly to allow drupal.active-link to mark the correct links as active.'); Chris@0: $this->assertIdentical($settings['path']['isFront'], FALSE, 'drupalSettings.path.isFront is set correctly to allow drupal.active-link to mark the correct links as active.'); Chris@0: $this->assertIdentical($settings['path']['currentLanguage'], 'en', 'drupalSettings.path.currentLanguage is set correctly to allow drupal.active-link to mark the correct links as active.'); Chris@0: $this->assertIdentical($labels, ['English', 'français'], 'The language links labels are in their own language on the language switcher block.'); Chris@0: } Chris@0: Chris@0: /** Chris@0: * For anonymous users, the "active" class is set by PHP. Chris@0: * Chris@0: * @param string $block_label Chris@0: * The label of the language switching block. Chris@0: * Chris@0: * @see testLanguageBlock() Chris@0: */ Chris@0: protected function doTestLanguageBlockAnonymous($block_label) { Chris@0: $this->drupalLogout(); Chris@0: Chris@0: // Assert that the language switching block is displayed on the frontpage Chris@0: // and ensure that the active class is added when query params are present. Chris@0: $this->drupalGet('', ['query' => ['foo' => 'bar']]); Chris@0: $this->assertText($block_label, 'Language switcher block found.'); Chris@0: Chris@0: // Assert that only the current language is marked as active. Chris@0: $language_switchers = $this->xpath('//div[@id=:id]/ul/li', [':id' => 'block-test-language-block']); Chris@0: $links = [ Chris@0: 'active' => [], Chris@0: 'inactive' => [], Chris@0: ]; Chris@0: $anchors = [ Chris@0: 'active' => [], Chris@0: 'inactive' => [], Chris@0: ]; Chris@0: $labels = []; Chris@0: foreach ($language_switchers as $list_item) { Chris@0: $classes = explode(" ", $list_item->getAttribute('class')); Chris@0: list($langcode) = array_intersect($classes, ['en', 'fr']); Chris@0: if (in_array('is-active', $classes)) { Chris@0: $links['active'][] = $langcode; Chris@0: } Chris@0: else { Chris@0: $links['inactive'][] = $langcode; Chris@0: } Chris@0: Chris@0: $link = $list_item->find('xpath', 'a'); Chris@0: $anchor_classes = explode(" ", $link->getAttribute('class')); Chris@0: if (in_array('is-active', $anchor_classes)) { Chris@0: $anchors['active'][] = $langcode; Chris@0: } Chris@0: else { Chris@0: $anchors['inactive'][] = $langcode; Chris@0: } Chris@0: $labels[] = $link->getText(); Chris@0: } Chris@0: $this->assertIdentical($links, ['active' => ['en'], 'inactive' => ['fr']], 'Only the current language list item is marked as active on the language switcher block.'); Chris@0: $this->assertIdentical($anchors, ['active' => ['en'], 'inactive' => ['fr']], 'Only the current language anchor is marked as active on the language switcher block.'); Chris@0: $this->assertIdentical($labels, ['English', 'français'], 'The language links labels are in their own language on the language switcher block.'); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Test language switcher links for domain based negotiation. Chris@0: */ Chris@0: public function testLanguageBlockWithDomain() { Chris@0: // Add the Italian language. Chris@0: ConfigurableLanguage::createFromLangcode('it')->save(); Chris@0: Chris@0: // Rebuild the container so that the new language is picked up by services Chris@0: // that hold a list of languages. Chris@0: $this->rebuildContainer(); Chris@0: Chris@0: $languages = $this->container->get('language_manager')->getLanguages(); Chris@0: Chris@0: // Enable browser and URL language detection. Chris@0: $edit = [ Chris@0: 'language_interface[enabled][language-url]' => TRUE, Chris@0: 'language_interface[weight][language-url]' => -10, Chris@0: ]; Chris@0: $this->drupalPostForm('admin/config/regional/language/detection', $edit, t('Save settings')); Chris@0: Chris@0: // Do not allow blank domain. Chris@0: $edit = [ Chris@0: 'language_negotiation_url_part' => LanguageNegotiationUrl::CONFIG_DOMAIN, Chris@0: 'domain[en]' => '', Chris@0: ]; Chris@0: $this->drupalPostForm('admin/config/regional/language/detection/url', $edit, t('Save configuration')); Chris@0: $this->assertText(t('The domain may not be left blank for English'), 'The form does not allow blank domains.'); Chris@0: Chris@0: // Change the domain for the Italian language. Chris@0: $edit = [ Chris@0: 'language_negotiation_url_part' => LanguageNegotiationUrl::CONFIG_DOMAIN, Chris@0: 'domain[en]' => \Drupal::request()->getHost(), Chris@0: 'domain[it]' => 'it.example.com', Chris@0: ]; Chris@0: $this->drupalPostForm('admin/config/regional/language/detection/url', $edit, t('Save configuration')); Chris@0: $this->assertText(t('The configuration options have been saved'), 'Domain configuration is saved.'); Chris@0: Chris@0: // Enable the language switcher block. Chris@0: $this->drupalPlaceBlock('language_block:' . LanguageInterface::TYPE_INTERFACE, ['id' => 'test_language_block']); Chris@0: Chris@0: $this->drupalGet(''); Chris@0: Chris@0: /** @var \Drupal\Core\Routing\UrlGenerator $generator */ Chris@0: $generator = $this->container->get('url_generator'); Chris@0: Chris@0: // Verify the English URL is correct Chris@0: list($english_link) = $this->xpath('//div[@id=:id]/ul/li/a[@hreflang=:hreflang]', [ Chris@0: ':id' => 'block-test-language-block', Chris@0: ':hreflang' => 'en', Chris@0: ]); Chris@0: $english_url = $generator->generateFromRoute('entity.user.canonical', ['user' => 2], ['language' => $languages['en']]); Chris@0: $this->assertEqual($english_url, $english_link->getAttribute('href')); Chris@0: Chris@0: // Verify the Italian URL is correct Chris@0: list($italian_link) = $this->xpath('//div[@id=:id]/ul/li/a[@hreflang=:hreflang]', [ Chris@0: ':id' => 'block-test-language-block', Chris@0: ':hreflang' => 'it', Chris@0: ]); Chris@0: $italian_url = $generator->generateFromRoute('entity.user.canonical', ['user' => 2], ['language' => $languages['it']]); Chris@0: $this->assertEqual($italian_url, $italian_link->getAttribute('href')); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Test active class on links when switching languages. Chris@0: */ Chris@0: public function testLanguageLinkActiveClass() { Chris@0: // Add language. Chris@0: $edit = [ Chris@0: 'predefined_langcode' => 'fr', Chris@0: ]; Chris@0: $this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language')); Chris@0: Chris@0: // Enable URL language detection and selection. Chris@0: $edit = ['language_interface[enabled][language-url]' => '1']; Chris@0: $this->drupalPostForm('admin/config/regional/language/detection', $edit, t('Save settings')); Chris@0: Chris@0: $this->doTestLanguageLinkActiveClassAuthenticated(); Chris@0: $this->doTestLanguageLinkActiveClassAnonymous(); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Check the path-admin class, as same as on default language. Chris@0: */ Chris@0: public function testLanguageBodyClass() { Chris@0: $searched_class = 'path-admin'; Chris@0: Chris@0: // Add language. Chris@0: $edit = [ Chris@0: 'predefined_langcode' => 'fr', Chris@0: ]; Chris@0: $this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language')); Chris@0: Chris@0: // Enable URL language detection and selection. Chris@0: $edit = ['language_interface[enabled][language-url]' => '1']; Chris@0: $this->drupalPostForm('admin/config/regional/language/detection', $edit, t('Save settings')); Chris@0: Chris@0: // Check if the default (English) admin/config page has the right class. Chris@0: $this->drupalGet('admin/config'); Chris@0: $class = $this->xpath('//body[contains(@class, :class)]', [':class' => $searched_class]); Chris@0: $this->assertTrue(isset($class[0]), t('The path-admin class appears on default language.')); Chris@0: Chris@0: // Check if the French admin/config page has the right class. Chris@0: $this->drupalGet('fr/admin/config'); Chris@0: $class = $this->xpath('//body[contains(@class, :class)]', [':class' => $searched_class]); Chris@0: $this->assertTrue(isset($class[0]), t('The path-admin class same as on default language.')); Chris@0: Chris@0: // The testing profile sets the user/login page as the frontpage. That Chris@0: // redirects authenticated users to their profile page, so check with an Chris@0: // anonymous user instead. Chris@0: $this->drupalLogout(); Chris@0: Chris@0: // Check if the default (English) frontpage has the right class. Chris@0: $this->drupalGet(''); Chris@0: $class = $this->xpath('//body[contains(@class, :class)]', [':class' => 'path-frontpage']); Chris@0: $this->assertTrue(isset($class[0]), 'path-frontpage class found on the body tag'); Chris@0: Chris@0: // Check if the French frontpage has the right class. Chris@0: $this->drupalGet('fr'); Chris@0: $class = $this->xpath('//body[contains(@class, :class)]', [':class' => 'path-frontpage']); Chris@0: $this->assertTrue(isset($class[0]), 'path-frontpage class found on the body tag with french as the active language'); Chris@0: Chris@0: } Chris@0: Chris@0: /** Chris@0: * For authenticated users, the "active" class is set by JavaScript. Chris@0: * Chris@0: * @see testLanguageLinkActiveClass() Chris@0: */ Chris@0: protected function doTestLanguageLinkActiveClassAuthenticated() { Chris@0: $function_name = '#type link'; Chris@0: $path = 'language_test/type-link-active-class'; Chris@0: Chris@0: // Test links generated by the link generator on an English page. Chris@0: $current_language = 'English'; Chris@0: $this->drupalGet($path); Chris@0: Chris@0: // Language code 'none' link should be active. Chris@0: $langcode = 'none'; Chris@0: $links = $this->xpath('//a[@id = :id and @data-drupal-link-system-path = :path]', [':id' => 'no_lang_link', ':path' => $path]); Chris@0: $this->assertTrue(isset($links[0]), t('A link generated by :function to the current :language page with langcode :langcode has the correct attributes that will allow the drupal.active-link library to mark it as active.', [':function' => $function_name, ':language' => $current_language, ':langcode' => $langcode])); Chris@0: Chris@0: // Language code 'en' link should be active. Chris@0: $langcode = 'en'; Chris@0: $links = $this->xpath('//a[@id = :id and @hreflang = :lang and @data-drupal-link-system-path = :path]', [':id' => 'en_link', ':lang' => 'en', ':path' => $path]); Chris@0: $this->assertTrue(isset($links[0]), t('A link generated by :function to the current :language page with langcode :langcode has the correct attributes that will allow the drupal.active-link library to mark it as active.', [':function' => $function_name, ':language' => $current_language, ':langcode' => $langcode])); Chris@0: Chris@0: // Language code 'fr' link should not be active. Chris@0: $langcode = 'fr'; Chris@0: $links = $this->xpath('//a[@id = :id and @hreflang = :lang and @data-drupal-link-system-path = :path]', [':id' => 'fr_link', ':lang' => 'fr', ':path' => $path]); Chris@0: $this->assertTrue(isset($links[0]), t('A link generated by :function to the current :language page with langcode :langcode has the correct attributes that will allow the drupal.active-link library to NOT mark it as active.', [':function' => $function_name, ':language' => $current_language, ':langcode' => $langcode])); Chris@0: Chris@0: // Verify that drupalSettings contains the correct values. Chris@0: $settings = $this->getDrupalSettings(); Chris@0: $this->assertIdentical($settings['path']['currentPath'], $path, 'drupalSettings.path.currentPath is set correctly to allow drupal.active-link to mark the correct links as active.'); Chris@0: $this->assertIdentical($settings['path']['isFront'], FALSE, 'drupalSettings.path.isFront is set correctly to allow drupal.active-link to mark the correct links as active.'); Chris@0: $this->assertIdentical($settings['path']['currentLanguage'], 'en', 'drupalSettings.path.currentLanguage is set correctly to allow drupal.active-link to mark the correct links as active.'); Chris@0: Chris@0: // Test links generated by the link generator on a French page. Chris@0: $current_language = 'French'; Chris@0: $this->drupalGet('fr/language_test/type-link-active-class'); Chris@0: Chris@0: // Language code 'none' link should be active. Chris@0: $langcode = 'none'; Chris@0: $links = $this->xpath('//a[@id = :id and @data-drupal-link-system-path = :path]', [':id' => 'no_lang_link', ':path' => $path]); Chris@0: $this->assertTrue(isset($links[0]), t('A link generated by :function to the current :language page with langcode :langcode has the correct attributes that will allow the drupal.active-link library to mark it as active.', [':function' => $function_name, ':language' => $current_language, ':langcode' => $langcode])); Chris@0: Chris@0: // Language code 'en' link should not be active. Chris@0: $langcode = 'en'; Chris@0: $links = $this->xpath('//a[@id = :id and @hreflang = :lang and @data-drupal-link-system-path = :path]', [':id' => 'en_link', ':lang' => 'en', ':path' => $path]); Chris@0: $this->assertTrue(isset($links[0]), t('A link generated by :function to the current :language page with langcode :langcode has the correct attributes that will allow the drupal.active-link library to NOT mark it as active.', [':function' => $function_name, ':language' => $current_language, ':langcode' => $langcode])); Chris@0: Chris@0: // Language code 'fr' link should be active. Chris@0: $langcode = 'fr'; Chris@0: $links = $this->xpath('//a[@id = :id and @hreflang = :lang and @data-drupal-link-system-path = :path]', [':id' => 'fr_link', ':lang' => 'fr', ':path' => $path]); Chris@0: $this->assertTrue(isset($links[0]), t('A link generated by :function to the current :language page with langcode :langcode has the correct attributes that will allow the drupal.active-link library to mark it as active.', [':function' => $function_name, ':language' => $current_language, ':langcode' => $langcode])); Chris@0: Chris@0: // Verify that drupalSettings contains the correct values. Chris@0: $settings = $this->getDrupalSettings(); Chris@0: $this->assertIdentical($settings['path']['currentPath'], $path, 'drupalSettings.path.currentPath is set correctly to allow drupal.active-link to mark the correct links as active.'); Chris@0: $this->assertIdentical($settings['path']['isFront'], FALSE, 'drupalSettings.path.isFront is set correctly to allow drupal.active-link to mark the correct links as active.'); Chris@0: $this->assertIdentical($settings['path']['currentLanguage'], 'fr', 'drupalSettings.path.currentLanguage is set correctly to allow drupal.active-link to mark the correct links as active.'); Chris@0: } Chris@0: Chris@0: /** Chris@0: * For anonymous users, the "active" class is set by PHP. Chris@0: * Chris@0: * @see testLanguageLinkActiveClass() Chris@0: */ Chris@0: protected function doTestLanguageLinkActiveClassAnonymous() { Chris@0: $function_name = '#type link'; Chris@0: Chris@0: $this->drupalLogout(); Chris@0: Chris@0: // Test links generated by the link generator on an English page. Chris@0: $current_language = 'English'; Chris@0: $this->drupalGet('language_test/type-link-active-class'); Chris@0: Chris@0: // Language code 'none' link should be active. Chris@0: $langcode = 'none'; Chris@0: $links = $this->xpath('//a[@id = :id and contains(@class, :class)]', [':id' => 'no_lang_link', ':class' => 'is-active']); Chris@0: $this->assertTrue(isset($links[0]), t('A link generated by :function to the current :language page with langcode :langcode is marked active.', [':function' => $function_name, ':language' => $current_language, ':langcode' => $langcode])); Chris@0: Chris@0: // Language code 'en' link should be active. Chris@0: $langcode = 'en'; Chris@0: $links = $this->xpath('//a[@id = :id and contains(@class, :class)]', [':id' => 'en_link', ':class' => 'is-active']); Chris@0: $this->assertTrue(isset($links[0]), t('A link generated by :function to the current :language page with langcode :langcode is marked active.', [':function' => $function_name, ':language' => $current_language, ':langcode' => $langcode])); Chris@0: Chris@0: // Language code 'fr' link should not be active. Chris@0: $langcode = 'fr'; Chris@0: $links = $this->xpath('//a[@id = :id and not(contains(@class, :class))]', [':id' => 'fr_link', ':class' => 'is-active']); Chris@0: $this->assertTrue(isset($links[0]), t('A link generated by :function to the current :language page with langcode :langcode is NOT marked active.', [':function' => $function_name, ':language' => $current_language, ':langcode' => $langcode])); Chris@0: Chris@0: // Test links generated by the link generator on a French page. Chris@0: $current_language = 'French'; Chris@0: $this->drupalGet('fr/language_test/type-link-active-class'); Chris@0: Chris@0: // Language code 'none' link should be active. Chris@0: $langcode = 'none'; Chris@0: $links = $this->xpath('//a[@id = :id and contains(@class, :class)]', [':id' => 'no_lang_link', ':class' => 'is-active']); Chris@0: $this->assertTrue(isset($links[0]), t('A link generated by :function to the current :language page with langcode :langcode is marked active.', [':function' => $function_name, ':language' => $current_language, ':langcode' => $langcode])); Chris@0: Chris@0: // Language code 'en' link should not be active. Chris@0: $langcode = 'en'; Chris@0: $links = $this->xpath('//a[@id = :id and not(contains(@class, :class))]', [':id' => 'en_link', ':class' => 'is-active']); Chris@0: $this->assertTrue(isset($links[0]), t('A link generated by :function to the current :language page with langcode :langcode is NOT marked active.', [':function' => $function_name, ':language' => $current_language, ':langcode' => $langcode])); Chris@0: Chris@0: // Language code 'fr' link should be active. Chris@0: $langcode = 'fr'; Chris@0: $links = $this->xpath('//a[@id = :id and contains(@class, :class)]', [':id' => 'fr_link', ':class' => 'is-active']); Chris@0: $this->assertTrue(isset($links[0]), t('A link generated by :function to the current :language page with langcode :langcode is marked active.', [':function' => $function_name, ':language' => $current_language, ':langcode' => $langcode])); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Tests language switcher links for session based negotiation. Chris@0: */ Chris@0: public function testLanguageSessionSwitchLinks() { Chris@0: // Add language. Chris@0: $edit = [ Chris@0: 'predefined_langcode' => 'fr', Chris@0: ]; Chris@0: $this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language')); Chris@0: Chris@0: // Enable session language detection and selection. Chris@0: $edit = [ Chris@0: 'language_interface[enabled][language-url]' => FALSE, Chris@0: 'language_interface[enabled][language-session]' => TRUE, Chris@0: ]; Chris@0: $this->drupalPostForm('admin/config/regional/language/detection', $edit, t('Save settings')); Chris@0: Chris@0: // Enable the language switching block. Chris@0: $this->drupalPlaceBlock('language_block:' . LanguageInterface::TYPE_INTERFACE, [ Chris@0: 'id' => 'test_language_block', Chris@0: ]); Chris@0: Chris@0: // Enable the main menu block. Chris@0: $this->drupalPlaceBlock('system_menu_block:main', [ Chris@0: 'id' => 'test_menu', Chris@0: ]); Chris@0: Chris@0: // Add a link to the homepage. Chris@0: $link = MenuLinkContent::create([ Chris@0: 'title' => 'Home', Chris@0: 'menu_name' => 'main', Chris@0: 'bundle' => 'menu_link_content', Chris@0: 'link' => [['uri' => 'entity:user/2']], Chris@0: ]); Chris@0: $link->save(); Chris@0: Chris@0: // Go to the homepage. Chris@0: $this->drupalGet(''); Chris@0: // Click on the French link. Chris@0: $this->clickLink(t('French')); Chris@0: // There should be a query parameter to set the session language. Chris@0: $this->assertUrl('user/2', ['query' => ['language' => 'fr']]); Chris@0: // Click on the 'Home' Link. Chris@0: $this->clickLink(t('Home')); Chris@0: // There should be no query parameter. Chris@0: $this->assertUrl('user/2'); Chris@0: // Click on the French link. Chris@0: $this->clickLink(t('French')); Chris@0: // There should be no query parameter. Chris@0: $this->assertUrl('user/2'); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Saves the native name of a language entity in configuration as a label. Chris@0: * Chris@0: * @param string $langcode Chris@0: * The language code of the language. Chris@0: * @param string $label Chris@0: * The native name of the language. Chris@0: */ Chris@0: protected function saveNativeLanguageName($langcode, $label) { Chris@0: \Drupal::service('language.config_factory_override') Chris@0: ->getOverride($langcode, 'language.entity.' . $langcode)->set('label', $label)->save(); Chris@0: } Chris@0: Chris@0: }