From: Michael M Slusarz Date: Mon, 29 Dec 2008 21:03:39 +0000 (-0700) Subject: Request #7545 - Translate special folder names. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=d2ef93dc0455c3b2498c005cce1d22a466256f73;p=horde.git Request #7545 - Translate special folder names. --- diff --git a/imp/config/prefs.php.dist b/imp/config/prefs.php.dist index 08df891ac..e357aa3af 100644 --- a/imp/config/prefs.php.dist +++ b/imp/config/prefs.php.dist @@ -273,7 +273,7 @@ $_prefs['sent_mail_folder'] = array( // 3501 [5.1.3]). For Exchange, uncomment the entry below and remove the // default value entry. // 'value' => 'Sent Items', - 'value' => _("Sent"), + 'value' => 'Sent', 'locked' => false, 'shared' => false, 'type' => 'implicit'); @@ -311,7 +311,7 @@ $_prefs['folderselect'] = array('type' => 'special'); $_prefs['drafts_folder'] = array( // The mailbox value must be encoded in the UTF7-IMAP charset (see RFC // 3501 [5.1.3]). - 'value' => _("Drafts"), + 'value' => 'Drafts', 'locked' => false, 'shared' => false, 'type' => 'implicit'); @@ -326,7 +326,7 @@ $_prefs['trash_folder'] = array( // 3501 [5.1.3]). For Exchange, uncomment the entry below and remove the // default value entry. // 'value' => 'Deleted Items', - 'value' => _("Trash"), + 'value' => 'Trash', 'locked' => false, 'shared' => false, 'type' => 'implicit'); @@ -339,7 +339,7 @@ $_prefs['spamselect'] = array('type' => 'special'); $_prefs['spam_folder'] = array( // The mailbox value must be encoded in the UTF7-IMAP charset (see RFC // 3501 [5.1.3]). - 'value' => _("Spam"), + 'value' => 'Spam', 'locked' => false, 'shared' => false, 'type' => 'implicit'); diff --git a/imp/docs/CHANGES b/imp/docs/CHANGES index d2c9dd31c..c77a224f1 100644 --- a/imp/docs/CHANGES +++ b/imp/docs/CHANGES @@ -2,6 +2,7 @@ v5.0-cvs -------- +[mms] Translate special folder names (Request #7545). [mms] Make autocompletion threshold parameters configurable (Request #7322). [mms] Add compose attachment preview to DIMP. [mms] Add 'unit' parameter for quota display (Carlos Pires , diff --git a/imp/lib/IMAP/Tree.php b/imp/lib/IMAP/Tree.php index fd7e80363..990c5235f 100644 --- a/imp/lib/IMAP/Tree.php +++ b/imp/lib/IMAP/Tree.php @@ -383,9 +383,8 @@ class IMP_IMAP_Tree $tmp = explode(is_null($ns_info) ? $this->_delimiter : $ns_info['delimiter'], $elt['v']); $elt['c'] = count($tmp) - 1; - /* Convert label to localized charset & convert 'INBOX' to localized - * name. */ - $elt['l'] = ($elt['v'] == 'INBOX') ? _("Inbox") : String::convertCharset($tmp[$elt['c']], 'UTF7-IMAP'); + /* Get the mailbox label. */ + $elt['l'] = IMP::getLabel($tmp[$elt['c']]); if ($_SESSION['imp']['protocol'] != 'pop') { if ($elt['c'] != 0) { diff --git a/imp/lib/IMP.php b/imp/lib/IMP.php index e1c1ab4a5..1a66eec62 100644 --- a/imp/lib/IMP.php +++ b/imp/lib/IMP.php @@ -469,39 +469,53 @@ class IMP /** * If there is information available to tell us about a prefix in front of * mailbox names that shouldn't be displayed to the user, then use it to - * strip that prefix out. + * strip that prefix out. Additionally, translate prefix text if this + * is one of the folders with special meaning. * * @param string $folder The folder name to display (UTF7-IMAP). * - * @return string The folder, with any prefix gone. + * @return string The folder, with any prefix gone/translated. */ static public function displayFolder($folder) { + global $prefs; + $cache = &self::$_displaycache; if (isset($cache[$folder])) { return $cache[$folder]; } - if ($folder == 'INBOX') { - $cache[$folder] = _("Inbox"); - } else { - $ns_info = $GLOBALS['imp_imap']->getNamespace($folder); - if (!is_null($ns_info) && - !empty($ns_info['name']) && - ($ns_info['type'] == 'personal') && - substr($folder, 0, strlen($ns_info['name'])) == $ns_info['name']) { - $cache[$folder] = substr($folder, strlen($ns_info['name'])); - } elseif (!is_null($ns_info) && - (stripos($folder, 'INBOX' . $ns_info['delimiter']) === 0)) { - $cache[$folder] = _("Inbox") . substr($folder, 5); - } else { - $cache[$folder] = $folder; + $ns_info = $GLOBALS['imp_imap']->getNamespace($folder); + $delimiter = is_null($ns_info) ? $ns_info['delimiter'] : ''; + + /* Substitute any translated prefix text. */ + $sub_array = array( + 'INBOX' => _("Inbox"), + $prefs->getValue('sent_mail_folder') => _("Sent"), + $prefs->getValue('drafts_folder') => _("Drafts"), + $prefs->getValue('trash_folder') => _("Trash"), + $prefs->getValue('spam_folder') => _("Spam") + ); + + foreach ($sub_array as $key => $val) { + if (stripos($folder, $key . $delimiter) === 0) { + return $val . String::convertCharset(substr($folder, strlen($key)), 'UTF7-IMAP'); } + } - $cache[$folder] = String::convertCharset($cache[$folder], 'UTF7-IMAP'); + /* Strip namespace information. */ + if (!is_null($ns_info) && + !empty($ns_info['name']) && + ($ns_info['type'] == 'personal') && + substr($folder, 0, strlen($ns_info['name'])) == $ns_info['name']) { + $out = substr($folder, strlen($ns_info['name'])); + } else { + $out = $folder; } + $cache[$folder] = String::convertCharset($out, 'UTF7-IMAP'); + return $cache[$folder]; }