User Tools

Site Tools


linux:zarafa_lang

Change default language in Webmail/Outlook

All information is taken from Zarafa Wiki

Make sure you have php-cli and your language pack installed.
The posted Script is only for Version 6.40. There is a newer Version available for SCP 7.
Just visit the Zarafa Wiki

First save the following script as foldernames.php

foldernames.php
#!/usr/bin/php
 
<?
 
$LOCALE_PATH = '/usr/share/locale';
 
function renamefolder($store, $entryid, $name)
{
    if(!$entryid) {
        print("Unable to find $name folder\n");
        return;
    }
 
    $folder = mapi_msgstore_openentry($store, $entryid);
    if(!$folder) {
        print("Unable to open folder " . bin2hex($entryid) . "\n");
        return;
    }
    mapi_setprops($folder, array(PR_DISPLAY_NAME => $name));
 
    if(mapi_last_hresult() != 0)
        print("Unable to rename " . bin2hex($entryid) . " to '$name'\n");
    else
        print("Renamed " . bin2hex($entryid) . " to '$name'\n");
}
 
include('/usr/share/php/mapi/mapi.util.php');
include('/usr/share/php/mapi/mapidefs.php');
include('/usr/share/php/mapi/mapicode.php');
include('/usr/share/php/mapi/mapitags.php');
include('/usr/share/php/mapi/mapiguid.php');
 
 
function translate($lang, $test=0) 
{
  global $LOCALE_PATH;
  putenv("LANGUAGE=$lang");
  bindtextdomain("zarafa", "$LOCALE_PATH");
  if ($test == 0) {
    bind_textdomain_codeset('zarafa', "windows-1252");
  }
  textdomain('zarafa');
  setlocale(LC_ALL,$lang);
  $trans_array["Sent Items"] = _("Sent Items");
  $trans_array["Outbox"] = _("Outbox");
  $trans_array["Deleted Items"] = _("Deleted Items");
  $trans_array["Inbox"] =  _("Inbox");
  $trans_array["Calendar"] = _("Calendar");
  $trans_array["Contacts"] = _("Contacts");
  $trans_array["Drafts"] = _("Drafts");
  $trans_array["Journal"] = _("Journal");
  $trans_array["Notes"] = _("Notes");
  $trans_array["Tasks"] = _("Tasks");
  $trans_array["Junk E-mail"] = _("Junk E-mail");
  return $trans_array;
} 
 
 
 
if(count($argv) != 3) {
    print("Usage: foldernames <useraccount> <language>\n");
    print("\n");
    print("To do a test translation, use:  -t <language>\n");
    print("\n");
    print("A <language> could be: nl_NL.UTF-8\n");
    print("\n");
    exit(2);
}
 
if($argv[1] == "-t") {
  $trans_array=translate($argv[2], 1);
  foreach ($trans_array as $key => $value) {
    echo str_pad($key, 20, " ");
    echo "$value\n";
  } 
  exit(0);
}
 
$session = mapi_logon_zarafa("SYSTEM", "", "file:///var/run/zarafa");
$msgstorestable = mapi_getmsgstorestable($session);
$msgstores = mapi_table_queryallrows($msgstorestable, array(PR_DEFAULT_STORE, PR_ENTRYID));
 
foreach ($msgstores as $row) {
    if($row[PR_DEFAULT_STORE]) {
        $storeentryid = $row[PR_ENTRYID];
    }
}
 
if(!$storeentryid) {
    print "Can't find default store\n";
    exit(1);
}
 
$store = mapi_openmsgstore($session, $storeentryid);
 
if(!$store) {
    print "Unable to open system store\n";
    exit(1);
}
 
$userstoreentryid = mapi_msgstore_createentryid($store, $argv[1]);
if(!$userstoreentryid) {
    print "Unknown user\n";
    exit(1);
}
 
$userstore = mapi_openmsgstore($session, $userstoreentryid);
if(!$userstore) {
    print "Unable to open user store\n";
    exit(1);
}
 
$inbox = mapi_msgstore_getreceivefolder($userstore);
$root = mapi_msgstore_openentry($userstore);
 
$storeprops = mapi_getprops($userstore, array(PR_IPM_SENTMAIL_ENTRYID, PR_IPM_OUTBOX_ENTRYID, PR_IPM_WASTEBASKET_ENTRYID));
$inboxprops = mapi_getprops($inbox, array(PR_ENTRYID, PR_IPM_APPOINTMENT_ENTRYID, PR_IPM_CONTACT_ENTRYID, PR_IPM_DRAFTS_ENTRYID, PR_IPM_JOURNAL_ENTRYID, PR_IPM_NOTE_ENTRYID, PR_IPM_TASK_ENTRYID));
$rootprops = mapi_getprops($root, array(PR_ADDITIONAL_REN_ENTRYIDS));
 
$trans_array = translate($argv[2]);
 
renamefolder($userstore, $storeprops[PR_IPM_SENTMAIL_ENTRYID], $trans_array["Sent Items"]);
renamefolder($userstore, $storeprops[PR_IPM_OUTBOX_ENTRYID], $trans_array["Outbox"]);
renamefolder($userstore, $storeprops[PR_IPM_WASTEBASKET_ENTRYID], $trans_array["Deleted Items"]);
renamefolder($userstore, $inboxprops[PR_ENTRYID], $trans_array["Inbox"]);
renamefolder($userstore, $inboxprops[PR_IPM_APPOINTMENT_ENTRYID], $trans_array["Calendar"]);
renamefolder($userstore, $inboxprops[PR_IPM_CONTACT_ENTRYID], $trans_array["Contacts"]);
renamefolder($userstore, $inboxprops[PR_IPM_DRAFTS_ENTRYID], $trans_array["Drafts"]);
renamefolder($userstore, $inboxprops[PR_IPM_JOURNAL_ENTRYID], $trans_array["Journal"]);
renamefolder($userstore, $inboxprops[PR_IPM_NOTE_ENTRYID], $trans_array["Notes"]);
renamefolder($userstore, $inboxprops[PR_IPM_TASK_ENTRYID], $trans_array["Tasks"]);
renamefolder($userstore, $rootprops[PR_ADDITIONAL_REN_ENTRYIDS][4], $trans_array["Junk E-mail"]);
 
?>

chmod it so you can execute it.

chmod 700 foldernames.php
./foldernames.php [zarafa-user] de_DE.UTF-8

Optionally you can test the script first using the following command:

./foldernames.php -t de_DE.UTF-8

The changes are taken immediately. You don't even need to restart Outlook.

skull 2011/05/11 10:51

linux/zarafa_lang.txt · Last modified: 2011/07/01 13:57 by skull@darktemple.ch