From 88459bba94d3c4eb0174958cb4ca05e98f33973c Mon Sep 17 00:00:00 2001 From: Jun Pataleta Date: Fri, 11 Aug 2023 16:35:10 +0800 Subject: [PATCH] MDL-78983 core: Preserve default behaviour of flipping question icon Introduce a lang string `questioniconfollowlangdirection` that will allow the current behaviour of displaying the question mark icon in RTL languages in the same manner as the current language. --- lang/en/langconfig.php | 6 ++++-- lib/classes/output/icon_system_fontawesome.php | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/lang/en/langconfig.php b/lang/en/langconfig.php index f30a6477ccf..077fa041a03 100644 --- a/lang/en/langconfig.php +++ b/lang/en/langconfig.php @@ -41,8 +41,10 @@ $string['oldcharset'] = 'ISO-8859-1'; $string['parentlanguage'] = ''; $string['pm'] = 'pm'; $string['pmcaps'] = 'PM'; -// Direction of the question mark icon for this language. Set to 'rtl' if the language needs to display it in right-to-left. -$string['questionicondirection'] = 'ltr'; +// Whether the question icon follows the language direction. +// E.g. In some RTL languages, like Arabic, it needs to be set to 'yes' so the question mark is flipped. +// But for Hebrew, the question mark character is not flipped, so it needs to be set to 'no'. +$string['questioniconfollowlangdirection'] = 'yes'; $string['strftimedate'] = '%d %B %Y'; $string['strftimedatemonthabbr'] = '%d %b %Y'; $string['strftimedatemonthtimeshort'] = '%d %b %Y, %I:%M'; diff --git a/lib/classes/output/icon_system_fontawesome.php b/lib/classes/output/icon_system_fontawesome.php index b4582359a4b..84400c68dfb 100644 --- a/lib/classes/output/icon_system_fontawesome.php +++ b/lib/classes/output/icon_system_fontawesome.php @@ -497,8 +497,9 @@ class icon_system_fontawesome extends icon_system_font { $data['aria-hidden'] = $icon->attributes['aria-hidden']; } - // Flip the orientation of the question mark if the value of the `questionicondirection` lang config string is set to `rtl`. - if (strpos($data['key'], 'fa-question') !== false && get_string('questionicondirection', 'langconfig') === 'rtl') { + // Flip question mark icon orientation when the `questioniconfollowlangdirection` lang config string is set to `yes`. + $isquestionicon = strpos($data['key'], 'fa-question') !== false; + if ($isquestionicon && right_to_left() && get_string('questioniconfollowlangdirection', 'langconfig') === 'yes') { $data['extraclasses'] = "fa-flip-horizontal"; }