From 29aab5a214620621057bfb6ef3546fa55b451f22 Mon Sep 17 00:00:00 2001
From: thomascube <thomas@roundcube.net>
Date: Sun, 06 Feb 2011 17:35:39 -0500
Subject: [PATCH] Localize contact property subtypes; better name for contact section

---
 program/steps/addressbook/edit.inc    |    2 +-
 program/steps/addressbook/func.inc    |   20 ++++++++++++++++++--
 program/localization/en_US/labels.inc |   12 ++++++++++++
 program/steps/addressbook/show.inc    |    2 +-
 4 files changed, 32 insertions(+), 4 deletions(-)

diff --git a/program/localization/en_US/labels.inc b/program/localization/en_US/labels.inc
index 66f47f0..58af54f 100644
--- a/program/localization/en_US/labels.inc
+++ b/program/localization/en_US/labels.inc
@@ -274,6 +274,18 @@
 $labels['assistant'] = 'Assistant';
 $labels['spouse'] = 'Spouse';
 
+$labels['typehome']   = 'Home';
+$labels['typework']   = 'Work';
+$labels['typeother']  = 'Other';
+$labels['typemobile']  = 'Mobile';
+$labels['typemain']  = 'Main';
+$labels['typehomefax']  = 'Home Fax';
+$labels['typeworkfax']  = 'Work Fax';
+$labels['typecar']  = 'Car';
+$labels['typepager']  = 'Pager';
+$labels['typevideo']  = 'Video';
+$labels['typeassistant']  = 'Assistant';
+
 $labels['addfield'] = 'Add field...';
 $labels['addcontact'] = 'Add new contact';
 $labels['editcontact'] = 'Edit contact';
diff --git a/program/steps/addressbook/edit.inc b/program/steps/addressbook/edit.inc
index c0d5f0f..932dc49 100644
--- a/program/steps/addressbook/edit.inc
+++ b/program/steps/addressbook/edit.inc
@@ -92,7 +92,7 @@
     $t_cols = !empty($attrib['textareacols']) ? $attrib['textareacols'] : 40;
 
     $form = array(
-        'info' => array(
+        'contact' => array(
             'name'    => rcube_label('contactproperties'),
             'content' => array(
                 'email' => array('size' => $i_size, 'visible' => true),
diff --git a/program/steps/addressbook/func.inc b/program/steps/addressbook/func.inc
index be0c82d..7597fa7 100644
--- a/program/steps/addressbook/func.inc
+++ b/program/steps/addressbook/func.inc
@@ -281,6 +281,20 @@
 }
 
 
+function rcmail_get_type_label($type)
+{
+    $label = 'type'.$type;
+    if (rcube_label_exists($label))
+        return rcube_label($label);
+    else if (preg_match('/\w+(\d+)$/', $label, $m)
+            && ($label = preg_replace('/(\d+)$/', '', $label))
+            && rcube_label_exists($label))
+        return rcube_label($label) . ' ' . $m[1];
+    
+    return ucfirst($type);
+}
+
+
 function rcmail_contact_form($form, $record, $attrib = null)
 {
     global $RCMAIL, $CONFIG;
@@ -324,6 +338,7 @@
         if ($section == 'head') {
             $content = '';
             
+            // TODO: use the save name composition function as in save.inc
             $names_arr = array($record['prefix'], $record['firstname'], $record['middlename'], $record['surname'], $record['suffix']);
             if ($record['name'] == join(' ', array_filter($names_arr)))
               unset($record['name']);
@@ -384,8 +399,9 @@
 
                 // prepare subtype selector in edit mode
                 if ($edit_mode && is_array($colprop['subtypes'])) {
+                    $subtype_names = array_map('rcmail_get_type_label', $colprop['subtypes']);
                     $select_subtype = new html_select(array('name' => '_subtype_'.$col.'[]', 'class' => 'contactselectsubtype'));
-                    $select_subtype->add($colprop['subtypes']);
+                    $select_subtype->add($subtype_names, $colprop['subtypes']);
                 }
                 else
                     $select_subtype = null;
@@ -474,7 +490,7 @@
 
                     // use subtype as label
                     if ($colprop['subtypes'])
-                        $label = $subtype;
+                        $label = rcmail_get_type_label($subtype);
 
                     // add delete button/link
                     if ($edit_mode && !($colprop['visible'] && $colprop['limit'] == 1))
diff --git a/program/steps/addressbook/show.inc b/program/steps/addressbook/show.inc
index 49953fd..f62bad3 100644
--- a/program/steps/addressbook/show.inc
+++ b/program/steps/addressbook/show.inc
@@ -90,7 +90,7 @@
     $i_size = !empty($attrib['size']) ? $attrib['size'] : 40;
 
     $form = array(
-        'info' => array(
+        'contact' => array(
             'name'    => rcube_label('contactproperties'),
             'content' => array(
               'email' => array('size' => $i_size, 'render_func' => 'rcmail_render_email_value'),

--
Gitblit v1.9.1