aboutsummaryrefslogtreecommitdiffstats
path: root/lib.php
diff options
context:
space:
mode:
authorfilip <filip.komar@gmail.com>2020-10-03 01:41:40 +0200
committerfilip <filip.komar@gmail.com>2020-10-03 01:41:40 +0200
commit0a858d2e4153328faa5b6cd8830914d55fedd449 (patch)
tree091273e164bc66c87088447c01de86baa9ebbd28 /lib.php
parent51315e355c8c7d8b03e34203e5ea77c5fb51cfd6 (diff)
downloadnav-0a858d2e4153328faa5b6cd8830914d55fedd449.tar
nav-0a858d2e4153328faa5b6cd8830914d55fedd449.tar.gz
nav-0a858d2e4153328faa5b6cd8830914d55fedd449.tar.bz2
nav-0a858d2e4153328faa5b6cd8830914d55fedd449.tar.xz
nav-0a858d2e4153328faa5b6cd8830914d55fedd449.zip
Managing RTL languages changes
Diffstat (limited to 'lib.php')
-rw-r--r--lib.php16
1 files changed, 14 insertions, 2 deletions
diff --git a/lib.php b/lib.php
index 510224d..8d3ae5b 100644
--- a/lib.php
+++ b/lib.php
@@ -75,6 +75,16 @@ $langs = array(
'zh-tw' => '正體中文'
);
+/**
+ * Enables RTL language changes
+ *
+ * Returns TRUE if $locale is RTL
+ */
+function is_locale_rtl($locale)
+{
+ return in_array($locale, array('ar', 'he', 'tg', 'ur'));
+}
+
class NCache
{
function __construct() { }
@@ -328,15 +338,17 @@ function _mgnav_html($wrap = false, $lang = 'en', $inject = null, $vhost = 'www.
$s[] = sprintf('%s', $inject);
$s = implode($s);
+ $links_direction = is_locale_rtl($lang) ? ' dir="rtl"' : '';
+ $links_position = is_locale_rtl($lang) ? 'ml-auto' : 'mr-auto';
$h = sprintf('<!--googleoff: all-->
- <div class="mganav">
+ <div' . $links_direction . ' class="mganav">
<nav id="mgnav" class="container navbar navbar-expand-lg navbar-light">
<a class="navbar-brand text-hide" href="//'. $vhost .'/'. $lang. '">Mageia</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
- <ul class="navbar-nav mr-auto">%s</ul>
+ <ul class="navbar-nav ' . $links_position . '">%s</ul>
</div>
</nav>
</div><!--googleon: all-->', $s);