diff --git a/core/modules/locale/lib/Drupal/locale/Tests/LocalePluralFormatTest.php b/core/modules/locale/lib/Drupal/locale/Tests/LocalePluralFormatTest.php index a5ed01ba28cc9db30305f2a32a1fe5004ddd77f1..589b210199742aa7bf7f92ff29cd25d6dff06db3 100644 --- a/core/modules/locale/lib/Drupal/locale/Tests/LocalePluralFormatTest.php +++ b/core/modules/locale/lib/Drupal/locale/Tests/LocalePluralFormatTest.php @@ -86,8 +86,8 @@ function testGetPluralFormat() { // English, but it will always pick the plural form as per the built-in // logic, so only index -1 is relevant with the plural value. 'hu' => array( - 0 => '1 hour', - -1 => '@count hours', + 0 => "\xE2\x80\xAA1 hour\xE2\x80\xAC", + -1 => "\xE2\x80\xAA@count hours\xE2\x80\xAC", ), ); diff --git a/core/modules/locale/locale.module b/core/modules/locale/locale.module index 75e0a223c4db270b0d4f70d21acee7377a60d75c..54346e70d2819af7e4ca8ffb96bf264029c7cb14 100644 --- a/core/modules/locale/locale.module +++ b/core/modules/locale/locale.module @@ -142,6 +142,16 @@ const LOCALE_TRANSLATION_IMPORTED = 'import'; /** + * Invisible code character U+202A for left-to-right text. + */ +const LOCALE_LEFT_TO_RIGHT_MARK = "\xE2\x80\xAA"; + +/** + * Invisible code character U+202C to pop last text directionality. + */ +const LOCALE_POP_DIRECTION_MARK = "\xE2\x80\xAC"; + +/** * Implements hook_help(). */ function locale_help($path, $arg) { @@ -396,7 +406,13 @@ function locale($string = NULL, $context = NULL, $langcode = NULL) { if (!isset($locale_t[$langcode][$context]) && isset($language_interface)) { $locale_t[$langcode][$context] = new LocaleLookup($langcode, $context, locale_storage()); } - return ($locale_t[$langcode][$context][$string] === TRUE ? $string : $locale_t[$langcode][$context][$string]); + + + if ($locale_t[$langcode][$context][$string] === TRUE) { + return LOCALE_LEFT_TO_RIGHT_MARK . str_replace(LOCALE_PLURAL_DELIMITER, LOCALE_POP_DIRECTION_MARK . LOCALE_PLURAL_DELIMITER . LOCALE_LEFT_TO_RIGHT_MARK, $string) . LOCALE_POP_DIRECTION_MARK; + } + + return $locale_t[$langcode][$context][$string]; } /**