Added Arabic language support in CP

This commit is contained in:
Pinga 2025-01-29 12:53:42 +02:00
parent bb050b170e
commit 9b57cc60af
6 changed files with 1563 additions and 17 deletions

View file

@ -88,7 +88,7 @@ $container->set('view', function ($container) {
]);
// Known set of languages
$allowedLanguages = ['en_US', 'uk_UA', 'jp_JP', 'fr_FR', 'pt_PT', 'es_ES']; // Add more as needed
$allowedLanguages = ['en_US', 'uk_UA', 'jp_JP', 'fr_FR', 'pt_PT', 'es_ES', 'ar_SA'];
if (isset($_SESSION['_lang']) && in_array($_SESSION['_lang'], $allowedLanguages)) {
// Use regex to validate the format: two letters, underscore, two letters
@ -111,6 +111,8 @@ $container->set('view', function ($container) {
$lang = '日本語';
} elseif ($uiLang === 'ua') {
$lang = 'Українська';
} elseif ($uiLang === 'ar') {
$lang = 'العربية';
} else {
$lang = ucfirst(trim(strstr($lang_full, ' (', true)));
}
@ -126,6 +128,7 @@ $container->set('view', function ($container) {
$view->getEnvironment()->addGlobal('uiLang', $uiLang);
$view->getEnvironment()->addGlobal('lang', $lang);
$view->getEnvironment()->addGlobal('_lang', substr($desiredLanguage, 0, 2));
$view->getEnvironment()->addGlobal('flash', $container->get('flash'));
$staticDir = '/var/www/cp/public/static';

1506
cp/lang/ar_SA/messages.po Normal file

File diff suppressed because it is too large Load diff

View file

@ -1,5 +1,5 @@
<!doctype html>
<html lang="en">
<html lang="{{ _lang ?: 'en' }}" dir="{{ _lang == 'ar' or _lang == 'ar_SA' ? 'rtl' : 'ltr' }}">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover"/>
@ -7,18 +7,6 @@
<title>{% block title %}{% endblock %} | Namingo</title>
<!-- CSS files -->
{% if route_is('domains') or route_is('applications') or route_is('contacts') or route_is('hosts') or route_is('epphistory') or route_is('registrars') or route_is('transactions') or route_is('overview') or route_is('reports') or route_is('transfers') or route_is('users') or is_current_url('ticketview') or route_is('poll') or route_is('log') or route_is('invoices') or route_is('registry/tlds') or route_is('profile') %}{% include 'partials/css-tables.twig' %}{% else %}{% include 'partials/css.twig' %}{% endif %}
<style>
@import url('/assets/fonts/inter/inter.css');
:root {
--tblr-font-sans-serif: "Inter", -apple-system, BlinkMacSystemFont, San Francisco, Segoe UI, Roboto, Helvetica Neue, sans-serif;
}
@supports (font-variation-settings: normal) {
:root {
--tblr-font-sans-serif: "InterVariable", -apple-system, BlinkMacSystemFont, San Francisco, Segoe UI, Roboto, Helvetica Neue, sans-serif;
font-optical-sizing: auto;
}
}
</style>
</head>
<body{% if screen_mode == 'dark' %} data-bs-theme="dark"{% endif %}>
<div class="page">
@ -45,6 +33,7 @@
<a href="/lang?es_ES" class="dropdown-item"><span class="flag flag-country-es"></span>&nbsp;Español</a>
<a href="/lang?pt_PT" class="dropdown-item"><span class="flag flag-country-pt"></span>&nbsp;Português</a>
<a href="/lang?jp_JP" class="dropdown-item"><span class="flag flag-country-jp"></span>&nbsp;日本語</a>
<a href="/lang?ar_SA" class="dropdown-item"><span class="flag flag-country-sa"></span>&nbsp;العربية</a>
</div>
</div>
</div>

View file

@ -1,7 +1,14 @@
{% if _lang == 'ar' or _lang == 'ar_SA' %}
<link href="/assets/css/tabler.rtl.min.css" rel="stylesheet"/>
<link href="/assets/css/tabler-flags.rtl.min.css" rel="stylesheet"/>
<link href="/assets/css/tabler-payments.rtl.min.css" rel="stylesheet"/>
<link href="/assets/css/tabler-vendors.rtl.min.css" rel="stylesheet"/>
{% else %}
<link href="/assets/css/tabler.min.css" rel="stylesheet"/>
<link href="/assets/css/tabler-flags.min.css" rel="stylesheet"/>
<link href="/assets/css/tabler-payments.min.css" rel="stylesheet"/>
<link href="/assets/css/tabler-vendors.min.css" rel="stylesheet"/>
{% endif %}
{% if screen_mode == 'dark' %}
<link href="/assets/css/tabulator-dark.min.css" rel="stylesheet">
{% else %}
@ -9,13 +16,30 @@
{% endif %}
<link href="/assets/css/sweetalert2.min.css" rel="stylesheet">
<style>
@import url('/assets/fonts/inter/inter.css');
:root {
--tblr-font-sans-serif: "Inter", -apple-system, BlinkMacSystemFont, San Francisco, Segoe UI, Roboto, Helvetica Neue, sans-serif;
}
@supports (font-variation-settings: normal) {
:root {
--tblr-font-sans-serif: "InterVariable", -apple-system, BlinkMacSystemFont, San Francisco, Segoe UI, Roboto, Helvetica Neue, sans-serif;
font-optical-sizing: auto;
}
}
.small-dropdown .dropdown-item {
padding: 0.25rem 1.5rem;
}
.small-dropdown .flag {
width: 20px;
height: 15px;
display: inline-block;
}
{% if _lang == 'ar' or _lang == 'ar_SA' %}
[dir="rtl"] {
text-align: right;
}
[dir="rtl"] .small-dropdown .dropdown-item {
text-align: right;
}
{% endif %}
</style>

View file

@ -1,15 +1,39 @@
{% if _lang == 'ar' or _lang == 'ar_SA' %}
<link href="/assets/css/tabler.rtl.min.css" rel="stylesheet"/>
<link href="/assets/css/tabler-flags.rtl.min.css" rel="stylesheet"/>
<link href="/assets/css/tabler-payments.rtl.min.css" rel="stylesheet"/>
<link href="/assets/css/tabler-vendors.rtl.min.css" rel="stylesheet"/>
{% else %}
<link href="/assets/css/tabler.min.css" rel="stylesheet"/>
<link href="/assets/css/tabler-flags.min.css" rel="stylesheet"/>
<link href="/assets/css/tabler-payments.min.css" rel="stylesheet"/>
<link href="/assets/css/tabler-vendors.min.css" rel="stylesheet"/>
{% endif %}
<style>
@import url('/assets/fonts/inter/inter.css');
:root {
--tblr-font-sans-serif: "Inter", -apple-system, BlinkMacSystemFont, San Francisco, Segoe UI, Roboto, Helvetica Neue, sans-serif;
}
@supports (font-variation-settings: normal) {
:root {
--tblr-font-sans-serif: "InterVariable", -apple-system, BlinkMacSystemFont, San Francisco, Segoe UI, Roboto, Helvetica Neue, sans-serif;
font-optical-sizing: auto;
}
}
.small-dropdown .dropdown-item {
padding: 0.25rem 1.5rem;
}
.small-dropdown .flag {
width: 20px;
height: 15px;
display: inline-block;
}
{% if _lang == 'ar' or _lang == 'ar_SA' %}
[dir="rtl"] {
text-align: right;
}
[dir="rtl"] .small-dropdown .dropdown-item {
text-align: right;
}
{% endif %}
</style>

View file

@ -230,7 +230,7 @@ To customize the landing page, copy `index.twig` to `index.custom.twig` using `c
To change the default language of the control panel, you must edit the `/var/www/cp/.env` file and replace the language values (`LANG`/`UI_LANG`) with your desired settings.
For the `LANG` variable, the supported values are `en_US`, `uk_UA`, `es_ES`, `pt_PT`, `jp_JP`, and `fr_FR`. For the `UI_LANG` variable, use `us`, `ua`, `es`, `pt`, `jp`, or `fr`.
For the `LANG` variable, the supported values are `en_US`, `uk_UA`, `es_ES`, `pt_PT`, `jp_JP`, `ar_SA`, and `fr_FR`. For the `UI_LANG` variable, use `us`, `ua`, `es`, `pt`, `jp`, `ar`, or `fr`.
To apply your changes, save the file, refresh the control panel, and clear the cache using the following command: `php /var/www/cp/bin/clear_cache.php` The new language settings will take effect immediately.