From 9cfcb4bb32e2fb8f5dbabd7faa06e47adf1c23af Mon Sep 17 00:00:00 2001 From: Antonio Gallo Date: Sun, 4 Dec 2011 19:07:42 +0000 Subject: improved i18n --- .../Controllers/AcquisitioncardsController.php | 3 +++ .../Application/Controllers/GenericController.php | 27 +++++++++++++++------- h-source/Application/Include/languages.php | 7 ++++++ h-source/Application/Include/myFunctions.php | 16 +++++++++++++ h-source/Application/Models/GenericModel.php | 26 ++++++++------------- .../Views/Acquisitioncards/catalogue.php | 14 ++++------- h-source/Application/Views/page.php | 8 +++---- 7 files changed, 63 insertions(+), 38 deletions(-) (limited to 'h-source/Application') diff --git a/h-source/Application/Controllers/AcquisitioncardsController.php b/h-source/Application/Controllers/AcquisitioncardsController.php index 08e99f0..f908d8e 100644 --- a/h-source/Application/Controllers/AcquisitioncardsController.php +++ b/h-source/Application/Controllers/AcquisitioncardsController.php @@ -66,6 +66,9 @@ class AcquisitioncardsController extends GenericController $data['intefaceOptions'] = $interfaceOptions; $data['worksOptions'] = $worksOptions; $data['worksField'] = $worksField; + + $data['notFoundString'] = "No acquisition card found"; + $this->append($data); } diff --git a/h-source/Application/Controllers/GenericController.php b/h-source/Application/Controllers/GenericController.php index 639faa5..3a8c1f0 100644 --- a/h-source/Application/Controllers/GenericController.php +++ b/h-source/Application/Controllers/GenericController.php @@ -34,23 +34,29 @@ class GenericController extends BaseController $popup = new Popup(); $popup->name = gtext('sort by'); + + $popNames = array(gtext('last inserted'),gtext('alphabetically'),gtext('alphabetically desc'),gtext('compatibility')); + $popValues = array('last-inserted','alphabetically','alphabetically-desc','compatibility'); + switch ($this->controller) { case 'printers': - $popup->itemsName = array('last inserted','alphabetically','alphabetically desc','compatibility'); - $popup->itemsValue = array('last-inserted','alphabetically','alphabetically-desc','compatibility'); + $popup->itemsName = $popNames; + $popup->itemsValue = $popValues; break; case 'notebooks': - $popup->itemsName = array('last inserted','alphabetically','alphabetically desc','compatibility'); - $popup->itemsValue = array('last-inserted','alphabetically','alphabetically-desc','compatibility'); + $popup->itemsName = $popNames; + $popup->itemsValue = $popValues; break; case 'scanners': - $popup->itemsName = array('last inserted','alphabetically','alphabetically desc','compatibility'); - $popup->itemsValue = array('last-inserted','alphabetically','alphabetically-desc','compatibility'); + $popup->itemsName = $popNames; + $popup->itemsValue = $popValues; break; default: - $popup->itemsName = array('last inserted','alphabetically','alphabetically desc'); - $popup->itemsValue = array('last-inserted','alphabetically','alphabetically-desc'); + array_pop($popNames); + array_pop($popValues); + $popup->itemsName = $popNames; + $popup->itemsValue = $popValues; break; } @@ -445,6 +451,9 @@ class GenericController extends BaseController $popup['sort-by'] = $this->orderPopup; $this->helper('Popup',$this->controller.'/catalogue/'.$this->lang,$popup,'inclusive','page'); + + $this->h['Popup']->allString = gtext("All"); + //create the HTML of the popup $data['popup'] = $this->h['Popup']->render(); @@ -474,6 +483,8 @@ class GenericController extends BaseController $data['pageList'] = $this->h['Pages']->render($page-3,7); $data['topNotice'] = $this->getModule(array('devices',$this->controller,'catalogue')); + + $data['popupLabel'] = $this->mod->getPopupLabel($this->viewArgs); $this->append($data); diff --git a/h-source/Application/Include/languages.php b/h-source/Application/Include/languages.php index 6f1fac4..ecd7318 100644 --- a/h-source/Application/Include/languages.php +++ b/h-source/Application/Include/languages.php @@ -335,6 +335,13 @@ class Lang /*0287*/"November" => "novembre", /*0288*/"December" => "dicembre", /*0289*/"not-specified" => "non specificato", + /*0290*/"last-inserted" => "ultimo inserito", + /*0291*/"last inserted" => "ultimo inserito", + /*0292*/"alphabetically" => "alfabeticamente", + /*0293*/"alphabetically-desc" => "alfabeticamente decresc", + /*0294*/"alphabetically desc" => "alfabeticamente decresc", + /*0295*/"undef" => "tutti", + /*0296*/"All" => "Tutti", ), 'es' => array ( diff --git a/h-source/Application/Include/myFunctions.php b/h-source/Application/Include/myFunctions.php index bb7aa5f..e90a163 100644 --- a/h-source/Application/Include/myFunctions.php +++ b/h-source/Application/Include/myFunctions.php @@ -451,4 +451,20 @@ function getDiffArray($associativeArray, $oldArray, $newArray) } } return $diffArray; +} + +//get the translation function +function getTranslationFunction($fieldName) +{ + $fieldsFunc = array( + "vendor" => "betterVendor", + "interface" => "translate", + ); + + if (array_key_exists($fieldName,$fieldsFunc)) + { + return $fieldsFunc[$fieldName]; + } + + return "gtext"; } \ No newline at end of file diff --git a/h-source/Application/Models/GenericModel.php b/h-source/Application/Models/GenericModel.php index 002149b..64f24be 100644 --- a/h-source/Application/Models/GenericModel.php +++ b/h-source/Application/Models/GenericModel.php @@ -72,33 +72,25 @@ class GenericModel extends Model_Tree { { foreach ($this->_popupItemNames as $name => $field) { - $this->_popupFunctions[$name] = $this->getTranslationFunction($name); + $this->_popupFunctions[$name] = getTranslationFunction($name); } } + //get the HTML of the popup labels public function getPopupLabel($viewArgs) { $html = null; + $listArray = array('page','history_page'); + foreach ($viewArgs as $field => $value) { - $html .= "
$value
\n"; + if (!in_array($field,$listArray)) + { + $value = getTranslationFunction($field) !== 'gtext' ? gtext(call_user_func(getTranslationFunction($field),$value)) : gtext($value); + $html .= "
".$value."
\n"; + } } return $html; } - //get the translation function - public function getTranslationFunction($fieldName) - { - $fieldsFunc = array( - "vendor" => "betterVendor", - "interface" => "translate", - ); - - if (array_key_exists($fieldName,$fieldsFunc)) - { - return $fieldsFunc[$fieldName]; - } - - return "gtext"; - } } \ No newline at end of file diff --git a/h-source/Application/Views/Acquisitioncards/catalogue.php b/h-source/Application/Views/Acquisitioncards/catalogue.php index f9d86d7..23ce477 100644 --- a/h-source/Application/Views/Acquisitioncards/catalogue.php +++ b/h-source/Application/Views/Acquisitioncards/catalogue.php @@ -25,18 +25,14 @@
-
viewArgs['vendor'])?>
-
viewArgs['comm_year']?>
-
viewArgs['compatibility']?>
-
viewArgs['interface']?>
-
viewArgs['sort-by']?>
+
- .. + ..
@@ -62,17 +58,17 @@
:
-
+
:
-
+
-
+