Skip to content

Commit

Permalink
MDL-78983 core: Fix question mark icon direction flipping
Browse files Browse the repository at this point in the history
This fixes the changes made in MDL-75047:
* Change `thisicondirection` langconfig string to a more specific one
  like `questionicondirection`.
* Use existing direction string value `ltr` for the value of
  `questionicondirection`. Also add a comment to at least provide some
  form of documentation for it.
* Improve the logic for applying the horizontal flipping class for the
  question icon:
  - Check first if the icon is a question icon
  - Flip the icon if `questionicondirection` is set to `rtl`.
  • Loading branch information
junpataleta committed Aug 11, 2023
1 parent 57ae65f commit 001b299
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
3 changes: 2 additions & 1 deletion lang/en/langconfig.php
Expand Up @@ -41,6 +41,8 @@
$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';
$string['strftimedate'] = '%d %B %Y';
$string['strftimedatemonthabbr'] = '%d %b %Y';
$string['strftimedatemonthtimeshort'] = '%d %b %Y, %I:%M';
Expand All @@ -64,7 +66,6 @@
$string['strftimetime24'] = '%H:%M';
$string['thisdirection'] = 'ltr';
$string['thisdirectionvertical'] = 'btt';
$string['thisicondirection'] = 'standard';
$string['thislanguage'] = 'English';
$string['thislanguageint'] = 'English';
$string['thousandssep'] = ',';
5 changes: 2 additions & 3 deletions lib/classes/output/icon_system_fontawesome.php
Expand Up @@ -501,9 +501,8 @@ public function render_pix_icon(renderer_base $output, pix_icon $icon) {
$data['aria-hidden'] = $icon->attributes['aria-hidden'];
}

// Define the orientation of the question mark in right-to-left languages.
$mirror = get_string('thisicondirection', 'langconfig');
if ($mirror == 'mirror' && (strpos($data['key'], 'fa-question') !== false)) {
// 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') {
$data['extraclasses'] = "fa-flip-horizontal";
}

Expand Down

0 comments on commit 001b299

Please sign in to comment.