From f8eefb4b0414b3b7452270a8e563631419fda285 Mon Sep 17 00:00:00 2001
From: Ben Woodward
Date: Thu, 29 Jul 2021 10:12:34 -0700
Subject: Arabic translation (#143)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* 🇪🇬 add Arabic language
* Update README.md
* :art: centralize lang dir selection
* :bug: hotfix initial direction
Co-authored-by: Ahmed Tarek
---
src/App.js | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
(limited to 'src/App.js')
diff --git a/src/App.js b/src/App.js
index 4e9ee3e..1db0b85 100644
--- a/src/App.js
+++ b/src/App.js
@@ -4,20 +4,20 @@ import logo from '../src/images/wifi.png';
import { Card } from './components/Card';
import './style.css';
+/* List of languages that require RTL direction (alphabetic order). */
+const RTL_LANGUAGES = ['ar', 'fa-IR'];
+
function App() {
const html = document.querySelector('html');
const { t, i18n } = useTranslation();
const changeLanguage = (language) => {
- if (language === 'fa-IR') {
- html.style.direction = 'rtl';
- } else {
- html.style.direction = 'ltr';
- }
+ html.style.direction = RTL_LANGUAGES.includes(language) ? 'rtl' : 'ltr';
i18n.changeLanguage(language);
};
- if (i18n.language === 'fa-IR') {
+ /* handle the edge case of the initial render requiring RTL direction */
+ if (RTL_LANGUAGES.includes(i18n.language)) {
html.style.direction = 'rtl';
}
@@ -52,6 +52,7 @@ function App() {
+
@@ -62,7 +63,7 @@ function App() {
{t('desc.source')}.
-
+
);
}
--
cgit v1.2.3