Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
LanguageInterface::DIRECTION_RTL and LanguageInterface::DIRECTION_LTR
are a clear and useful constants.
BUT but they are not used in all places.
Most notably in Drupal\Core\Language\Language
public static $defaultValues = array(
'id' => 'en',
'name' => 'English',
'direction' => 0, <--- this should read self::DIRECTION_LTR
'weight' => 0,
'locked' => 0,
'default' => TRUE,
);
Proposed resolution
consistently use the constants a cursory search for " 'direction' => "
show that several files need to be updated. Language.php, ConfigOverrideWebTest, ConfigTranslationUiTest.php, LanguageDependancyInjecitonTest.php
and many more
Remaining tasks
A more exhaustive search for places where the constants should be used.
The fix is obvious.
User interface changes
none
API changes
none
Comment | File | Size | Author |
---|---|---|---|
#2 | interdiff-1-2.txt | 1.47 KB | martin107 |
#2 | direction-2286403-2.patch | 14.52 KB | martin107 |
#1 | direction-2286403-1.patch | 13.05 KB | martin107 |
Comments
Comment #1
martin107 CreditAttribution: martin107 commentedThe following files were updated.
core/lib/Drupal/Core/Language/Language.php
core/modules/language/src/Tests/Condition/LanguageConditionTest.php
core/modules/language/src/Tests/LanguageDependencyInjectionTest.php
core/modules/language/src/Tests/LanguageListTest.php
core/modules/locale/src/Tests/LocaleConfigTranslationTest.php
core/modules/locale/src/Tests/LocaleContentTest.php
core/modules/locale/src/Tests/LocaleImportFunctionalTest.php
core/modules/locale/src/Tests/LocaleLocaleLookupTest.php
core/modules/locale/src/Tests/LocalePathTest.php
core/modules/locale/src/Tests/LocaleTranslationUiTest.php
core/modules/locale/src/Tests/LocaleUpdateTest.php
core/modules/system/src/Tests/Theme/TwigTransTest.php
core/modules/toolbar/src/Tests/ToolbarAdminMenuTest.php
core/modules/user/src/Tests/UserAdminLanguageTest.php
core/modules/user/src/Tests/UserLanguageTest.php
Comment #2
martin107 CreditAttribution: martin107 commentedFound 2 more
Comment #3
tstoecklerAwesome detective work, @martin107!
Nothing to complain.
Also shameless bump: #2070737: Change values of LanguageInterface::DIRECTION_(LTR/RTL) to ('ltr'/'rtl')
Comment #4
Dries CreditAttribution: Dries commentedNice clean-up. Committed to 8.x. Thank you.