summaryrefslogtreecommitdiffstatshomepage
path: root/core/modules/language
diff options
context:
space:
mode:
Diffstat (limited to 'core/modules/language')
-rw-r--r--core/modules/language/language.module9
-rw-r--r--core/modules/language/src/Hook/LanguageThemeHooks.php22
-rw-r--r--core/modules/language/tests/src/Functional/LanguageSwitchingTest.php4
-rw-r--r--core/modules/language/tests/src/Kernel/Condition/LanguageConditionTest.php4
-rw-r--r--core/modules/language/tests/src/Kernel/Migrate/d7/MigrateLanguageContentSettingsTest.php2
5 files changed, 27 insertions, 14 deletions
diff --git a/core/modules/language/language.module b/core/modules/language/language.module
index fb9420037db..2d65dc70365 100644
--- a/core/modules/language/language.module
+++ b/core/modules/language/language.module
@@ -127,15 +127,6 @@ function language_negotiation_url_prefixes_update(): void {
}
/**
- * Implements hook_preprocess_HOOK() for block templates.
- */
-function language_preprocess_block(&$variables): void {
- if ($variables['configuration']['provider'] == 'language') {
- $variables['attributes']['role'] = 'navigation';
- }
-}
-
-/**
* Returns language mappings between browser and Drupal language codes.
*
* @return array
diff --git a/core/modules/language/src/Hook/LanguageThemeHooks.php b/core/modules/language/src/Hook/LanguageThemeHooks.php
new file mode 100644
index 00000000000..0629f7ff682
--- /dev/null
+++ b/core/modules/language/src/Hook/LanguageThemeHooks.php
@@ -0,0 +1,22 @@
+<?php
+
+namespace Drupal\language\Hook;
+
+use Drupal\Core\Hook\Attribute\Hook;
+
+/**
+ * Hook implementations for language.
+ */
+class LanguageThemeHooks {
+
+ /**
+ * Implements hook_preprocess_HOOK() for block templates.
+ */
+ #[Hook('preprocess_block')]
+ public function preprocessBlock(&$variables): void {
+ if ($variables['configuration']['provider'] == 'language') {
+ $variables['attributes']['role'] = 'navigation';
+ }
+ }
+
+}
diff --git a/core/modules/language/tests/src/Functional/LanguageSwitchingTest.php b/core/modules/language/tests/src/Functional/LanguageSwitchingTest.php
index 32ec3a2c6e5..44beb40d3eb 100644
--- a/core/modules/language/tests/src/Functional/LanguageSwitchingTest.php
+++ b/core/modules/language/tests/src/Functional/LanguageSwitchingTest.php
@@ -356,11 +356,11 @@ class LanguageSwitchingTest extends BrowserTestBase {
/** @var \Drupal\Core\Routing\UrlGenerator $generator */
$generator = $this->container->get('url_generator');
- // Verify the English URL is correct
+ // Verify the English URL is correct.
$english_url = $generator->generateFromRoute('entity.user.canonical', ['user' => 2], ['language' => $languages['en']]);
$this->assertSession()->elementAttributeContains('xpath', '//div[@id="block-test-language-block"]/ul/li/a[@hreflang="en"]', 'href', $english_url);
- // Verify the Italian URL is correct
+ // Verify the Italian URL is correct.
$italian_url = $generator->generateFromRoute('entity.user.canonical', ['user' => 2], ['language' => $languages['it']]);
$this->assertSession()->elementAttributeContains('xpath', '//div[@id="block-test-language-block"]/ul/li/a[@hreflang="it"]', 'href', $italian_url);
}
diff --git a/core/modules/language/tests/src/Kernel/Condition/LanguageConditionTest.php b/core/modules/language/tests/src/Kernel/Condition/LanguageConditionTest.php
index 19a74112e61..6b1949a72aa 100644
--- a/core/modules/language/tests/src/Kernel/Condition/LanguageConditionTest.php
+++ b/core/modules/language/tests/src/Kernel/Condition/LanguageConditionTest.php
@@ -66,7 +66,7 @@ class LanguageConditionTest extends KernelTestBase {
// Check for the proper summary.
$this->assertEquals('The language is Italian.', $condition->summary());
- // Negate the condition
+ // Negate the condition.
$condition->setConfig('negate', TRUE);
$this->assertTrue($condition->execute(), 'Language condition passes as expected.');
// Check for the proper summary.
@@ -89,7 +89,7 @@ class LanguageConditionTest extends KernelTestBase {
// Check for the proper summary.
$this->assertEquals('The language is Italian.', $condition->summary());
- // Negate the condition
+ // Negate the condition.
$condition->setConfig('negate', TRUE);
$this->assertFalse($condition->execute(), 'Language condition fails as expected.');
// Check for the proper summary.
diff --git a/core/modules/language/tests/src/Kernel/Migrate/d7/MigrateLanguageContentSettingsTest.php b/core/modules/language/tests/src/Kernel/Migrate/d7/MigrateLanguageContentSettingsTest.php
index 28da2b80249..da4bd0750c5 100644
--- a/core/modules/language/tests/src/Kernel/Migrate/d7/MigrateLanguageContentSettingsTest.php
+++ b/core/modules/language/tests/src/Kernel/Migrate/d7/MigrateLanguageContentSettingsTest.php
@@ -76,7 +76,7 @@ class MigrateLanguageContentSettingsTest extends MigrateDrupal7TestBase {
$this->assertSame($config->get('default_langcode'), 'und');
// Assert that a content type without a 'language_content_type' variable is
- // not translatable
+ // not translatable.
$config = ContentLanguageSettings::loadByEntityTypeBundle('node', 'book');
$this->assertTrue($config->isDefaultConfiguration());
$this->assertFalse($config->isLanguageAlterable());