From ddf7347f5d48d5c8a94f498d1eb547f1452c4fb0 Mon Sep 17 00:00:00 2001 From: Hannes Mannerheim Date: Thu, 18 Jun 2015 14:24:37 +0200 Subject: [PATCH] rtl/ltr setting in language files --- actions/qvitter.php | 21 +++++++++++++++++---- js/qvitter.js | 10 +++++----- locale/ar.json | 1 + locale/ast.json | 1 + locale/ca.json | 1 + locale/de.json | 1 + locale/en.json | 1 + locale/eo.json | 1 + locale/es.json | 1 + locale/es_ahorita.json | 1 + locale/eu.json | 1 + locale/fa.json | 1 + locale/fi.json | 1 + locale/fr.json | 1 + locale/gl.json | 1 + locale/he.json | 1 + locale/ido.json | 1 + locale/it.json | 1 + locale/no.json | 1 + locale/pt_br.json | 1 + locale/sv.json | 1 + locale/zh_cn.json | 1 + locale/zh_tw.json | 1 + 23 files changed, 43 insertions(+), 9 deletions(-) diff --git a/actions/qvitter.php b/actions/qvitter.php index a92867c..d2b8b2c 100644 --- a/actions/qvitter.php +++ b/actions/qvitter.php @@ -242,17 +242,30 @@ class QvitterAction extends ApiAction // scan all files in the locale directory and create a json object with their change date added $available_languages = array_diff(scandir(QVITTERDIR.'/locale'), array('..', '.')); - foreach($available_languages as $lan) { + foreach($available_languages as $lankey=>$lan) { + $lancode = substr($lan,0,strpos($lan,'.')); - print "\n".' "'.$lancode.'": "'.$lan.'?changed='.date('YmdHis',filemtime(QVITTERDIR.'/locale/'.$lan)).'",'; - + // also make an array with all language names, to use for generating menu $languagecodesandnames[$lancode]['english_name'] = Locale::getDisplayLanguage($lancode, 'en'); $languagecodesandnames[$lancode]['name'] = Locale::getDisplayLanguage($lancode, $lancode); if(Locale::getDisplayRegion($lancode, $lancode)) { $languagecodesandnames[$lancode]['name'] .= ' ('.Locale::getDisplayRegion($lancode, $lancode).')'; } - if($lancode == 'es_ahorita') { $languagecodesandnames[$lancode]['name'] = 'español (ahorita)'; } // joke + + // ahorita meme only on quitter.es + if($lancode == 'es_ahorita') { + if($siterootdomain == 'quitter.es') { + $languagecodesandnames[$lancode]['name'] = 'español (ahorita)'; + } + else { + unset($available_languages[$lankey]); + unset($languagecodesandnames[$lancode]); + continue; + } + } + + print "\n".' "'.$lancode.'": "'.$lan.'?changed='.date('YmdHis',filemtime(QVITTERDIR.'/locale/'.$lan)).'",'; } ?> diff --git a/js/qvitter.js b/js/qvitter.js index 098d9e4..594da23 100644 --- a/js/qvitter.js +++ b/js/qvitter.js @@ -333,11 +333,6 @@ $(window).load(function() { window.selectedLanguage = 'en'; } - // if this is a RTL-language, add rtl class to body - if(window.selectedLanguage == 'ar' - || window.selectedLanguage == 'fa') { - $('body').addClass('rtl'); - } // if we already have this version of this language in localstorage, we // use that cached version. we do this because $.ajax doesn't respect caching, it seems @@ -367,6 +362,11 @@ $(window).load(function() { function proceedToSetLanguageAndLogin(data){ window.sL = data; + // if this is a RTL-language, add rtl class to body + if(window.sL.directionality == 'rtl') { + $('body').addClass('rtl'); + } + window.siteTitle = $('head title').html(); // remember this for later use diff --git a/locale/ar.json b/locale/ar.json index 0d058ca..582637e 100644 --- a/locale/ar.json +++ b/locale/ar.json @@ -1,4 +1,5 @@ { + "directionality":"rtl", "languageName": "العربيّة", "loginUsername": "اسم المستخدم أو البريد الإلكترونيّ", "loginPassword": "كلمة المرور", diff --git a/locale/ast.json b/locale/ast.json index 03eac2b..9e4cce7 100644 --- a/locale/ast.json +++ b/locale/ast.json @@ -1,4 +1,5 @@ { + "directionality":"ltr", "languageName": "Asturianu", "loginUsername": "Nome d'usuariu o corréu-e", "loginPassword": "Contraseña", diff --git a/locale/ca.json b/locale/ca.json index 15383c1..6f0bd8f 100644 --- a/locale/ca.json +++ b/locale/ca.json @@ -1,4 +1,5 @@ { + "directionality":"ltr", "languageName": "Català", "loginUsername": "Nom d'usuari o correu electrònic", "loginPassword": "Contrasenya", diff --git a/locale/de.json b/locale/de.json index 91f4f6b..fb3338d 100644 --- a/locale/de.json +++ b/locale/de.json @@ -1,4 +1,5 @@ { + "directionality":"ltr", "languageName": "Deutsch", "loginUsername": "Benutzername oder E-Mail", "loginPassword": "Passwort", diff --git a/locale/en.json b/locale/en.json index 7f77c40..e664274 100644 --- a/locale/en.json +++ b/locale/en.json @@ -1,4 +1,5 @@ { + "directionality":"ltr", "languageName": "English", "loginUsername": "Username or e-mail", "loginPassword": "Password", diff --git a/locale/eo.json b/locale/eo.json index a770adb..cd70869 100644 --- a/locale/eo.json +++ b/locale/eo.json @@ -1,4 +1,5 @@ { + "directionality":"ltr", "languageName": "Esperanto", "loginUsername": "Uzantnomo aŭ retpoŝtadreso", "loginPassword": "Pasvorto", diff --git a/locale/es.json b/locale/es.json index edaef48..17092a7 100644 --- a/locale/es.json +++ b/locale/es.json @@ -1,4 +1,5 @@ { + "directionality":"ltr", "languageName": "Español", "loginUsername": "Nombre de usuario o correo electrónico", "loginPassword": "Contraseña", diff --git a/locale/es_ahorita.json b/locale/es_ahorita.json index b97bf0d..9fe902d 100644 --- a/locale/es_ahorita.json +++ b/locale/es_ahorita.json @@ -1,4 +1,5 @@ { + "directionality":"ltr", "languageName": "Español (ahorita)", "loginUsername": "Nombre de usuario o correo electrónico", "loginPassword": "Contraseña", diff --git a/locale/eu.json b/locale/eu.json index c7bfd4c..2fd47a2 100644 --- a/locale/eu.json +++ b/locale/eu.json @@ -1,4 +1,5 @@ { + "directionality":"ltr", "languageName": "Euskara", "loginUsername": "Erabiltzaile edo emaila", "loginPassword": "Pasahitza", diff --git a/locale/fa.json b/locale/fa.json index 5d093fc..31d6b7b 100644 --- a/locale/fa.json +++ b/locale/fa.json @@ -1,4 +1,5 @@ { + "directionality":"rtl", "languageName": "فارسی", "loginUsername": "شناسه یا ایمیل", "loginPassword": "گذرواژه - رمز عبور", diff --git a/locale/fi.json b/locale/fi.json index c7d4e93..19175e6 100644 --- a/locale/fi.json +++ b/locale/fi.json @@ -1,4 +1,5 @@ { + "directionality":"ltr", "languageName": "Suomi", "loginUsername": "Käyttäjänimi tai sähköposti", "loginPassword": "Salasana", diff --git a/locale/fr.json b/locale/fr.json index c37125f..274b80e 100644 --- a/locale/fr.json +++ b/locale/fr.json @@ -1,4 +1,5 @@ { + "directionality":"ltr", "languageName": "Français", "loginUsername": "Nom d'utilisateur ou e-mail", "loginPassword": "Mot de passe", diff --git a/locale/gl.json b/locale/gl.json index ffc49ce..4117a0e 100644 --- a/locale/gl.json +++ b/locale/gl.json @@ -1,4 +1,5 @@ { + "directionality":"ltr", "languageName": "Galego", "loginUsername": "Nome de usuario ou enderezo electrónico", "loginPassword": "Contrasinal", diff --git a/locale/he.json b/locale/he.json index c013242..7d9240e 100644 --- a/locale/he.json +++ b/locale/he.json @@ -1,4 +1,5 @@ { + "directionality":"rtl", "languageName": "עברית", "loginUsername": "שם משתמש או דוא״ל", "loginPassword": "סיסמה", diff --git a/locale/ido.json b/locale/ido.json index deda488..2357316 100644 --- a/locale/ido.json +++ b/locale/ido.json @@ -1,4 +1,5 @@ { + "directionality":"ltr", "languageName": "Ido", "loginUsername": "Uzantonomo od e-adreso", "loginPassword": "Pasovorto", diff --git a/locale/it.json b/locale/it.json index d25290f..0609e09 100644 --- a/locale/it.json +++ b/locale/it.json @@ -1,4 +1,5 @@ { + "directionality":"ltr", "languageName": "Italiano", "loginUsername": "Nome Utente o indirizzo email", "loginPassword": "Password", diff --git a/locale/no.json b/locale/no.json index f041c19..386c678 100644 --- a/locale/no.json +++ b/locale/no.json @@ -1,4 +1,5 @@ { + "directionality":"ltr", "languageName": "Norsk", "loginUsername": "Brukernavn eller e-Post", "loginPassword": "Passord", diff --git a/locale/pt_br.json b/locale/pt_br.json index 4d671f4..6f9fec6 100644 --- a/locale/pt_br.json +++ b/locale/pt_br.json @@ -1,4 +1,5 @@ { + "directionality":"ltr", "languageName": "Português-Brasil", "loginUsername": "Nome de usuário ou e-mail", "loginPassword": "Senha", diff --git a/locale/sv.json b/locale/sv.json index 78ab9f6..ec38853 100644 --- a/locale/sv.json +++ b/locale/sv.json @@ -1,4 +1,5 @@ { + "directionality":"ltr", "languageName": "Svenska", "loginUsername": "Användarnamn eller mejladress", "loginPassword": "Lösenord", diff --git a/locale/zh_cn.json b/locale/zh_cn.json index 2c26333..4236ee8 100644 --- a/locale/zh_cn.json +++ b/locale/zh_cn.json @@ -1,4 +1,5 @@ { + "directionality":"ltr", "languageName": "简体中文", "loginUsername": "用户名或邮件地址", "loginPassword": "密码", diff --git a/locale/zh_tw.json b/locale/zh_tw.json index 7ec5457..5d1afd3 100644 --- a/locale/zh_tw.json +++ b/locale/zh_tw.json @@ -1,4 +1,5 @@ { + "directionality":"ltr", "languageName": "繁體中文", "loginUsername": "使用者名稱或電子郵件", "loginPassword": "密碼",