aboutsummaryrefslogtreecommitdiffstats
path: root/src/App.js
diff options
context:
space:
mode:
Diffstat (limited to 'src/App.js')
-rw-r--r--src/App.js15
1 files changed, 8 insertions, 7 deletions
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';
4import { Card } from './components/Card'; 4import { Card } from './components/Card';
5import './style.css'; 5import './style.css';
6 6
7/* List of languages that require RTL direction (alphabetic order). */
8const RTL_LANGUAGES = ['ar', 'fa-IR'];
9
7function App() { 10function App() {
8 const html = document.querySelector('html'); 11 const html = document.querySelector('html');
9 const { t, i18n } = useTranslation(); 12 const { t, i18n } = useTranslation();
10 13
11 const changeLanguage = (language) => { 14 const changeLanguage = (language) => {
12 if (language === 'fa-IR') { 15 html.style.direction = RTL_LANGUAGES.includes(language) ? 'rtl' : 'ltr';
13 html.style.direction = 'rtl';
14 } else {
15 html.style.direction = 'ltr';
16 }
17 i18n.changeLanguage(language); 16 i18n.changeLanguage(language);
18 }; 17 };
19 18
20 if (i18n.language === 'fa-IR') { 19 /* handle the edge case of the initial render requiring RTL direction */
20 if (RTL_LANGUAGES.includes(i18n.language)) {
21 html.style.direction = 'rtl'; 21 html.style.direction = 'rtl';
22 } 22 }
23 23
@@ -52,6 +52,7 @@ function App() {
52 <option value="de-DE">German (Germany)</option> 52 <option value="de-DE">German (Germany)</option>
53 <option value="id-ID">Indonesian (Indonesia)</option> 53 <option value="id-ID">Indonesian (Indonesia)</option>
54 <option value="pl-PL">Polish - PL (Polski)</option> 54 <option value="pl-PL">Polish - PL (Polski)</option>
55 <option value="ar">Arabic - العربية</option>
55 </select> 56 </select>
56 </div> 57 </div>
57 58
@@ -62,7 +63,7 @@ function App() {
62 <a href="https://github.com/bndw/wifi-card">{t('desc.source')}</a>. 63 <a href="https://github.com/bndw/wifi-card">{t('desc.source')}</a>.
63 </p> 64 </p>
64 65
65 <Card direction={i18n.language === 'fa-IR' ? 'rtl' : 'ltr'} /> 66 <Card direction={RTL_LANGUAGES.includes(i18n.language) ? 'rtl' : 'ltr'} />
66 </div> 67 </div>
67 ); 68 );
68} 69}