From be9aacaa5296dfca63fb3a01c2dc52538d1546aa Mon Sep 17 00:00:00 2001
From: Thomas Bruederli <thomas@roundcube.net>
Date: Sat, 17 Nov 2012 12:31:31 -0500
Subject: [PATCH] Bring back lost localization for the about page

---
 program/include/rcube_csv2vcard.php |   33 ++++++++++++++++++++++++++-------
 1 files changed, 26 insertions(+), 7 deletions(-)

diff --git a/program/include/rcube_csv2vcard.php b/program/include/rcube_csv2vcard.php
index bde8198..114d36d 100644
--- a/program/include/rcube_csv2vcard.php
+++ b/program/include/rcube_csv2vcard.php
@@ -21,8 +21,9 @@
 /**
  * CSV to vCard data converter
  *
- * @package Roundcube Framework
- * @author  Aleksander Machniak <alec@alec.pl>
+ * @package    Framework
+ * @subpackage Addressbook
+ * @author     Aleksander Machniak <alec@alec.pl>
  */
 class rcube_csv2vcard
 {
@@ -229,8 +230,9 @@
         'work_zipcode'      => "Work ZipCode",
     );
 
+    protected $local_label_map = array();
     protected $vcards = array();
-    protected $map    = array();
+    protected $map = array();
 
 
     /**
@@ -247,11 +249,12 @@
             }
 
             if (!empty($map)) {
-                $this->label_map = array_merge($this->label_map, $map);
+                $this->local_label_map = array_merge($this->label_map, $map);
             }
         }
 
         $this->label_map = array_flip($this->label_map);
+        $this->local_label_map = array_flip($this->local_label_map);
     }
 
     /**
@@ -307,13 +310,29 @@
      * Parse CSV header line, detect fields mapping
      */
     protected function parse_header($elements)
-     {
-        for ($i = 0, $size = count($elements); $i<$size; $i++) {
+    {
+        $map1 = array();
+        $map2 = array();
+        $size = count($elements);
+
+        // check English labels
+        for ($i = 0; $i < $size; $i++) {
             $label = $this->label_map[$elements[$i]];
             if ($label && !empty($this->csv2vcard_map[$label])) {
-                $this->map[$i] = $this->csv2vcard_map[$label];
+                $map1[$i] = $this->csv2vcard_map[$label];
             }
         }
+        // check localized labels
+        if (!empty($this->local_label_map)) {
+            for ($i = 0; $i < $size; $i++) {
+                $label = $this->local_label_map[$elements[$i]];
+                if ($label && !empty($this->csv2vcard_map[$label])) {
+                    $map2[$i] = $this->csv2vcard_map[$label];
+                }
+            }
+        }
+
+        $this->map = count($map1) >= count($map2) ? $map1 : $map2;
     }
 
     /**

--
Gitblit v1.9.1