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 ++++++++------- src/i18n.js | 27 +++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 7 deletions(-) (limited to 'src') 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')}.

- + ); } diff --git a/src/i18n.js b/src/i18n.js index 4c6c500..f816585 100644 --- a/src/i18n.js +++ b/src/i18n.js @@ -397,6 +397,33 @@ const resources = { select: 'Dil Seçin', }, }, + ar: { + translation: { + title: 'بطاقة واي فاي', + 'desc.use': + 'اطبع بطاقة بسيطة تحتوي على تفاصيل تسجيل الدخول إلى شبكة الواي فاي. إلصقه على الثلاجة، اوإحتفظ به في محفظتك.', + 'desc.privacy': + 'لا يتم إرسال معلومات الشبكة الخاصة بك إلى الخادم او اي اماكن اخري. لا يتم استخدام التتبع أو التحليلات أو البصمات الإلكترونية على هذا الموقع. اعرض ملف', + 'desc.source': 'البرنامج', + 'wifi.login': 'تسجيل الدخول', + 'wifi.name': 'إسم الشبكة', + 'wifi.name.placeholder': 'إسم الشبكة', + 'wifi.password': 'كلمه السر', + 'wifi.password.placeholder': 'كلمه السر', + 'wifi.password.hide': 'إخفاء حقل كلمة المرور قبل الطباعة', + 'wifi.password.encryption': 'التشفير', + 'wifi.tip': + 'وجّه كاميرا هاتفك إلى رمز الاستجابة السريعة للاتصال تلقائيًا', + 'wifi.alert.name': 'لا يمكن أن يكون اسم الشبكة فارغًا', + 'wifi.alert.password.length.5': + 'يجب أن تكون كلمة المرور مكونة من ٥ أحرف على الأقل', + 'wifi.alert.password.length.8': + 'يجب أن تكون كلمة المرور مكونة من ٨ أحرف على الأقل', + 'button.rotate': 'تدوير', + 'button.print': 'طباعة', + select: 'اختر لغة', + }, + }, 'hi-IN': { translation: { title: 'वाईफाई कार्ड', -- cgit v1.2.3