aboutsummaryrefslogtreecommitdiffstats
path: root/lib.php
diff options
context:
space:
mode:
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);