Change $language_name to $text['language-name'] this will follow current naming standards in app_languages.php and reduces code needed in the text class.

This commit is contained in:
markjcrane
2016-03-12 22:06:57 -07:00
parent ed2898aa33
commit afe19e8a40
2 changed files with 25 additions and 42 deletions
+14 -25
View File
@@ -1,31 +1,20 @@
<?php <?php
// Fill in the value in the native language //language
// rename the corerct flag in /theme/flags/*.png $text['language-name']['en-us'] = "English - United States";
$text['language-name']['es-cl'] = "Español - Chile";
$language_name['en-us'] = "English - United States"; $text['language-name']['pt-pt'] = "Português - Portugal";
$language_name['es-cl'] = "Español - Chile"; $text['language-name']['fr-fr'] = "Français - France";
$language_name['pt-pt'] = "Português - Portugal"; $text['language-name']['nl-nl'] = "Nederlands - De Nederland";
$language_name['fr-fr'] = "Français - France"; $text['language-name']['pt-br'] = "Brasileiro - Português";
$language_name['nl-nl'] = "Nederlands - De Nederland"; $text['language-name']['pl'] = "Polski - Polska";
$language_name['pt-br'] = "Brasileiro - Português"; $text['language-name']['sv-se'] = "Svenska - Sverige";
$language_name['pl'] = "Polski - Polska"; $text['language-name']['uk'] = "Українська - Україна";
$language_name['sv-se'] = "Svenska - Sverige"; $text['language-name']['de-at'] = "Deutsch - Österreich";
$language_name['uk'] = "Українська - Україна"; $text['language-name']['ar-eg'] = "العربية - مصر";
$language_name['de-at'] = "Deutsch - Österreich"; $text['language-name']['ru-ru'] = 'Русский - Россия';
$language_name['ar-eg'] = "العربية - مصر";
$language_name['ru-ru'] = 'Русский - Россия';
// pl should be pl-pl
// ro should be ro-ro
// uk should be uk-ua
// he should be he-il
// Common terms
//message //message
$text['message-update']['en-us'] = "Update Completed"; $text['message-update']['en-us'] = "Update Completed";
$text['message-update']['es-cl'] = "Actualización Completada"; $text['message-update']['es-cl'] = "Actualización Completada";
$text['message-update']['pt-pt'] = "Actualização Efectuada"; $text['message-update']['pt-pt'] = "Actualização Efectuada";
@@ -95,7 +84,7 @@ $text['message-failed']['pt-pt'] = "Falha na atualiza玢o - Contato com o suport
$text['message-failed']['fr-fr'] = "Mise ?jour a 閏hou?- Contacter le support technique"; $text['message-failed']['fr-fr'] = "Mise ?jour a 閏hou?- Contacter le support technique";
$text['message-failed']['pt-br'] = "Falha na atualiza莽茫o - Entre em contato com o suporte"; $text['message-failed']['pt-br'] = "Falha na atualiza莽茫o - Entre em contato com o suporte";
$text['message-failed']['pl'] = "Aktualizacja nie powiod艂a si臋 - skontaktuj si臋 z pomoc膮"; $text['message-failed']['pl'] = "Aktualizacja nie powiod艂a si臋 - skontaktuj si臋 z pomoc膮";
$text['message-failed']['uk'] = "袧械 胁写邪谢芯褋褟 芯薪芯胁懈褌懈 - 蟹胁'褟卸褨褌褜褋褟 蟹褨 褋谢褍卸斜芯褞 锌褨写褌褉懈屑泻懈"; $text['message-failed']['uk'] = ""
$text['message-failed']['sv-se'] = "Uppdatering Misslyckades - Kontakta Support"; $text['message-failed']['sv-se'] = "Uppdatering Misslyckades - Kontakta Support";
$text['message-failed']['de-at'] = "Aktualisierung fehlgeschlagen - Kontaktieren Sie den Support"; $text['message-failed']['de-at'] = "Aktualisierung fehlgeschlagen - Kontaktieren Sie den Support";
+11 -17
View File
@@ -30,9 +30,10 @@ class text {
*/ */
public function get($language_code = null, $app_path = null, $exclude_global = false) { public function get($language_code = null, $app_path = null, $exclude_global = false) {
//get the global app_languages.php //get the global app_languages.php
if(!$exclude_global){ if (!$exclude_global){
include $_SERVER["PROJECT_ROOT"]."/resources/app_languages.php"; include $_SERVER["PROJECT_ROOT"]."/resources/app_languages.php";
} }
//get the app_languages.php //get the app_languages.php
if ($app_path != null) { if ($app_path != null) {
$lang_path = $_SERVER["PROJECT_ROOT"]."/".$app_path."/app_languages.php"; $lang_path = $_SERVER["PROJECT_ROOT"]."/".$app_path."/app_languages.php";
@@ -43,6 +44,7 @@ class text {
if(file_exists($lang_path)){ if(file_exists($lang_path)){
require $lang_path; require $lang_path;
} }
//get the available languages //get the available languages
krsort($text); krsort($text);
foreach ($text as $lang_label => $lang_codes) { foreach ($text as $lang_label => $lang_codes) {
@@ -53,37 +55,29 @@ class text {
} }
} }
$_SESSION['app']['languages'] = array_unique($app_languages); $_SESSION['app']['languages'] = array_unique($app_languages);
//check the session language //check the session language
if(isset($_SESSION['domain']) and $language_code == null){ if (isset($_SESSION['domain']) and $language_code == null){
$language_code = $_SESSION['domain']['language']['code']; $language_code = $_SESSION['domain']['language']['code'];
}elseif($language_code == null){ } elseif ($language_code == null){
$language_code = 'en-us'; $language_code = 'en-us';
} }
//reduce to specific language //reduce to specific language
if ($language_code != 'all') { if ($language_code != 'all') {
foreach($text as $key => $value) { foreach ($text as $key => $value) {
if(strlen($value[$language_code]) > 0) { if (strlen($value[$language_code]) > 0) {
$text[$key] = $value[$language_code]; $text[$key] = $value[$language_code];
}else{ } else {
//fallback to en-us //fallback to en-us
$text[$key] = $value['en-us']; $text[$key] = $value['en-us'];
} }
} }
} }
if ($language_code != 'all') {
foreach($language_name as $code => $value) {
$text["language-$code"] = $value;
}
}else{
foreach($language_name as $code => $value) {
foreach($language_name as $c_code => $value) {
$text["language-$code"][$c_code] = $value;
}
}
}
//return the array of translations //return the array of translations
return $text; return $text;
} }
} }
?> ?>