<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[3325] CalendarServer/trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.macosforge.org/projects/calendarserver/changeset/3325">3325</a></dd>
<dt>Author</dt> <dd>sagen@apple.com</dd>
<dt>Date</dt> <dd>2008-11-05 17:45:12 -0800 (Wed, 05 Nov 2008)</dd>
</dl>

<h3>Log Message</h3>
<pre>Landing localized emails branch</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#CalendarServertrunkconfcaldavdtestplist">CalendarServer/trunk/conf/caldavd-test.plist</a></li>
<li><a href="#CalendarServertrunklocalesenLC_MESSAGEScalendarservermo">CalendarServer/trunk/locales/en/LC_MESSAGES/calendarserver.mo</a></li>
<li><a href="#CalendarServertrunklocalesenLC_MESSAGEScalendarserverpo">CalendarServer/trunk/locales/en/LC_MESSAGES/calendarserver.po</a></li>
<li><a href="#CalendarServertrunktwistedcaldavconfigpy">CalendarServer/trunk/twistedcaldav/config.py</a></li>
<li><a href="#CalendarServertrunktwistedcaldavicalpy">CalendarServer/trunk/twistedcaldav/ical.py</a></li>
<li><a href="#CalendarServertrunktwistedcaldavmailpy">CalendarServer/trunk/twistedcaldav/mail.py</a></li>
<li><a href="#CalendarServertrunktwistedcaldavtesttest_mailpy">CalendarServer/trunk/twistedcaldav/test/test_mail.py</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li>CalendarServer/trunk/locales/</li>
<li>CalendarServer/trunk/locales/en/</li>
<li>CalendarServer/trunk/locales/en/LC_MESSAGES/</li>
<li><a href="#CalendarServertrunksupportmsgfmtpy">CalendarServer/trunk/support/msgfmt.py</a></li>
<li><a href="#CalendarServertrunksupportpygettextpy">CalendarServer/trunk/support/pygettext.py</a></li>
<li>CalendarServer/trunk/twistedcaldav/test/data/locales/</li>
<li>CalendarServer/trunk/twistedcaldav/test/data/locales/en/</li>
<li>CalendarServer/trunk/twistedcaldav/test/data/locales/en/LC_MESSAGES/</li>
<li><a href="#CalendarServertrunktwistedcaldavtestdatalocalesenLC_MESSAGEScalendarservermo">CalendarServer/trunk/twistedcaldav/test/data/locales/en/LC_MESSAGES/calendarserver.mo</a></li>
<li><a href="#CalendarServertrunktwistedcaldavtestdatalocalesenLC_MESSAGEScalendarserverpo">CalendarServer/trunk/twistedcaldav/test/data/locales/en/LC_MESSAGES/calendarserver.po</a></li>
<li>CalendarServer/trunk/twistedcaldav/test/data/locales/pig/</li>
<li>CalendarServer/trunk/twistedcaldav/test/data/locales/pig/LC_MESSAGES/</li>
<li><a href="#CalendarServertrunktwistedcaldavtestdatalocalespigLC_MESSAGEScalendarservermo">CalendarServer/trunk/twistedcaldav/test/data/locales/pig/LC_MESSAGES/calendarserver.mo</a></li>
<li><a href="#CalendarServertrunktwistedcaldavtestdatalocalespigLC_MESSAGEScalendarserverpo">CalendarServer/trunk/twistedcaldav/test/data/locales/pig/LC_MESSAGES/calendarserver.po</a></li>
<li><a href="#CalendarServertrunktwistedcaldavtesttest_localizationpy">CalendarServer/trunk/twistedcaldav/test/test_localization.py</a></li>
</ul>

<h3>Removed Paths</h3>
<ul>
<li>CalendarServer/trunk/locales/en/</li>
<li>CalendarServer/trunk/locales/en/LC_MESSAGES/</li>
<li>CalendarServer/trunk/twistedcaldav/test/data/locales/en/</li>
<li>CalendarServer/trunk/twistedcaldav/test/data/locales/en/LC_MESSAGES/</li>
<li><a href="#CalendarServertrunktwistedcaldavtestdatalocalesenLC_MESSAGEScalendarservermo">CalendarServer/trunk/twistedcaldav/test/data/locales/en/LC_MESSAGES/calendarserver.mo</a></li>
<li><a href="#CalendarServertrunktwistedcaldavtestdatalocalesenLC_MESSAGEScalendarserverpo">CalendarServer/trunk/twistedcaldav/test/data/locales/en/LC_MESSAGES/calendarserver.po</a></li>
<li>CalendarServer/trunk/twistedcaldav/test/data/locales/pig/</li>
<li>CalendarServer/trunk/twistedcaldav/test/data/locales/pig/LC_MESSAGES/</li>
<li><a href="#CalendarServertrunktwistedcaldavtestdatalocalespigLC_MESSAGEScalendarservermo">CalendarServer/trunk/twistedcaldav/test/data/locales/pig/LC_MESSAGES/calendarserver.mo</a></li>
<li><a href="#CalendarServertrunktwistedcaldavtestdatalocalespigLC_MESSAGEScalendarserverpo">CalendarServer/trunk/twistedcaldav/test/data/locales/pig/LC_MESSAGES/calendarserver.po</a></li>
</ul>

<h3>Property Changed</h3>
<ul>
<li><a href="#CalendarServertrunklocalesenLC_MESSAGEScalendarservermo">CalendarServer/trunk/locales/en/LC_MESSAGES/calendarserver.mo</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="CalendarServertrunkconfcaldavdtestplist"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/conf/caldavd-test.plist (3324 => 3325)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/conf/caldavd-test.plist        2008-11-06 01:28:37 UTC (rev 3324)
+++ CalendarServer/trunk/conf/caldavd-test.plist        2008-11-06 01:45:12 UTC (rev 3325)
</span><span class="lines">@@ -638,6 +638,13 @@
</span><span class="cx">       &lt;string&gt;logs/caldavd-pydir.sock&lt;/string&gt;
</span><span class="cx">     &lt;/dict&gt;
</span><span class="cx"> 
</span><ins>+    &lt;key&gt;Localization&lt;/key&gt;
+    &lt;dict&gt;
+      &lt;key&gt;LocalesDirectory&lt;/key&gt;
+      &lt;string&gt;locales&lt;/string&gt;
+      &lt;key&gt;Language&lt;/key&gt;
+      &lt;string&gt;en&lt;/string&gt;
+    &lt;/dict&gt;
</ins><span class="cx"> 
</span><span class="cx">   &lt;/dict&gt;
</span><span class="cx"> &lt;/plist&gt;
</span></span></pre></div>
<a id="CalendarServertrunklocalesenLC_MESSAGEScalendarservermo"></a>
<div class="binary"><h4>Modified: CalendarServer/trunk/locales/en/LC_MESSAGES/calendarserver.mo</h4>
<pre class="diff"><span>
<span class="cx">(Binary files differ)
</span></span></pre></div>
<a id="CalendarServertrunksupportmsgfmtpyfromrev3323CalendarServerbranchesuserssagenlocalization3308supportmsgfmtpy"></a>
<div class="copfile"><h4>Copied: CalendarServer/trunk/support/msgfmt.py (from rev 3323, CalendarServer/branches/users/sagen/localization-3308/support/msgfmt.py) (0 => 3325)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/support/msgfmt.py                                (rev 0)
+++ CalendarServer/trunk/support/msgfmt.py        2008-11-06 01:45:12 UTC (rev 3325)
</span><span class="lines">@@ -0,0 +1,203 @@
</span><ins>+#! /usr/bin/env python
+# -*- coding: iso-8859-1 -*-
+# Written by Martin v. L\xF6wis &lt;loewis@informatik.hu-berlin.de&gt;
+
+&quot;&quot;&quot;Generate binary message catalog from textual translation description.
+
+This program converts a textual Uniforum-style message catalog (.po file) into
+a binary GNU catalog (.mo file).  This is essentially the same function as the
+GNU msgfmt program, however, it is a simpler implementation.
+
+Usage: msgfmt.py [OPTIONS] filename.po
+
+Options:
+    -o file
+    --output-file=file
+        Specify the output file to write to.  If omitted, output will go to a
+        file named filename.mo (based off the input file name).
+
+    -h
+    --help
+        Print this message and exit.
+
+    -V
+    --version
+        Display version information and exit.
+&quot;&quot;&quot;
+
+import sys
+import os
+import getopt
+import struct
+import array
+
+__version__ = &quot;1.1&quot;
+
+MESSAGES = {}
+
+
+
+def usage(code, msg=''):
+    print &gt;&gt; sys.stderr, __doc__
+    if msg:
+        print &gt;&gt; sys.stderr, msg
+    sys.exit(code)
+
+
+
+def add(id, str, fuzzy):
+    &quot;Add a non-fuzzy translation to the dictionary.&quot;
+    global MESSAGES
+    if not fuzzy and str:
+        MESSAGES[id] = str
+
+
+
+def generate():
+    &quot;Return the generated output.&quot;
+    global MESSAGES
+    keys = MESSAGES.keys()
+    # the keys are sorted in the .mo file
+    keys.sort()
+    offsets = []
+    ids = strs = ''
+    for id in keys:
+        # For each string, we need size and file offset.  Each string is NUL
+        # terminated; the NUL does not count into the size.
+        offsets.append((len(ids), len(id), len(strs), len(MESSAGES[id])))
+        ids += id + '\0'
+        strs += MESSAGES[id] + '\0'
+    output = ''
+    # The header is 7 32-bit unsigned integers.  We don't use hash tables, so
+    # the keys start right after the index tables.
+    # translated string.
+    keystart = 7*4+16*len(keys)
+    # and the values start after the keys
+    valuestart = keystart + len(ids)
+    koffsets = []
+    voffsets = []
+    # The string table first has the list of keys, then the list of values.
+    # Each entry has first the size of the string, then the file offset.
+    for o1, l1, o2, l2 in offsets:
+        koffsets += [l1, o1+keystart]
+        voffsets += [l2, o2+valuestart]
+    offsets = koffsets + voffsets
+    output = struct.pack(&quot;Iiiiiii&quot;,
+                         0x950412deL,       # Magic
+                         0,                 # Version
+                         len(keys),         # # of entries
+                         7*4,               # start of key index
+                         7*4+len(keys)*8,   # start of value index
+                         0, 0)              # size and offset of hash table
+    output += array.array(&quot;i&quot;, offsets).tostring()
+    output += ids
+    output += strs
+    return output
+
+
+
+def make(filename, outfile):
+    ID = 1
+    STR = 2
+
+    # Compute .mo name from .po name and arguments
+    if filename.endswith('.po'):
+        infile = filename
+    else:
+        infile = filename + '.po'
+    if outfile is None:
+        outfile = os.path.splitext(infile)[0] + '.mo'
+
+    try:
+        lines = open(infile).readlines()
+    except IOError, msg:
+        print &gt;&gt; sys.stderr, msg
+        sys.exit(1)
+
+    section = None
+    fuzzy = 0
+
+    # Parse the catalog
+    lno = 0
+    for l in lines:
+        lno += 1
+        # If we get a comment line after a msgstr, this is a new entry
+        if l[0] == '#' and section == STR:
+            add(msgid, msgstr, fuzzy)
+            section = None
+            fuzzy = 0
+        # Record a fuzzy mark
+        if l[:2] == '#,' and 'fuzzy' in l:
+            fuzzy = 1
+        # Skip comments
+        if l[0] == '#':
+            continue
+        # Now we are in a msgid section, output previous section
+        if l.startswith('msgid'):
+            if section == STR:
+                add(msgid, msgstr, fuzzy)
+            section = ID
+            l = l[5:]
+            msgid = msgstr = ''
+        # Now we are in a msgstr section
+        elif l.startswith('msgstr'):
+            section = STR
+            l = l[6:]
+        # Skip empty lines
+        l = l.strip()
+        if not l:
+            continue
+        # XXX: Does this always follow Python escape semantics?
+        l = eval(l)
+        if section == ID:
+            msgid += l
+        elif section == STR:
+            msgstr += l
+        else:
+            print &gt;&gt; sys.stderr, 'Syntax error on %s:%d' % (infile, lno), \
+                  'before:'
+            print &gt;&gt; sys.stderr, l
+            sys.exit(1)
+    # Add last entry
+    if section == STR:
+        add(msgid, msgstr, fuzzy)
+
+    # Compute output
+    output = generate()
+
+    try:
+        open(outfile,&quot;wb&quot;).write(output)
+    except IOError,msg:
+        print &gt;&gt; sys.stderr, msg
+
+
+
+def main():
+    try:
+        opts, args = getopt.getopt(sys.argv[1:], 'hVo:',
+                                   ['help', 'version', 'output-file='])
+    except getopt.error, msg:
+        usage(1, msg)
+
+    outfile = None
+    # parse options
+    for opt, arg in opts:
+        if opt in ('-h', '--help'):
+            usage(0)
+        elif opt in ('-V', '--version'):
+            print &gt;&gt; sys.stderr, &quot;msgfmt.py&quot;, __version__
+            sys.exit(0)
+        elif opt in ('-o', '--output-file'):
+            outfile = arg
+    # do it
+    if not args:
+        print &gt;&gt; sys.stderr, 'No input file given'
+        print &gt;&gt; sys.stderr, &quot;Try `msgfmt --help' for more information.&quot;
+        return
+
+    for filename in args:
+        make(filename, outfile)
+
+
+if __name__ == '__main__':
+    main()
</ins></span></pre></div>
<a id="CalendarServertrunksupportpygettextpyfromrev3323CalendarServerbranchesuserssagenlocalization3308supportpygettextpy"></a>
<div class="copfile"><h4>Copied: CalendarServer/trunk/support/pygettext.py (from rev 3323, CalendarServer/branches/users/sagen/localization-3308/support/pygettext.py) (0 => 3325)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/support/pygettext.py                                (rev 0)
+++ CalendarServer/trunk/support/pygettext.py        2008-11-06 01:45:12 UTC (rev 3325)
</span><span class="lines">@@ -0,0 +1,669 @@
</span><ins>+#! /usr/bin/env python
+# -*- coding: iso-8859-1 -*-
+# Originally written by Barry Warsaw &lt;barry@zope.com&gt;
+#
+# Minimally patched to make it even more xgettext compatible
+# by Peter Funk &lt;pf@artcom-gmbh.de&gt;
+#
+# 2002-11-22 J\xFCrgen Hermann &lt;jh@web.de&gt;
+# Added checks that _() only contains string literals, and
+# command line args are resolved to module lists, i.e. you
+# can now pass a filename, a module or package name, or a
+# directory (including globbing chars, important for Win32).
+# Made docstring fit in 80 chars wide displays using pydoc.
+#
+
+# for selftesting
+try:
+    import fintl
+    _ = fintl.gettext
+except ImportError:
+    _ = lambda s: s
+
+__doc__ = _(&quot;&quot;&quot;pygettext -- Python equivalent of xgettext(1)
+
+Many systems (Solaris, Linux, Gnu) provide extensive tools that ease the
+internationalization of C programs. Most of these tools are independent of
+the programming language and can be used from within Python programs.
+Martin von Loewis' work[1] helps considerably in this regard.
+
+There's one problem though; xgettext is the program that scans source code
+looking for message strings, but it groks only C (or C++). Python
+introduces a few wrinkles, such as dual quoting characters, triple quoted
+strings, and raw strings. xgettext understands none of this.
+
+Enter pygettext, which uses Python's standard tokenize module to scan
+Python source code, generating .pot files identical to what GNU xgettext[2]
+generates for C and C++ code. From there, the standard GNU tools can be
+used.
+
+A word about marking Python strings as candidates for translation. GNU
+xgettext recognizes the following keywords: gettext, dgettext, dcgettext,
+and gettext_noop. But those can be a lot of text to include all over your
+code. C and C++ have a trick: they use the C preprocessor. Most
+internationalized C source includes a #define for gettext() to _() so that
+what has to be written in the source is much less. Thus these are both
+translatable strings:
+
+    gettext(&quot;Translatable String&quot;)
+    _(&quot;Translatable String&quot;)
+
+Python of course has no preprocessor so this doesn't work so well.  Thus,
+pygettext searches only for _() by default, but see the -k/--keyword flag
+below for how to augment this.
+
+ [1] http://www.python.org/workshops/1997-10/proceedings/loewis.html
+ [2] http://www.gnu.org/software/gettext/gettext.html
+
+NOTE: pygettext attempts to be option and feature compatible with GNU
+xgettext where ever possible. However some options are still missing or are
+not fully implemented. Also, xgettext's use of command line switches with
+option arguments is broken, and in these cases, pygettext just defines
+additional switches.
+
+Usage: pygettext [options] inputfile ...
+
+Options:
+
+    -a
+    --extract-all
+        Extract all strings.
+
+    -d name
+    --default-domain=name
+        Rename the default output file from messages.pot to name.pot.
+
+    -E
+    --escape
+        Replace non-ASCII characters with octal escape sequences.
+
+    -D
+    --docstrings
+        Extract module, class, method, and function docstrings.  These do
+        not need to be wrapped in _() markers, and in fact cannot be for
+        Python to consider them docstrings. (See also the -X option).
+
+    -h
+    --help
+        Print this help message and exit.
+
+    -k word
+    --keyword=word
+        Keywords to look for in addition to the default set, which are:
+        %(DEFAULTKEYWORDS)s
+
+        You can have multiple -k flags on the command line.
+
+    -K
+    --no-default-keywords
+        Disable the default set of keywords (see above).  Any keywords
+        explicitly added with the -k/--keyword option are still recognized.
+
+    --no-location
+        Do not write filename/lineno location comments.
+
+    -n
+    --add-location
+        Write filename/lineno location comments indicating where each
+        extracted string is found in the source.  These lines appear before
+        each msgid.  The style of comments is controlled by the -S/--style
+        option.  This is the default.
+
+    -o filename
+    --output=filename
+        Rename the default output file from messages.pot to filename.  If
+        filename is `-' then the output is sent to standard out.
+
+    -p dir
+    --output-dir=dir
+        Output files will be placed in directory dir.
+
+    -S stylename
+    --style stylename
+        Specify which style to use for location comments.  Two styles are
+        supported:
+
+        Solaris  # File: filename, line: line-number
+        GNU      #: filename:line
+
+        The style name is case insensitive.  GNU style is the default.
+
+    -v
+    --verbose
+        Print the names of the files being processed.
+
+    -V
+    --version
+        Print the version of pygettext and exit.
+
+    -w columns
+    --width=columns
+        Set width of output to columns.
+
+    -x filename
+    --exclude-file=filename
+        Specify a file that contains a list of strings that are not be
+        extracted from the input files.  Each string to be excluded must
+        appear on a line by itself in the file.
+
+    -X filename
+    --no-docstrings=filename
+        Specify a file that contains a list of files (one per line) that
+        should not have their docstrings extracted.  This is only useful in
+        conjunction with the -D option above.
+
+If `inputfile' is -, standard input is read.
+&quot;&quot;&quot;)
+
+import os
+import imp
+import sys
+import glob
+import time
+import getopt
+import token
+import tokenize
+import operator
+
+__version__ = '1.5'
+
+default_keywords = ['_']
+DEFAULTKEYWORDS = ', '.join(default_keywords)
+
+EMPTYSTRING = ''
+
+
+
+# The normal pot-file header. msgmerge and Emacs's po-mode work better if it's
+# there.
+pot_header = _('''\
+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR ORGANIZATION
+# FIRST AUTHOR &lt;EMAIL@ADDRESS&gt;, YEAR.
+#
+msgid &quot;&quot;
+msgstr &quot;&quot;
+&quot;Project-Id-Version: PACKAGE VERSION\\n&quot;
+&quot;POT-Creation-Date: %(time)s\\n&quot;
+&quot;PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\\n&quot;
+&quot;Last-Translator: FULL NAME &lt;EMAIL@ADDRESS&gt;\\n&quot;
+&quot;Language-Team: LANGUAGE &lt;LL@li.org&gt;\\n&quot;
+&quot;MIME-Version: 1.0\\n&quot;
+&quot;Content-Type: text/plain; charset=CHARSET\\n&quot;
+&quot;Content-Transfer-Encoding: ENCODING\\n&quot;
+&quot;Generated-By: pygettext.py %(version)s\\n&quot;
+
+''')
+
+
+def usage(code, msg=''):
+    print &gt;&gt; sys.stderr, __doc__ % globals()
+    if msg:
+        print &gt;&gt; sys.stderr, msg
+    sys.exit(code)
+
+
+
+escapes = []
+
+def make_escapes(pass_iso8859):
+    global escapes
+    if pass_iso8859:
+        # Allow iso-8859 characters to pass through so that e.g. 'msgid
+        # &quot;H\xF6he&quot;' would result not result in 'msgid &quot;H\366he&quot;'.  Otherwise we
+        # escape any character outside the 32..126 range.
+        mod = 128
+    else:
+        mod = 256
+    for i in range(256):
+        if 32 &lt;= (i % mod) &lt;= 126:
+            escapes.append(chr(i))
+        else:
+            escapes.append(&quot;\\%03o&quot; % i)
+    escapes[ord('\\')] = '\\\\'
+    escapes[ord('\t')] = '\\t'
+    escapes[ord('\r')] = '\\r'
+    escapes[ord('\n')] = '\\n'
+    escapes[ord('\&quot;')] = '\\&quot;'
+
+
+def escape(s):
+    global escapes
+    s = list(s)
+    for i in range(len(s)):
+        s[i] = escapes[ord(s[i])]
+    return EMPTYSTRING.join(s)
+
+
+def safe_eval(s):
+    # unwrap quotes, safely
+    return eval(s, {'__builtins__':{}}, {})
+
+
+def normalize(s):
+    # This converts the various Python string types into a format that is
+    # appropriate for .po files, namely much closer to C style.
+    lines = s.split('\n')
+    if len(lines) == 1:
+        s = '&quot;' + escape(s) + '&quot;'
+    else:
+        if not lines[-1]:
+            del lines[-1]
+            lines[-1] = lines[-1] + '\n'
+        for i in range(len(lines)):
+            lines[i] = escape(lines[i])
+        lineterm = '\\n&quot;\n&quot;'
+        s = '&quot;&quot;\n&quot;' + lineterm.join(lines) + '&quot;'
+    return s
+
+
+def containsAny(str, set):
+    &quot;&quot;&quot;Check whether 'str' contains ANY of the chars in 'set'&quot;&quot;&quot;
+    return 1 in [c in str for c in set]
+
+
+def _visit_pyfiles(list, dirname, names):
+    &quot;&quot;&quot;Helper for getFilesForName().&quot;&quot;&quot;
+    # get extension for python source files
+    if not globals().has_key('_py_ext'):
+        global _py_ext
+        _py_ext = [triple[0] for triple in imp.get_suffixes()
+                   if triple[2] == imp.PY_SOURCE][0]
+
+    # don't recurse into CVS directories
+    if 'CVS' in names:
+        names.remove('CVS')
+
+    # add all *.py files to list
+    list.extend(
+        [os.path.join(dirname, file) for file in names
+         if os.path.splitext(file)[1] == _py_ext]
+        )
+
+
+def _get_modpkg_path(dotted_name, pathlist=None):
+    &quot;&quot;&quot;Get the filesystem path for a module or a package.
+
+    Return the file system path to a file for a module, and to a directory for
+    a package. Return None if the name is not found, or is a builtin or
+    extension module.
+    &quot;&quot;&quot;
+    # split off top-most name
+    parts = dotted_name.split('.', 1)
+
+    if len(parts) &gt; 1:
+        # we have a dotted path, import top-level package
+        try:
+            file, pathname, description = imp.find_module(parts[0], pathlist)
+            if file: file.close()
+        except ImportError:
+            return None
+
+        # check if it's indeed a package
+        if description[2] == imp.PKG_DIRECTORY:
+            # recursively handle the remaining name parts
+            pathname = _get_modpkg_path(parts[1], [pathname])
+        else:
+            pathname = None
+    else:
+        # plain name
+        try:
+            file, pathname, description = imp.find_module(
+                dotted_name, pathlist)
+            if file:
+                file.close()
+            if description[2] not in [imp.PY_SOURCE, imp.PKG_DIRECTORY]:
+                pathname = None
+        except ImportError:
+            pathname = None
+
+    return pathname
+
+
+def getFilesForName(name):
+    &quot;&quot;&quot;Get a list of module files for a filename, a module or package name,
+    or a directory.
+    &quot;&quot;&quot;
+    if not os.path.exists(name):
+        # check for glob chars
+        if containsAny(name, &quot;*?[]&quot;):
+            files = glob.glob(name)
+            list = []
+            for file in files:
+                list.extend(getFilesForName(file))
+            return list
+
+        # try to find module or package
+        name = _get_modpkg_path(name)
+        if not name:
+            return []
+
+    if os.path.isdir(name):
+        # find all python files in directory
+        list = []
+        os.path.walk(name, _visit_pyfiles, list)
+        return list
+    elif os.path.exists(name):
+        # a single file
+        return [name]
+
+    return []
+
+
+class TokenEater:
+    def __init__(self, options):
+        self.__options = options
+        self.__messages = {}
+        self.__state = self.__waiting
+        self.__data = []
+        self.__lineno = -1
+        self.__freshmodule = 1
+        self.__curfile = None
+
+    def __call__(self, ttype, tstring, stup, etup, line):
+        # dispatch
+##        import token
+##        print &gt;&gt; sys.stderr, 'ttype:', token.tok_name[ttype], \
+##              'tstring:', tstring
+        self.__state(ttype, tstring, stup[0])
+
+    def __waiting(self, ttype, tstring, lineno):
+        opts = self.__options
+        # Do docstring extractions, if enabled
+        if opts.docstrings and not opts.nodocstrings.get(self.__curfile):
+            # module docstring?
+            if self.__freshmodule:
+                if ttype == tokenize.STRING:
+                    self.__addentry(safe_eval(tstring), lineno, isdocstring=1)
+                    self.__freshmodule = 0
+                elif ttype not in (tokenize.COMMENT, tokenize.NL):
+                    self.__freshmodule = 0
+                return
+            # class docstring?
+            if ttype == tokenize.NAME and tstring in ('class', 'def'):
+                self.__state = self.__suiteseen
+                return
+        if ttype == tokenize.NAME and tstring in opts.keywords:
+            self.__state = self.__keywordseen
+
+    def __suiteseen(self, ttype, tstring, lineno):
+        # ignore anything until we see the colon
+        if ttype == tokenize.OP and tstring == ':':
+            self.__state = self.__suitedocstring
+
+    def __suitedocstring(self, ttype, tstring, lineno):
+        # ignore any intervening noise
+        if ttype == tokenize.STRING:
+            self.__addentry(safe_eval(tstring), lineno, isdocstring=1)
+            self.__state = self.__waiting
+        elif ttype not in (tokenize.NEWLINE, tokenize.INDENT,
+                           tokenize.COMMENT):
+            # there was no class docstring
+            self.__state = self.__waiting
+
+    def __keywordseen(self, ttype, tstring, lineno):
+        if ttype == tokenize.OP and tstring == '(':
+            self.__data = []
+            self.__lineno = lineno
+            self.__state = self.__openseen
+        else:
+            self.__state = self.__waiting
+
+    def __openseen(self, ttype, tstring, lineno):
+        if ttype == tokenize.OP and tstring == ')':
+            # We've seen the last of the translatable strings.  Record the
+            # line number of the first line of the strings and update the list
+            # of messages seen.  Reset state for the next batch.  If there
+            # were no strings inside _(), then just ignore this entry.
+            if self.__data:
+                self.__addentry(EMPTYSTRING.join(self.__data))
+            self.__state = self.__waiting
+        elif ttype == tokenize.STRING:
+            self.__data.append(safe_eval(tstring))
+        elif ttype not in [tokenize.COMMENT, token.INDENT, token.DEDENT,
+                           token.NEWLINE, tokenize.NL]:
+            # warn if we see anything else than STRING or whitespace
+            print &gt;&gt; sys.stderr, _(
+                '*** %(file)s:%(lineno)s: Seen unexpected token &quot;%(token)s&quot;'
+                ) % {
+                'token': tstring,
+                'file': self.__curfile,
+                'lineno': self.__lineno
+                }
+            self.__state = self.__waiting
+
+    def __addentry(self, msg, lineno=None, isdocstring=0):
+        if lineno is None:
+            lineno = self.__lineno
+        if not msg in self.__options.toexclude:
+            entry = (self.__curfile, lineno)
+            self.__messages.setdefault(msg, {})[entry] = isdocstring
+
+    def set_filename(self, filename):
+        self.__curfile = filename
+        self.__freshmodule = 1
+
+    def write(self, fp):
+        options = self.__options
+        timestamp = time.strftime('%Y-%m-%d %H:%M+%Z')
+        # The time stamp in the header doesn't have the same format as that
+        # generated by xgettext...
+        print &gt;&gt; fp, pot_header % {'time': timestamp, 'version': __version__}
+        # Sort the entries.  First sort each particular entry's keys, then
+        # sort all the entries by their first item.
+        reverse = {}
+        for k, v in self.__messages.items():
+            keys = v.keys()
+            keys.sort()
+            reverse.setdefault(tuple(keys), []).append((k, v))
+        rkeys = reverse.keys()
+        rkeys.sort()
+        for rkey in rkeys:
+            rentries = reverse[rkey]
+            rentries.sort()
+            for k, v in rentries:
+                isdocstring = 0
+                # If the entry was gleaned out of a docstring, then add a
+                # comment stating so.  This is to aid translators who may wish
+                # to skip translating some unimportant docstrings.
+                if reduce(operator.__add__, v.values()):
+                    isdocstring = 1
+                # k is the message string, v is a dictionary-set of (filename,
+                # lineno) tuples.  We want to sort the entries in v first by
+                # file name and then by line number.
+                v = v.keys()
+                v.sort()
+                if not options.writelocations:
+                    pass
+                # location comments are different b/w Solaris and GNU:
+                elif options.locationstyle == options.SOLARIS:
+                    for filename, lineno in v:
+                        d = {'filename': filename, 'lineno': lineno}
+                        print &gt;&gt;fp, _(
+                            '# File: %(filename)s, line: %(lineno)d') % d
+                elif options.locationstyle == options.GNU:
+                    # fit as many locations on one line, as long as the
+                    # resulting line length doesn't exceeds 'options.width'
+                    locline = '#:'
+                    for filename, lineno in v:
+                        d = {'filename': filename, 'lineno': lineno}
+                        s = _(' %(filename)s:%(lineno)d') % d
+                        if len(locline) + len(s) &lt;= options.width:
+                            locline = locline + s
+                        else:
+                            print &gt;&gt; fp, locline
+                            locline = &quot;#:&quot; + s
+                    if len(locline) &gt; 2:
+                        print &gt;&gt; fp, locline
+                if isdocstring:
+                    print &gt;&gt; fp, '#, docstring'
+                print &gt;&gt; fp, 'msgid', normalize(k)
+                print &gt;&gt; fp, 'msgstr &quot;&quot;\n'
+
+
+
+def main():
+    global default_keywords
+    try:
+        opts, args = getopt.getopt(
+            sys.argv[1:],
+            'ad:DEhk:Kno:p:S:Vvw:x:X:',
+            ['extract-all', 'default-domain=', 'escape', 'help',
+             'keyword=', 'no-default-keywords',
+             'add-location', 'no-location', 'output=', 'output-dir=',
+             'style=', 'verbose', 'version', 'width=', 'exclude-file=',
+             'docstrings', 'no-docstrings',
+             ])
+    except getopt.error, msg:
+        usage(1, msg)
+
+    # for holding option values
+    class Options:
+        # constants
+        GNU = 1
+        SOLARIS = 2
+        # defaults
+        extractall = 0 # FIXME: currently this option has no effect at all.
+        escape = 0
+        keywords = []
+        outpath = ''
+        outfile = 'messages.pot'
+        writelocations = 1
+        locationstyle = GNU
+        verbose = 0
+        width = 78
+        excludefilename = ''
+        docstrings = 0
+        nodocstrings = {}
+
+    options = Options()
+    locations = {'gnu' : options.GNU,
+                 'solaris' : options.SOLARIS,
+                 }
+
+    # parse options
+    for opt, arg in opts:
+        if opt in ('-h', '--help'):
+            usage(0)
+        elif opt in ('-a', '--extract-all'):
+            options.extractall = 1
+        elif opt in ('-d', '--default-domain'):
+            options.outfile = arg + '.pot'
+        elif opt in ('-E', '--escape'):
+            options.escape = 1
+        elif opt in ('-D', '--docstrings'):
+            options.docstrings = 1
+        elif opt in ('-k', '--keyword'):
+            options.keywords.append(arg)
+        elif opt in ('-K', '--no-default-keywords'):
+            default_keywords = []
+        elif opt in ('-n', '--add-location'):
+            options.writelocations = 1
+        elif opt in ('--no-location',):
+            options.writelocations = 0
+        elif opt in ('-S', '--style'):
+            options.locationstyle = locations.get(arg.lower())
+            if options.locationstyle is None:
+                usage(1, _('Invalid value for --style: %s') % arg)
+        elif opt in ('-o', '--output'):
+            options.outfile = arg
+        elif opt in ('-p', '--output-dir'):
+            options.outpath = arg
+        elif opt in ('-v', '--verbose'):
+            options.verbose = 1
+        elif opt in ('-V', '--version'):
+            print _('pygettext.py (xgettext for Python) %s') % __version__
+            sys.exit(0)
+        elif opt in ('-w', '--width'):
+            try:
+                options.width = int(arg)
+            except ValueError:
+                usage(1, _('--width argument must be an integer: %s') % arg)
+        elif opt in ('-x', '--exclude-file'):
+            options.excludefilename = arg
+        elif opt in ('-X', '--no-docstrings'):
+            fp = open(arg)
+            try:
+                while 1:
+                    line = fp.readline()
+                    if not line:
+                        break
+                    options.nodocstrings[line[:-1]] = 1
+            finally:
+                fp.close()
+
+    # calculate escapes
+    make_escapes(options.escape)
+
+    # calculate all keywords
+    options.keywords.extend(default_keywords)
+
+    # initialize list of strings to exclude
+    if options.excludefilename:
+        try:
+            fp = open(options.excludefilename)
+            options.toexclude = fp.readlines()
+            fp.close()
+        except IOError:
+            print &gt;&gt; sys.stderr, _(
+                &quot;Can't read --exclude-file: %s&quot;) % options.excludefilename
+            sys.exit(1)
+    else:
+        options.toexclude = []
+
+    # resolve args to module lists
+    expanded = []
+    for arg in args:
+        if arg == '-':
+            expanded.append(arg)
+        else:
+            expanded.extend(getFilesForName(arg))
+    args = expanded
+
+    # slurp through all the files
+    eater = TokenEater(options)
+    for filename in args:
+        if filename == '-':
+            if options.verbose:
+                print _('Reading standard input')
+            fp = sys.stdin
+            closep = 0
+        else:
+            if options.verbose:
+                print _('Working on %s') % filename
+            fp = open(filename)
+            closep = 1
+        try:
+            eater.set_filename(filename)
+            try:
+                tokenize.tokenize(fp.readline, eater)
+            except tokenize.TokenError, e:
+                print &gt;&gt; sys.stderr, '%s: %s, line %d, column %d' % (
+                    e[0], filename, e[1][0], e[1][1])
+        finally:
+            if closep:
+                fp.close()
+
+    # write the output
+    if options.outfile == '-':
+        fp = sys.stdout
+        closep = 0
+    else:
+        if options.outpath:
+            options.outfile = os.path.join(options.outpath, options.outfile)
+        fp = open(options.outfile, 'w')
+        closep = 1
+    try:
+        eater.write(fp)
+    finally:
+        if closep:
+            fp.close()
+
+
+if __name__ == '__main__':
+    main()
+    # some more test strings
+    _(u'a unicode string')
+    # this one creates a warning
+    _('*** Seen unexpected token &quot;%(token)s&quot;') % {'token': 'test'}
+    _('more' 'than' 'one' 'string')
</ins></span></pre></div>
<a id="CalendarServertrunktwistedcaldavconfigpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/twistedcaldav/config.py (3324 => 3325)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twistedcaldav/config.py        2008-11-06 01:28:37 UTC (rev 3324)
+++ CalendarServer/trunk/twistedcaldav/config.py        2008-11-06 01:45:12 UTC (rev 3325)
</span><span class="lines">@@ -233,6 +233,9 @@
</span><span class="cx">                 &quot;Password&quot;      : &quot;&quot;,    # For account receving mail
</span><span class="cx">             },
</span><span class="cx">             &quot;AddressPatterns&quot;   : [],    # Reg-ex patterns to match iMIP-able calendar user addresses
</span><ins>+            &quot;MailTemplatesDirectory&quot;: &quot;/usr/share/caldavd/templates&quot;, # Directory containing HTML templates for email invitations (invite.html, cancel.html)
+            &quot;MailIconsDirectory&quot;: &quot;/usr/share/caldavd/images/mail&quot;, # Directory containing language-specific subdirectories containing date-specific icons for email invitations (cal-icon-mm-dd.png)
+            &quot;InvitationDaysToLive&quot; : 90, # How many days invitations are valid
</ins><span class="cx">         },
</span><span class="cx"> 
</span><span class="cx">     },
</span><span class="lines">@@ -288,7 +291,17 @@
</span><span class="cx">     &quot;IdleConnectionTimeOut&quot;: 15,
</span><span class="cx">     &quot;UIDReservationTimeOut&quot;: 30 * 60,
</span><span class="cx"> 
</span><ins>+
</ins><span class="cx">     #
</span><ins>+    # Localization
+    #
+    &quot;Localization&quot; : {
+        &quot;LocalesDirectory&quot; : &quot;/usr/share/caldavd/locales&quot;,
+        &quot;Language&quot; : &quot;en&quot;,
+    },
+
+
+    #
</ins><span class="cx">     # Implementation details
</span><span class="cx">     #
</span><span class="cx">     #    The following are specific to how the server is built, and useful
</span></span></pre></div>
<a id="CalendarServertrunktwistedcaldavicalpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/twistedcaldav/ical.py (3324 => 3325)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twistedcaldav/ical.py        2008-11-06 01:28:37 UTC (rev 3324)
+++ CalendarServer/trunk/twistedcaldav/ical.py        2008-11-06 01:45:12 UTC (rev 3325)
</span><span class="lines">@@ -1255,6 +1255,25 @@
</span><span class="cx"> 
</span><span class="cx">         return results
</span><span class="cx"> 
</span><ins>+    def getAllAttendeeProperties(self):
+        &quot;&quot;&quot;
+        Yield all attendees as Property objects.  Works on either a VCALENDAR or
+        on a component.
+        @return: a generator yielding Property objects
+        &quot;&quot;&quot;
+
+        # Extract appropriate sub-component if this is a VCALENDAR
+        if self.name() == &quot;VCALENDAR&quot;:
+            for component in self.subcomponents():
+                if component.name() != &quot;VTIMEZONE&quot;:
+                    for attendee in component.getAllAttendeeProperties():
+                        yield attendee
+        else:
+            # Find the primary subcomponent
+            for attendee in self.properties(&quot;ATTENDEE&quot;):
+                yield attendee
+
+
</ins><span class="cx">     def getMaskUID(self):
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         Get the X-CALENDARSEREVR-MASK-UID value. Works on either a VCALENDAR or on a component.
</span></span></pre></div>
<a id="CalendarServertrunktwistedcaldavmailpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/twistedcaldav/mail.py (3324 => 3325)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twistedcaldav/mail.py        2008-11-06 01:28:37 UTC (rev 3324)
+++ CalendarServer/trunk/twistedcaldav/mail.py        2008-11-06 01:45:12 UTC (rev 3325)
</span><span class="lines">@@ -18,6 +18,7 @@
</span><span class="cx"> Mail Gateway for Calendar Server
</span><span class="cx"> 
</span><span class="cx"> &quot;&quot;&quot;
</span><ins>+from __future__ import with_statement
</ins><span class="cx"> 
</span><span class="cx"> from email.mime.image import MIMEImage
</span><span class="cx"> from email.mime.multipart import MIMEMultipart
</span><span class="lines">@@ -41,7 +42,9 @@
</span><span class="cx"> from twistedcaldav.log import Logger, LoggingMixIn
</span><span class="cx"> from twistedcaldav.resource import CalDAVResource
</span><span class="cx"> from twistedcaldav.scheduling.scheduler import IMIPScheduler
</span><ins>+from twistedcaldav.scheduling.cuaddress import normalizeCUAddr
</ins><span class="cx"> from twistedcaldav.sql import AbstractSQLDatabase
</span><ins>+from twistedcaldav.localization import translationTo
</ins><span class="cx"> 
</span><span class="cx"> from zope.interface import implements
</span><span class="cx"> 
</span><span class="lines">@@ -260,6 +263,8 @@
</span><span class="cx">     log.debug(&quot;Injecting to %s: %s %s&quot; % (url, str(headers), data))
</span><span class="cx">     factory = client.HTTPClientFactory(url, method='POST', headers=headers,
</span><span class="cx">         postdata=data, agent=&quot;iMIP gateway&quot;)
</span><ins>+    factory.noisy = False
+
</ins><span class="cx">     if useSSL:
</span><span class="cx">         reactor.connectSSL(host, port, factory, ssl.ClientContextFactory())
</span><span class="cx">     else:
</span><span class="lines">@@ -287,7 +292,7 @@
</span><span class="cx"> 
</span><span class="cx">     Token Database:
</span><span class="cx"> 
</span><del>-    ROW: TOKEN, ORGANIZER, ATTENDEE
</del><ins>+    ROW: TOKEN, ORGANIZER, ATTENDEE, ICALUID, DATESTAMP
</ins><span class="cx"> 
</span><span class="cx">     &quot;&quot;&quot;
</span><span class="cx"> 
</span><span class="lines">@@ -301,14 +306,14 @@
</span><span class="cx">             path = os.path.join(path, MailGatewayTokensDatabase.dbFilename)
</span><span class="cx">         super(MailGatewayTokensDatabase, self).__init__(path, True)
</span><span class="cx"> 
</span><del>-    def createToken(self, organizer, attendee, token=None):
</del><ins>+    def createToken(self, organizer, attendee, icaluid, token=None):
</ins><span class="cx">         if token is None:
</span><span class="cx">             token = str(uuid.uuid4())
</span><span class="cx">         self._db_execute(
</span><span class="cx">             &quot;&quot;&quot;
</span><del>-            insert into TOKENS (TOKEN, ORGANIZER, ATTENDEE)
-            values (:1, :2, :3)
-            &quot;&quot;&quot;, token, organizer, attendee
</del><ins>+            insert into TOKENS (TOKEN, ORGANIZER, ATTENDEE, ICALUID, DATESTAMP)
+            values (:1, :2, :3, :4, :5)
+            &quot;&quot;&quot;, token, organizer, attendee, icaluid, datetime.date.today()
</ins><span class="cx">         )
</span><span class="cx">         self._db_commit()
</span><span class="cx">         return token
</span><span class="lines">@@ -317,7 +322,7 @@
</span><span class="cx">         results = list(
</span><span class="cx">             self._db_execute(
</span><span class="cx">                 &quot;&quot;&quot;
</span><del>-                select ORGANIZER, ATTENDEE from TOKENS
</del><ins>+                select ORGANIZER, ATTENDEE, ICALUID from TOKENS
</ins><span class="cx">                 where TOKEN = :1
</span><span class="cx">                 &quot;&quot;&quot;, token
</span><span class="cx">             )
</span><span class="lines">@@ -328,13 +333,20 @@
</span><span class="cx"> 
</span><span class="cx">         return results[0]
</span><span class="cx"> 
</span><del>-    def getToken(self, organizer, attendee):
</del><ins>+    def getToken(self, organizer, attendee, icaluid):
</ins><span class="cx">         token = self._db_value_for_sql(
</span><span class="cx">             &quot;&quot;&quot;
</span><span class="cx">             select TOKEN from TOKENS
</span><del>-            where ORGANIZER = :1 and ATTENDEE = :2
-            &quot;&quot;&quot;, organizer, attendee
</del><ins>+            where ORGANIZER = :1 and ATTENDEE = :2 and ICALUID = :3
+            &quot;&quot;&quot;, organizer, attendee, icaluid
</ins><span class="cx">         )
</span><ins>+        if token is not None:
+            # update the datestamp on the token to keep it from being purged
+            self._db_execute(
+                &quot;&quot;&quot;
+                update TOKENS set DATESTAMP = :1 WHERE TOKEN = :2
+                &quot;&quot;&quot;, datetime.date.today(), token
+            )
</ins><span class="cx">         return token
</span><span class="cx"> 
</span><span class="cx">     def deleteToken(self, token):
</span><span class="lines">@@ -343,7 +355,16 @@
</span><span class="cx">             delete from TOKENS where TOKEN = :1
</span><span class="cx">             &quot;&quot;&quot;, token
</span><span class="cx">         )
</span><ins>+        self._db_commit()
</ins><span class="cx"> 
</span><ins>+    def purgeOldTokens(self, before):
+        self._db_execute(
+            &quot;&quot;&quot;
+            delete from TOKENS where DATESTAMP &lt; :1
+            &quot;&quot;&quot;, before
+        )
+        self._db_commit()
+
</ins><span class="cx">     def _db_version(self):
</span><span class="cx">         &quot;&quot;&quot;
</span><span class="cx">         @return: the schema version assigned to this index.
</span><span class="lines">@@ -370,7 +391,9 @@
</span><span class="cx">             create table TOKENS (
</span><span class="cx">                 TOKEN       text,
</span><span class="cx">                 ORGANIZER   text,
</span><del>-                ATTENDEE    text
</del><ins>+                ATTENDEE    text,
+                ICALUID     text,
+                DATESTAMP   date
</ins><span class="cx">             )
</span><span class="cx">             &quot;&quot;&quot;
</span><span class="cx">         )
</span><span class="lines">@@ -480,8 +503,9 @@
</span><span class="cx">             # Compute token, add to db, generate email and send it
</span><span class="cx">             calendar = ical.Component.fromString(request.content.read())
</span><span class="cx">             headers = request.getAllHeaders()
</span><ins>+            language = config.Localization[&quot;Language&quot;]
</ins><span class="cx">             self.mailer.outbound(headers['originator'], headers['recipient'],
</span><del>-                calendar)
</del><ins>+                calendar, language=language)
</ins><span class="cx"> 
</span><span class="cx">             # TODO: what to return?
</span><span class="cx">             return &quot;&quot;&quot;
</span><span class="lines">@@ -497,6 +521,9 @@
</span><span class="cx">         if dataRoot is None:
</span><span class="cx">             dataRoot = config.DataRoot
</span><span class="cx">         self.db = MailGatewayTokensDatabase(dataRoot)
</span><ins>+        days = config.Scheduling['iMIP']['InvitationDaysToLive']
+        self.db.purgeOldTokens(datetime.date.today() -
+            datetime.timedelta(days=days))
</ins><span class="cx"> 
</span><span class="cx">     def checkDSN(self, message):
</span><span class="cx">         # returns (isDSN, Action, icalendar attachment)
</span><span class="lines">@@ -561,9 +588,10 @@
</span><span class="cx">             self.log_error(&quot;Mail gateway found a token (%s) but didn't recognize it in DSN %s&quot; % (token, msgId))
</span><span class="cx">             return
</span><span class="cx"> 
</span><del>-        organizer, attendee = result
</del><ins>+        organizer, attendee, icaluid = result
</ins><span class="cx">         organizer = str(organizer)
</span><span class="cx">         attendee = str(attendee)
</span><ins>+        icaluid = str(icaluid)
</ins><span class="cx">         calendar.removeAllButOneAttendee(attendee)
</span><span class="cx">         calendar.getOrganizerProperty().setValue(organizer)
</span><span class="cx">         for comp in calendar.subcomponents():
</span><span class="lines">@@ -576,7 +604,7 @@
</span><span class="cx">             # TODO: what to do in this case?
</span><span class="cx">             pass
</span><span class="cx"> 
</span><del>-        self.log_error(&quot;Mail gateway processing DSN %s&quot; % (msgId,))
</del><ins>+        self.log_warn(&quot;Mail gateway processing DSN %s&quot; % (msgId,))
</ins><span class="cx">         return fn(organizer, attendee, calendar, msgId)
</span><span class="cx"> 
</span><span class="cx">     def processReply(self, msg, fn):
</span><span class="lines">@@ -611,9 +639,10 @@
</span><span class="cx">             self.log_error(&quot;Mail gateway found a token (%s) but didn't recognize it in message %s&quot; % (token, msg['Message-ID']))
</span><span class="cx">             return
</span><span class="cx"> 
</span><del>-        organizer, attendee = result
</del><ins>+        organizer, attendee, icaluid = result
</ins><span class="cx">         organizer = str(organizer)
</span><span class="cx">         attendee = str(attendee)
</span><ins>+        icaluid = str(icaluid)
</ins><span class="cx">         calendar.removeAllButOneAttendee(attendee)
</span><span class="cx">         organizerProperty = calendar.getOrganizerProperty()
</span><span class="cx">         if organizerProperty is None:
</span><span class="lines">@@ -627,39 +656,71 @@
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     def inbound(self, message, fn=injectMessage):
</span><del>-        msg = email.message_from_string(message)
</del><ins>+        try:
+            msg = email.message_from_string(message)
</ins><span class="cx"> 
</span><del>-        isDSN, action, calBody = self.checkDSN(msg)
-        if isDSN:
-            if action == 'failed' and calBody:
-                # This is a DSN we can handle
-                return self.processDSN(calBody, msg['Message-ID'], fn)
-            else:
-                # It's a DSN without enough to go on
-                self.log_error(&quot;Mail gateway can't process DSN %s&quot; % (msg['Message-ID'],))
-                return
</del><ins>+            isDSN, action, calBody = self.checkDSN(msg)
+            if isDSN:
+                if action == 'failed' and calBody:
+                    # This is a DSN we can handle
+                    return self.processDSN(calBody, msg['Message-ID'], fn)
+                else:
+                    # It's a DSN without enough to go on
+                    self.log_error(&quot;Mail gateway can't process DSN %s&quot; % (msg['Message-ID'],))
+                    return
</ins><span class="cx"> 
</span><del>-        self.log_info(&quot;Mail gateway received message %s from %s to %s&quot; %
-            (msg['Message-ID'], msg['From'], msg['To']))
</del><ins>+            self.log_info(&quot;Mail gateway received message %s from %s to %s&quot; %
+                (msg['Message-ID'], msg['From'], msg['To']))
</ins><span class="cx"> 
</span><del>-        return self.processReply(msg, fn)
</del><ins>+            return self.processReply(msg, fn)
</ins><span class="cx"> 
</span><ins>+        except Exception, e:
+            # Don't let a failure of any kind stop us
+            self.log_error(&quot;Failed to process message: %s&quot; % (e,))
</ins><span class="cx"> 
</span><span class="cx"> 
</span><del>-    def outbound(self, organizer, attendee, calendar):
</del><ins>+
+
+    def outbound(self, organizer, attendee, calendar, language='en'):
</ins><span class="cx">         # create token, send email
</span><del>-        token = self.db.getToken(organizer, attendee)
</del><ins>+
+        component = calendar.masterComponent()
+        if component is None:
+            component = calendar.mainComponent(True)
+        icaluid = component.propertyValue(&quot;UID&quot;)
+
+        token = self.db.getToken(organizer, attendee, icaluid)
</ins><span class="cx">         if token is None:
</span><del>-            token = self.db.createToken(organizer, attendee)
-            self.log_info(&quot;Mail gateway created token %s for %s (organizer) and %s (attendee)&quot; % (token, organizer, attendee))
</del><ins>+            token = self.db.createToken(organizer, attendee, icaluid)
+            self.log_debug(&quot;Mail gateway created token %s for %s (organizer), %s (attendee) and %s (icaluid)&quot; % (token, organizer, attendee, icaluid))
+            newInvitation = True
</ins><span class="cx">         else:
</span><del>-            self.log_info(&quot;Mail gateway reusing token %s for %s (organizer) and %s (attendee)&quot; % (token, organizer, attendee))
</del><ins>+            self.log_debug(&quot;Mail gateway reusing token %s for %s (organizer), %s (attendee) and %s (icaluid)&quot; % (token, organizer, attendee, icaluid))
+            newInvitation = False
</ins><span class="cx"> 
</span><span class="cx">         settings = config.Scheduling['iMIP']['Sending']
</span><span class="cx">         fullServerAddress = settings['Address']
</span><span class="cx">         name, serverAddress = email.utils.parseaddr(fullServerAddress)
</span><span class="cx">         pre, post = serverAddress.split('@')
</span><span class="cx">         addressWithToken = &quot;%s+%s@%s&quot; % (pre, token, post)
</span><ins>+
+        attendees = []
+        for attendeeProp in calendar.getAllAttendeeProperties():
+            params = attendeeProp.params()
+            cutype = params.get('CUTYPE', (None,))[0]
+            if cutype == &quot;INDIVIDUAL&quot;:
+                cn = params.get(&quot;CN&quot;, (None,))[0]
+                cuaddr = normalizeCUAddr(attendeeProp.value())
+                if cuaddr.startswith(&quot;mailto:&quot;):
+                    mailto = cuaddr[7:]
+                    if not cn:
+                        cn = mailto
+                else:
+                    mailto = None
+
+                if cn or mailto:
+                    attendees.append( (cn, mailto) )
+
</ins><span class="cx">         calendar.getOrganizerProperty().setValue(&quot;mailto:%s&quot; %
</span><span class="cx">             (addressWithToken,))
</span><span class="cx"> 
</span><span class="lines">@@ -667,29 +728,34 @@
</span><span class="cx">         if organizerAttendee is not None:
</span><span class="cx">             organizerAttendee.setValue(&quot;mailto:%s&quot; % (addressWithToken,))
</span><span class="cx"> 
</span><del>-        msgId, message = self._generateTemplateMessage(calendar, organizer)
</del><span class="cx"> 
</span><span class="cx">         # The email's From will include the organizer's real name email
</span><span class="cx">         # address if available.  Otherwise it will be the server's email
</span><span class="cx">         # address (without # + addressing)
</span><span class="cx">         if organizer.startswith(&quot;mailto:&quot;):
</span><del>-            fromAddr = organizer[7:]
</del><ins>+            orgEmail = fromAddr = organizer[7:]
</ins><span class="cx">         else:
</span><span class="cx">             fromAddr = serverAddress
</span><del>-        cn = calendar.getOrganizerProperty().params().get('CN',
-            ['Calendar Server'])[0]
</del><ins>+            orgEmail = None
+        cn = calendar.getOrganizerProperty().params().get('CN', (None,))[0]
+        if cn is None:
+            cn = 'Calendar Server'
+            orgCN = orgEmail
+        else:
+            orgCN = cn
</ins><span class="cx">         formattedFrom = &quot;%s &lt;%s&gt;&quot; % (cn, fromAddr)
</span><del>-        message = message.replace(&quot;${fromaddress}&quot;, formattedFrom)
</del><span class="cx"> 
</span><span class="cx">         # Reply-to address will be the server+token address
</span><del>-        message = message.replace(&quot;${replytoaddress}&quot;, addressWithToken)
</del><span class="cx"> 
</span><span class="cx">         toAddr = attendee
</span><span class="cx">         if not attendee.startswith(&quot;mailto:&quot;):
</span><span class="cx">             raise ValueError(&quot;ATTENDEE address '%s' must be mailto: for iMIP operation.&quot; % (attendee,))
</span><span class="cx">         attendee = attendee[7:]
</span><del>-        message = message.replace(&quot;${toaddress}&quot;, attendee)
</del><span class="cx"> 
</span><ins>+        msgId, message = self.generateEmail(newInvitation, calendar, orgEmail,
+            orgCN, attendees, formattedFrom, addressWithToken, attendee,
+            language=language)
+
</ins><span class="cx">         self.log_debug(&quot;Sending: %s&quot; % (message,))
</span><span class="cx">         def _success(result, msgId, fromAddr, toAddr):
</span><span class="cx">             self.log_info(&quot;Mail gateway sent message %s from %s to %s&quot; %
</span><span class="lines">@@ -706,62 +772,202 @@
</span><span class="cx">         deferred.addErrback(_failure, msgId, fromAddr, toAddr)
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-    def _generateTemplateMessage(self, calendar, organizer):
</del><ins>+    def generateEmail(self, newInvitation, calendar, orgEmail, orgCN,
+        attendees, fromAddress, replyToAddress, toAddress, language='en'):
</ins><span class="cx"> 
</span><del>-        title, summary = self._generateCalendarSummary(calendar, organizer)
</del><ins>+        details = self.getEventDetails(calendar, language=language)
</ins><span class="cx"> 
</span><del>-        msg = MIMEMultipart()
-        msg[&quot;From&quot;] = &quot;${fromaddress}&quot;
-        msg[&quot;Reply-To&quot;] = &quot;${replytoaddress}&quot;
-        msg[&quot;To&quot;] = &quot;${toaddress}&quot;
-        msg[&quot;Date&quot;] = rfc822date()
-        msgId = messageid()
-        msg[&quot;Message-ID&quot;] = msgId
</del><ins>+        iconDir = config.Scheduling[&quot;iMIP&quot;][&quot;MailIconsDirectory&quot;].rstrip(&quot;/&quot;)
+        iconName = &quot;cal-icon-%02d-%02d.png&quot; % (details['month'],
+            details['day'])
+        iconPath = os.path.join(iconDir, language, iconName)
+        if not os.path.exists(iconPath):
+            # Try the generic (numeric) version
+            iconPath = os.path.join(iconDir, 'generic', iconName)
</ins><span class="cx"> 
</span><del>-        msgAlt = MIMEMultipart(&quot;alternative&quot;)
-        msg.attach(msgAlt)
</del><ins>+        with translationTo(language):
+            msg = MIMEMultipart()
+            msg[&quot;From&quot;] = fromAddress
+            msg[&quot;Reply-To&quot;] = replyToAddress
+            msg[&quot;To&quot;] = toAddress
+            msg[&quot;Date&quot;] = rfc822date()
+            msgId = messageid()
+            msg[&quot;Message-ID&quot;] = msgId
</ins><span class="cx"> 
</span><del>-        # plain text version
-        if calendar.propertyValue(&quot;METHOD&quot;) == &quot;CANCEL&quot;:
-            msg[&quot;Subject&quot;] = &quot;Event cancelled&quot;
-            plainText = u&quot;An event has been cancelled.  Click the link below.\n&quot;
-        else:
-            msg[&quot;Subject&quot;] = &quot;Event invitation: %s&quot; % (title,)
-            plainText = u&quot;You've been invited to the following event:  %s To accept or decline this invitation, click the link below.\n&quot; % (summary,)
</del><ins>+            canceled = (calendar.propertyValue(&quot;METHOD&quot;) == &quot;CANCEL&quot;)
+            if canceled:
+                formatString = _(&quot;Event canceled: %(summary)s&quot;)
+            elif newInvitation:
+                formatString = _(&quot;Event invitation: %(summary)s&quot;)
+            else:
+                formatString = _(&quot;Event update: %(summary)s&quot;)
</ins><span class="cx"> 
</span><del>-        msgPlain = MIMEText(plainText.encode(&quot;UTF-8&quot;), &quot;plain&quot;, &quot;UTF-8&quot;)
-        msgAlt.attach(msgPlain)
</del><ins>+            details['subject'] = msg['Subject'] = formatString % {
+                'summary' : details['summary']
+            }
</ins><span class="cx"> 
</span><del>-        # html version
-        msgHtmlRelated = MIMEMultipart(&quot;related&quot;, type=&quot;text/html&quot;)
-        msgAlt.attach(msgHtmlRelated)
-        htmlText = u&quot;&quot;&quot;
-&lt;html&gt;&lt;body&gt;&lt;div&gt;
-&lt;img src=&quot;cid:ical.jpg&quot;&gt;
-%s
-&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;
-&quot;&quot;&quot; % plainText
</del><ins>+            msgAlt = MIMEMultipart(&quot;alternative&quot;)
+            msg.attach(msgAlt)
+
+            # Get localized labels
+            if canceled:
+                details['inviteLabel'] = _(&quot;Event Canceled&quot;)
+            else:
+                if newInvitation:
+                    details['inviteLabel'] = _(&quot;Event Invitation&quot;)
+                else:
+                    details['inviteLabel'] = _(&quot;Event Update&quot;)
+
+            details['dateLabel'] = _(&quot;Date&quot;)
+            details['timeLabel'] = _(&quot;Time&quot;)
+            details['durationLabel'] = _(&quot;Duration&quot;)
+            details['recurrenceLabel'] = _(&quot;Occurs&quot;)
+            details['descLabel'] = _(&quot;Description&quot;)
+            details['orgLabel'] = _(&quot;Organizer&quot;)
+            details['attLabel'] = _(&quot;Attendees&quot;)
+            details['locLabel'] = _(&quot;Location&quot;)
+
+
+            plainAttendeeList = []
+            for cn, mailto in attendees:
+                if cn:
+                    plainAttendeeList.append(cn if not mailto else
+                        &quot;%s &lt;%s&gt;&quot; % (cn, mailto))
+                elif mailto:
+                    plainAttendeeList.append(&quot;&lt;%s&gt;&quot; % (mailto,))
+
+            details['plainAttendees'] = &quot;, &quot;.join(plainAttendeeList)
+
+            details['plainOrganizer'] = (orgCN if not orgEmail else
+                &quot;%s &lt;%s&gt;&quot; % (orgCN, orgEmail))
+
+            # plain text version
+            if canceled:
+                plainTemplate = u&quot;&quot;&quot;%(subject)s
+
+%(orgLabel)s: %(plainOrganizer)s
+%(dateLabel)s: %(dateInfo)s %(recurrenceInfo)s
+%(timeLabel)s: %(timeInfo)s %(durationInfo)s
+&quot;&quot;&quot;
+            else:
+                plainTemplate = u&quot;&quot;&quot;%(subject)s
+
+%(orgLabel)s: %(plainOrganizer)s
+%(locLabel)s: %(location)s
+%(dateLabel)s: %(dateInfo)s %(recurrenceInfo)s
+%(timeLabel)s: %(timeInfo)s %(durationInfo)s
+%(descLabel)s: %(description)s
+%(attLabel)s: %(plainAttendees)s
+&quot;&quot;&quot;
+
+            plainText = plainTemplate % details
+
+            msgPlain = MIMEText(plainText.encode(&quot;UTF-8&quot;), &quot;plain&quot;, &quot;UTF-8&quot;)
+            msgAlt.attach(msgPlain)
+
+            # html version
+            msgHtmlRelated = MIMEMultipart(&quot;related&quot;, type=&quot;text/html&quot;)
+            msgAlt.attach(msgHtmlRelated)
+
+
+            htmlAttendees = []
+            for cn, mailto in attendees:
+                if mailto:
+                    htmlAttendees.append('&lt;a href=&quot;mailto:%s&quot;&gt;%s&lt;/a&gt;' %
+                        (mailto, cn))
+                else:
+                    htmlAttendees.append(cn)
+
+            details['htmlAttendees'] = &quot;, &quot;.join(htmlAttendees)
+
+            if orgEmail:
+                details['htmlOrganizer'] = '&lt;a href=&quot;mailto:%s&quot;&gt;%s&lt;/a&gt;' % (
+                    orgEmail, orgCN)
+            else:
+                details['htmlOrganizer'] = orgCN
+
+            details['iconName'] = iconName
+
+            templateDir = config.Scheduling[&quot;iMIP&quot;][&quot;MailTemplatesDirectory&quot;].rstrip(&quot;/&quot;)
+            templateName = &quot;cancel.html&quot; if canceled else &quot;invite.html&quot;
+            templatePath = os.path.join(templateDir, templateName)
+
+            if not os.path.exists(templatePath):
+                # Fall back to built-in simple templates:
+                if canceled:
+
+                    htmlTemplate = u&quot;&quot;&quot;&lt;html&gt;
+    &lt;body&gt;&lt;div&gt;
+
+    &lt;h1&gt;%(subject)s&lt;/h1&gt;
+    &lt;p&gt;
+    &lt;h3&gt;%(orgLabel)s:&lt;/h3&gt; %(htmlOrganizer)s
+    &lt;/p&gt;
+    &lt;p&gt;
+    &lt;h3&gt;%(dateLabel)s:&lt;/h3&gt; %(dateInfo)s %(recurrenceInfo)s
+    &lt;/p&gt;
+    &lt;p&gt;
+    &lt;h3&gt;%(timeLabel)s:&lt;/h3&gt; %(timeInfo)s %(durationInfo)s
+    &lt;/p&gt;
+
+    &quot;&quot;&quot;
+
+                else:
+
+                    htmlTemplate = u&quot;&quot;&quot;&lt;html&gt;
+    &lt;body&gt;&lt;div&gt;
+    &lt;p&gt;%(inviteLabel)s&lt;/p&gt;
+
+    &lt;h1&gt;%(summary)s&lt;/h1&gt;
+    &lt;p&gt;
+    &lt;h3&gt;%(orgLabel)s:&lt;/h3&gt; %(htmlOrganizer)s
+    &lt;/p&gt;
+    &lt;p&gt;
+    &lt;h3&gt;%(locLabel)s:&lt;/h3&gt; %(location)s
+    &lt;/p&gt;
+    &lt;p&gt;
+    &lt;h3&gt;%(dateLabel)s:&lt;/h3&gt; %(dateInfo)s %(recurrenceInfo)s
+    &lt;/p&gt;
+    &lt;p&gt;
+    &lt;h3&gt;%(timeLabel)s:&lt;/h3&gt; %(timeInfo)s %(durationInfo)s
+    &lt;/p&gt;
+    &lt;p&gt;
+    &lt;h3&gt;%(descLabel)s:&lt;/h3&gt; %(description)s
+    &lt;/p&gt;
+    &lt;p&gt;
+    &lt;h3&gt;%(attLabel)s:&lt;/h3&gt; %(htmlAttendees)s
+    &lt;/p&gt;
+
+    &quot;&quot;&quot;
+            else: # HTML template file exists
+
+                with open(templatePath) as templateFile:
+                    htmlTemplate = templateFile.read()
+
+            htmlText = htmlTemplate % details
+
</ins><span class="cx">         msgHtml = MIMEText(htmlText.encode(&quot;UTF-8&quot;), &quot;html&quot;, &quot;UTF-8&quot;)
</span><span class="cx">         msgHtmlRelated.attach(msgHtml)
</span><span class="cx"> 
</span><span class="cx">         # an image for html version
</span><del>-        imageName = &quot;ical.jpg&quot;
-        imageFile = open(os.path.join(os.path.dirname(__file__),
-            &quot;images&quot;, &quot;mail&quot;, imageName))
-        msgImage = MIMEImage(imageFile.read(),
-            _subtype='jpeg;x-apple-mail-type=stationery;name=&quot;%s&quot;' %
-            (imageName,))
-        imageFile.close()
-        msgImage.add_header(&quot;Content-ID&quot;, &quot;&lt;%s&gt;&quot; % (imageName,))
-        msgImage.add_header(&quot;Content-Disposition&quot;, &quot;inline;filename=%s&quot; %
-            (imageName,))
-        msgHtmlRelated.attach(msgImage)
</del><ins>+        if os.path.exists(iconPath) and htmlTemplate.find(&quot;cid:%(iconName)s&quot;) != -1:
</ins><span class="cx"> 
</span><ins>+            with open(iconPath) as iconFile:
+                msgIcon = MIMEImage(iconFile.read(),
+                    _subtype='png;x-apple-mail-type=stationery;name=&quot;%s&quot;' %
+                    (iconName,))
+
+            msgIcon.add_header(&quot;Content-ID&quot;, &quot;&lt;%s&gt;&quot; % (iconName,))
+            msgIcon.add_header(&quot;Content-Disposition&quot;, &quot;inline;filename=%s&quot; %
+                (iconName,))
+            msgHtmlRelated.attach(msgIcon)
+
</ins><span class="cx">         # the icalendar attachment
</span><span class="cx">         self.log_debug(&quot;Mail gateway sending calendar body: %s&quot; % (str(calendar)))
</span><span class="cx">         msgIcal = MIMEText(str(calendar), &quot;calendar&quot;, &quot;UTF-8&quot;)
</span><span class="cx">         method = calendar.propertyValue(&quot;METHOD&quot;).lower()
</span><span class="cx">         msgIcal.set_param(&quot;method&quot;, method)
</span><ins>+        msgIcal.add_header(&quot;Content-ID&quot;, &quot;&lt;invitation.ics&gt;&quot;)
</ins><span class="cx">         msgIcal.add_header(&quot;Content-Disposition&quot;,
</span><span class="cx">             &quot;inline;filename=invitation.ics&quot;)
</span><span class="cx">         msg.attach(msgIcal)
</span><span class="lines">@@ -769,135 +975,55 @@
</span><span class="cx">         return msgId, msg.as_string()
</span><span class="cx"> 
</span><span class="cx"> 
</span><del>-    def _generateCalendarSummary(self, calendar, organizer):
</del><ins>+    def getEventDetails(self, calendar, language='en'):
</ins><span class="cx"> 
</span><span class="cx">         # Get the most appropriate component
</span><span class="cx">         component = calendar.masterComponent()
</span><span class="cx">         if component is None:
</span><span class="cx">             component = calendar.mainComponent(True)
</span><span class="cx"> 
</span><del>-        organizerProp = component.getOrganizerProperty()
-        if &quot;CN&quot; in organizerProp.params():
-            organizer = &quot;%s &lt;%s&gt;&quot; % (organizerProp.params()[&quot;CN&quot;][0],
-                organizer,)
</del><ins>+        results = { }
</ins><span class="cx"> 
</span><del>-        if calendar.propertyValue(&quot;METHOD&quot;) == &quot;CANCEL&quot;:
-            dtinfo = &quot;&quot;
-        else:
-            dtinfo = self._getDateTimeInfo(component)
</del><ins>+        dtStart = component.propertyNativeValue(&quot;DTSTART&quot;)
+        results['month'] = dtStart.month
+        results['day'] = dtStart.day
</ins><span class="cx"> 
</span><span class="cx">         summary = component.propertyValue(&quot;SUMMARY&quot;)
</span><span class="cx">         if summary is None:
</span><span class="cx">             summary = &quot;&quot;
</span><ins>+        results['summary'] = summary
</ins><span class="cx"> 
</span><span class="cx">         description = component.propertyValue(&quot;DESCRIPTION&quot;)
</span><span class="cx">         if description is None:
</span><span class="cx">             description = &quot;&quot;
</span><ins>+        results['description'] = description
</ins><span class="cx"> 
</span><del>-        return summary, &quot;&quot;&quot;
</del><ins>+        location = component.propertyValue(&quot;LOCATION&quot;)
+        if location is None:
+            location = &quot;&quot;
+        results['location'] = location
</ins><span class="cx"> 
</span><del>-Summary: %s
-Organizer: %s
-%sDescription: %s
</del><ins>+        with translationTo(language) as trans:
+            results['dateInfo'] = trans.date(component)
+            results['timeInfo'], duration = trans.time(component)
+            results['durationInfo'] = &quot;(%s)&quot; % (duration,) if duration else &quot;&quot;
</ins><span class="cx"> 
</span><del>-&quot;&quot;&quot; % (summary, organizer, dtinfo, description,)
-
-    def _getDateTimeInfo(self, component):
-
-        dtstart = component.propertyNativeValue(&quot;DTSTART&quot;)
-        tzid_start = component.getProperty(&quot;DTSTART&quot;).params().get(&quot;TZID&quot;, &quot;UTC&quot;)
-
-        dtend = component.propertyNativeValue(&quot;DTEND&quot;)
-        if dtend:
-            tzid_end = component.getProperty(&quot;DTEND&quot;).params().get(&quot;TZID&quot;, &quot;UTC&quot;)
-            duration = dtend - dtstart
-        else:
-            duration = component.propertyNativeValue(&quot;DURATION&quot;)
-            if duration:
-                dtend = dtstart + duration
-                tzid_end = tzid_start
</del><ins>+            for propertyName in (&quot;RRULE&quot;, &quot;RDATE&quot;, &quot;EXRULE&quot;, &quot;EXDATE&quot;,
+                &quot;RECURRENCE-ID&quot;):
+                if component.hasProperty(propertyName):
+                    results['recurrenceInfo'] = _(&quot;(Repeating)&quot;)
+                    break
</ins><span class="cx">             else:
</span><del>-                if isinstance(dtstart, datetime.date):
-                    dtend = None
-                    duration = datetime.timedelta(days=1)
-                else:
-                    dtend = dtstart + datetime.timedelta(days=1)
-                    dtend.hour = dtend.minute = dtend.second = 0
-                    duration = dtend - dtstart
-        result = &quot;Starts:      %s\n&quot; % (self._getDateTimeText(dtstart, tzid_start),)
-        if dtend is not None:
-            result += &quot;Ends:        %s\n&quot; % (self._getDateTimeText(dtend, tzid_end),)
-        result += &quot;Duration:    %s\n&quot; % (self._getDurationText(duration),)
</del><ins>+                results['recurrenceInfo'] = &quot;&quot;
</ins><span class="cx"> 
</span><del>-        if not isinstance(dtstart, datetime.datetime):
-            result += &quot;All Day\n&quot;
</del><ins>+        return results
</ins><span class="cx"> 
</span><del>-        for property_name in (&quot;RRULE&quot;, &quot;RDATE&quot;, &quot;EXRULE&quot;, &quot;EXDATE&quot;, &quot;RECURRENCE-ID&quot;,):
-            if component.hasProperty(property_name):
-                result += &quot;Recurring\n&quot;
-                break
</del><span class="cx"> 
</span><del>-        return result
</del><span class="cx"> 
</span><del>-    def _getDateTimeText(self, dtvalue, tzid):
</del><span class="cx"> 
</span><del>-        if isinstance(dtvalue, datetime.datetime):
-            timeformat = &quot;%A, %B %e, %Y %I:%M %p&quot;
-        elif isinstance(dtvalue, datetime.date):
-            timeformat = &quot;%A, %B %e, %Y&quot;
-            tzid = &quot;&quot;
-        if tzid:
-            tzid = &quot; (%s)&quot; % (tzid,)
</del><span class="cx"> 
</span><del>-        return &quot;%s%s&quot; % (dtvalue.strftime(timeformat), tzid,)
</del><span class="cx"> 
</span><del>-    def _getDurationText(self, duration):
</del><span class="cx"> 
</span><del>-        result = &quot;&quot;
-        if duration.days &gt; 0:
-            result += &quot;%d %s&quot; % (
-                duration.days,
-                self._pluralize(duration.days, &quot;day&quot;, &quot;days&quot;)
-            )
-
-        hours = duration.seconds / 3600
-        minutes = divmod(duration.seconds / 60, 60)[1]
-        seconds = divmod(duration.seconds, 60)[1]
-
-        if hours &gt; 0:
-            if result:
-                result += &quot;, &quot;
-            result += &quot;%d %s&quot; % (
-                hours,
-                self._pluralize(hours, &quot;hour&quot;, &quot;hours&quot;)
-            )
-
-        if minutes &gt; 0:
-            if result:
-                result += &quot;, &quot;
-            result += &quot;%d %s&quot; % (
-                minutes,
-                self._pluralize(minutes, &quot;minute&quot;, &quot;minutes&quot;)
-            )
-
-        if seconds &gt; 0:
-            if result:
-                result += &quot;, &quot;
-            result += &quot;%d %s&quot; % (
-                seconds,
-                self._pluralize(seconds, &quot;second&quot;, &quot;seconds&quot;)
-            )
-
-        return result
-
-    def _pluralize(self, number, unit1, unitS):
-        return unit1 if number == 1 else unitS
-
-
-
-
-
-
</del><span class="cx"> #
</span><span class="cx"> # POP3
</span><span class="cx"> #
</span><span class="lines">@@ -972,6 +1098,7 @@
</span><span class="cx">             from twisted.internet import reactor
</span><span class="cx">         self.reactor = reactor
</span><span class="cx">         self.nextPoll = None
</span><ins>+        self.noisy = False
</ins><span class="cx"> 
</span><span class="cx">     def retry(self, connector=None):
</span><span class="cx">         # TODO: if connector is None:
</span><span class="lines">@@ -1147,6 +1274,7 @@
</span><span class="cx">         if reactor is None:
</span><span class="cx">             from twisted.internet import reactor
</span><span class="cx">         self.reactor = reactor
</span><ins>+        self.noisy = False
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx">     def handleMessage(self, message):
</span></span></pre></div>
<a id="CalendarServertrunktwistedcaldavtestdatalocalesenLC_MESSAGEScalendarservermo"></a>
<div class="binary"><h4>Deleted: CalendarServer/trunk/twistedcaldav/test/data/locales/en/LC_MESSAGES/calendarserver.mo</h4>
<pre class="diff"><span>
<span class="cx">(Binary files differ)
</span></span></pre></div>
<a id="CalendarServertrunktwistedcaldavtestdatalocalesenLC_MESSAGEScalendarservermofromrev3323CalendarServerbranchesuserssagenlocalization3308twistedcaldavtestdatalocalesenLC_MESSAGEScalendarservermo"></a>
<div class="binary"><h4>Copied: CalendarServer/trunk/twistedcaldav/test/data/locales/en/LC_MESSAGES/calendarserver.mo (from rev 3323, CalendarServer/branches/users/sagen/localization-3308/twistedcaldav/test/data/locales/en/LC_MESSAGES/calendarserver.mo)</h4>
<pre class="diff"><span>
<span class="cx">(Binary files differ)
</span></span></pre></div>
<a id="CalendarServertrunktwistedcaldavtestdatalocalesenLC_MESSAGEScalendarserverpo"></a>
<div class="delfile"><h4>Deleted: CalendarServer/trunk/twistedcaldav/test/data/locales/en/LC_MESSAGES/calendarserver.po (3323 => 3325)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/sagen/localization-3308/twistedcaldav/test/data/locales/en/LC_MESSAGES/calendarserver.po        2008-11-06 01:01:07 UTC (rev 3323)
+++ CalendarServer/trunk/twistedcaldav/test/data/locales/en/LC_MESSAGES/calendarserver.po        2008-11-06 01:45:12 UTC (rev 3325)
</span><span class="lines">@@ -1,249 +0,0 @@
</span><del>-# SOME DESCRIPTIVE TITLE.
-# Copyright (C) YEAR ORGANIZATION
-# FIRST AUTHOR &lt;EMAIL@ADDRESS&gt;, YEAR.
-#
-msgid &quot;&quot;
-msgstr &quot;&quot;
-&quot;Project-Id-Version: PACKAGE VERSION\n&quot;
-&quot;POT-Creation-Date: 2008-10-24 15:03+PDT\n&quot;
-&quot;PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n&quot;
-&quot;Last-Translator: FULL NAME &lt;EMAIL@ADDRESS&gt;\n&quot;
-&quot;Language-Team: LANGUAGE &lt;LL@li.org&gt;\n&quot;
-&quot;MIME-Version: 1.0\n&quot;
-&quot;Content-Type: text/plain; charset=UTF-8\n&quot;
-&quot;Content-Transfer-Encoding: 8bit\n&quot;
-&quot;Generated-By: pygettext.py 1.5\n&quot;
-
-
-#: localization.py:171
-msgid &quot;All day&quot;
-msgstr &quot;&quot;
-
-#: localization.py:177
-msgid &quot;%(startTime)s to %(endTime)s&quot;
-msgstr &quot;&quot;
-
-#: localization.py:191
-msgid &quot;%(dayName)s, %(monthName)s %(dayNumber)d, %(yearNumber)d&quot;
-msgstr &quot;&quot;
-
-#: localization.py:207
-msgid &quot;AM&quot;
-msgstr &quot;&quot;
-
-#: localization.py:207
-msgid &quot;PM&quot;
-msgstr &quot;&quot;
-
-#: localization.py:213
-msgid &quot;%(hour12Number)d:%(minuteNumber)02d %(ampm)s&quot;
-msgstr &quot;&quot;
-
-#: localization.py:236
-msgid &quot;Monday&quot;
-msgstr &quot;&quot;
-
-#: localization.py:237
-msgid &quot;Tuesday&quot;
-msgstr &quot;&quot;
-
-#: localization.py:238
-msgid &quot;Wednesday&quot;
-msgstr &quot;&quot;
-
-#: localization.py:239
-msgid &quot;Thursday&quot;
-msgstr &quot;&quot;
-
-#: localization.py:240
-msgid &quot;Friday&quot;
-msgstr &quot;&quot;
-
-#: localization.py:241
-msgid &quot;Saturday&quot;
-msgstr &quot;&quot;
-
-#: localization.py:242
-msgid &quot;Sunday&quot;
-msgstr &quot;&quot;
-
-#: localization.py:246
-msgid &quot;Mon&quot;
-msgstr &quot;&quot;
-
-#: localization.py:247
-msgid &quot;Tue&quot;
-msgstr &quot;&quot;
-
-#: localization.py:248
-msgid &quot;Wed&quot;
-msgstr &quot;&quot;
-
-#: localization.py:249
-msgid &quot;Thu&quot;
-msgstr &quot;&quot;
-
-#: localization.py:250
-msgid &quot;Fri&quot;
-msgstr &quot;&quot;
-
-#: localization.py:251
-msgid &quot;Sun&quot;
-msgstr &quot;&quot;
-
-#: localization.py:252
-msgid &quot;Sat&quot;
-msgstr &quot;&quot;
-
-#: localization.py:257
-msgid &quot;January&quot;
-msgstr &quot;&quot;
-
-#: localization.py:258
-msgid &quot;February&quot;
-msgstr &quot;&quot;
-
-#: localization.py:259
-msgid &quot;March&quot;
-msgstr &quot;&quot;
-
-#: localization.py:260
-msgid &quot;April&quot;
-msgstr &quot;&quot;
-
-#: localization.py:261 localization.py:277
-msgid &quot;May&quot;
-msgstr &quot;&quot;
-
-#: localization.py:262
-msgid &quot;June&quot;
-msgstr &quot;&quot;
-
-#: localization.py:263
-msgid &quot;July&quot;
-msgstr &quot;&quot;
-
-#: localization.py:264
-msgid &quot;August&quot;
-msgstr &quot;&quot;
-
-#: localization.py:265
-msgid &quot;September&quot;
-msgstr &quot;&quot;
-
-#: localization.py:266
-msgid &quot;October&quot;
-msgstr &quot;&quot;
-
-#: localization.py:267
-msgid &quot;November&quot;
-msgstr &quot;&quot;
-
-#: localization.py:268
-msgid &quot;December&quot;
-msgstr &quot;&quot;
-
-#: localization.py:273
-msgid &quot;Jan&quot;
-msgstr &quot;&quot;
-
-#: localization.py:274
-msgid &quot;Feb&quot;
-msgstr &quot;&quot;
-
-#: localization.py:275
-msgid &quot;Mar&quot;
-msgstr &quot;&quot;
-
-#: localization.py:276
-msgid &quot;Apr&quot;
-msgstr &quot;&quot;
-
-#: localization.py:278
-msgid &quot;Jun&quot;
-msgstr &quot;&quot;
-
-#: localization.py:279
-msgid &quot;Jul&quot;
-msgstr &quot;&quot;
-
-#: localization.py:280
-msgid &quot;Aug&quot;
-msgstr &quot;&quot;
-
-#: localization.py:281
-msgid &quot;Sep&quot;
-msgstr &quot;&quot;
-
-#: localization.py:282
-msgid &quot;Oct&quot;
-msgstr &quot;&quot;
-
-#: localization.py:283
-msgid &quot;Nov&quot;
-msgstr &quot;&quot;
-
-#: localization.py:284
-msgid &quot;Dec&quot;
-msgstr &quot;&quot;
-
-#: mail.py:726 mail.py:755 mail.py:792
-msgid &quot;Event cancelled&quot;
-msgstr &quot;&quot;
-
-#: mail.py:727
-msgid &quot;Event invitation: %(summary)s&quot;
-msgstr &quot;&quot;
-
-#: mail.py:736
-msgid &quot;Event Invitation&quot;
-msgstr &quot;&quot;
-
-#: mail.py:737
-msgid &quot;Date&quot;
-msgstr &quot;&quot;
-
-#: mail.py:738
-msgid &quot;Time&quot;
-msgstr &quot;&quot;
-
-#: mail.py:739
-msgid &quot;Description&quot;
-msgstr &quot;&quot;
-
-#: mail.py:740
-msgid &quot;Organizer&quot;
-msgstr &quot;&quot;
-
-#: mail.py:741
-msgid &quot;Attendees&quot;
-msgstr &quot;&quot;
-
-#: mail.py:742
-msgid &quot;Location&quot;
-msgstr &quot;&quot;
-
-
-msgid &quot;1 day&quot;
-msgstr
-
-msgid &quot;%(dayCount)d days&quot;
-msgstr
-
-msgid &quot;1 hour&quot;
-
-msgid &quot;%(hourCount)d hours&quot;
-msgstr
-
-msgid &quot;1 minute&quot;
-msgstr
-
-msgid &quot;%(minuteCount)d minutes&quot;
-msgstr
-
-msgid &quot;1 second&quot;
-msgstr
-
-msgid &quot;%(secondCount)d seconds&quot;
-msgstr
-
</del></span></pre></div>
<a id="CalendarServertrunktwistedcaldavtestdatalocalesenLC_MESSAGEScalendarserverpofromrev3323CalendarServerbranchesuserssagenlocalization3308twistedcaldavtestdatalocalesenLC_MESSAGEScalendarserverpo"></a>
<div class="copfile"><h4>Copied: CalendarServer/trunk/twistedcaldav/test/data/locales/en/LC_MESSAGES/calendarserver.po (from rev 3323, CalendarServer/branches/users/sagen/localization-3308/twistedcaldav/test/data/locales/en/LC_MESSAGES/calendarserver.po) (0 => 3325)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twistedcaldav/test/data/locales/en/LC_MESSAGES/calendarserver.po                                (rev 0)
+++ CalendarServer/trunk/twistedcaldav/test/data/locales/en/LC_MESSAGES/calendarserver.po        2008-11-06 01:45:12 UTC (rev 3325)
</span><span class="lines">@@ -0,0 +1,249 @@
</span><ins>+# SOME DESCRIPTIVE TITLE.
+# Copyright (C) YEAR ORGANIZATION
+# FIRST AUTHOR &lt;EMAIL@ADDRESS&gt;, YEAR.
+#
+msgid &quot;&quot;
+msgstr &quot;&quot;
+&quot;Project-Id-Version: PACKAGE VERSION\n&quot;
+&quot;POT-Creation-Date: 2008-10-24 15:03+PDT\n&quot;
+&quot;PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n&quot;
+&quot;Last-Translator: FULL NAME &lt;EMAIL@ADDRESS&gt;\n&quot;
+&quot;Language-Team: LANGUAGE &lt;LL@li.org&gt;\n&quot;
+&quot;MIME-Version: 1.0\n&quot;
+&quot;Content-Type: text/plain; charset=UTF-8\n&quot;
+&quot;Content-Transfer-Encoding: 8bit\n&quot;
+&quot;Generated-By: pygettext.py 1.5\n&quot;
+
+
+#: localization.py:171
+msgid &quot;All day&quot;
+msgstr &quot;&quot;
+
+#: localization.py:177
+msgid &quot;%(startTime)s to %(endTime)s&quot;
+msgstr &quot;&quot;
+
+#: localization.py:191
+msgid &quot;%(dayName)s, %(monthName)s %(dayNumber)d, %(yearNumber)d&quot;
+msgstr &quot;&quot;
+
+#: localization.py:207
+msgid &quot;AM&quot;
+msgstr &quot;&quot;
+
+#: localization.py:207
+msgid &quot;PM&quot;
+msgstr &quot;&quot;
+
+#: localization.py:213
+msgid &quot;%(hour12Number)d:%(minuteNumber)02d %(ampm)s&quot;
+msgstr &quot;&quot;
+
+#: localization.py:236
+msgid &quot;Monday&quot;
+msgstr &quot;&quot;
+
+#: localization.py:237
+msgid &quot;Tuesday&quot;
+msgstr &quot;&quot;
+
+#: localization.py:238
+msgid &quot;Wednesday&quot;
+msgstr &quot;&quot;
+
+#: localization.py:239
+msgid &quot;Thursday&quot;
+msgstr &quot;&quot;
+
+#: localization.py:240
+msgid &quot;Friday&quot;
+msgstr &quot;&quot;
+
+#: localization.py:241
+msgid &quot;Saturday&quot;
+msgstr &quot;&quot;
+
+#: localization.py:242
+msgid &quot;Sunday&quot;
+msgstr &quot;&quot;
+
+#: localization.py:246
+msgid &quot;Mon&quot;
+msgstr &quot;&quot;
+
+#: localization.py:247
+msgid &quot;Tue&quot;
+msgstr &quot;&quot;
+
+#: localization.py:248
+msgid &quot;Wed&quot;
+msgstr &quot;&quot;
+
+#: localization.py:249
+msgid &quot;Thu&quot;
+msgstr &quot;&quot;
+
+#: localization.py:250
+msgid &quot;Fri&quot;
+msgstr &quot;&quot;
+
+#: localization.py:251
+msgid &quot;Sun&quot;
+msgstr &quot;&quot;
+
+#: localization.py:252
+msgid &quot;Sat&quot;
+msgstr &quot;&quot;
+
+#: localization.py:257
+msgid &quot;January&quot;
+msgstr &quot;&quot;
+
+#: localization.py:258
+msgid &quot;February&quot;
+msgstr &quot;&quot;
+
+#: localization.py:259
+msgid &quot;March&quot;
+msgstr &quot;&quot;
+
+#: localization.py:260
+msgid &quot;April&quot;
+msgstr &quot;&quot;
+
+#: localization.py:261 localization.py:277
+msgid &quot;May&quot;
+msgstr &quot;&quot;
+
+#: localization.py:262
+msgid &quot;June&quot;
+msgstr &quot;&quot;
+
+#: localization.py:263
+msgid &quot;July&quot;
+msgstr &quot;&quot;
+
+#: localization.py:264
+msgid &quot;August&quot;
+msgstr &quot;&quot;
+
+#: localization.py:265
+msgid &quot;September&quot;
+msgstr &quot;&quot;
+
+#: localization.py:266
+msgid &quot;October&quot;
+msgstr &quot;&quot;
+
+#: localization.py:267
+msgid &quot;November&quot;
+msgstr &quot;&quot;
+
+#: localization.py:268
+msgid &quot;December&quot;
+msgstr &quot;&quot;
+
+#: localization.py:273
+msgid &quot;Jan&quot;
+msgstr &quot;&quot;
+
+#: localization.py:274
+msgid &quot;Feb&quot;
+msgstr &quot;&quot;
+
+#: localization.py:275
+msgid &quot;Mar&quot;
+msgstr &quot;&quot;
+
+#: localization.py:276
+msgid &quot;Apr&quot;
+msgstr &quot;&quot;
+
+#: localization.py:278
+msgid &quot;Jun&quot;
+msgstr &quot;&quot;
+
+#: localization.py:279
+msgid &quot;Jul&quot;
+msgstr &quot;&quot;
+
+#: localization.py:280
+msgid &quot;Aug&quot;
+msgstr &quot;&quot;
+
+#: localization.py:281
+msgid &quot;Sep&quot;
+msgstr &quot;&quot;
+
+#: localization.py:282
+msgid &quot;Oct&quot;
+msgstr &quot;&quot;
+
+#: localization.py:283
+msgid &quot;Nov&quot;
+msgstr &quot;&quot;
+
+#: localization.py:284
+msgid &quot;Dec&quot;
+msgstr &quot;&quot;
+
+#: mail.py:726 mail.py:755 mail.py:792
+msgid &quot;Event cancelled&quot;
+msgstr &quot;&quot;
+
+#: mail.py:727
+msgid &quot;Event invitation: %(summary)s&quot;
+msgstr &quot;&quot;
+
+#: mail.py:736
+msgid &quot;Event Invitation&quot;
+msgstr &quot;&quot;
+
+#: mail.py:737
+msgid &quot;Date&quot;
+msgstr &quot;&quot;
+
+#: mail.py:738
+msgid &quot;Time&quot;
+msgstr &quot;&quot;
+
+#: mail.py:739
+msgid &quot;Description&quot;
+msgstr &quot;&quot;
+
+#: mail.py:740
+msgid &quot;Organizer&quot;
+msgstr &quot;&quot;
+
+#: mail.py:741
+msgid &quot;Attendees&quot;
+msgstr &quot;&quot;
+
+#: mail.py:742
+msgid &quot;Location&quot;
+msgstr &quot;&quot;
+
+
+msgid &quot;1 day&quot;
+msgstr
+
+msgid &quot;%(dayCount)d days&quot;
+msgstr
+
+msgid &quot;1 hour&quot;
+
+msgid &quot;%(hourCount)d hours&quot;
+msgstr
+
+msgid &quot;1 minute&quot;
+msgstr
+
+msgid &quot;%(minuteCount)d minutes&quot;
+msgstr
+
+msgid &quot;1 second&quot;
+msgstr
+
+msgid &quot;%(secondCount)d seconds&quot;
+msgstr
+
</ins></span></pre></div>
<a id="CalendarServertrunktwistedcaldavtestdatalocalespigLC_MESSAGEScalendarservermo"></a>
<div class="binary"><h4>Deleted: CalendarServer/trunk/twistedcaldav/test/data/locales/pig/LC_MESSAGES/calendarserver.mo</h4>
<pre class="diff"><span>
<span class="cx">(Binary files differ)
</span></span></pre></div>
<a id="CalendarServertrunktwistedcaldavtestdatalocalespigLC_MESSAGEScalendarservermofromrev3323CalendarServerbranchesuserssagenlocalization3308twistedcaldavtestdatalocalespigLC_MESSAGEScalendarservermo"></a>
<div class="binary"><h4>Copied: CalendarServer/trunk/twistedcaldav/test/data/locales/pig/LC_MESSAGES/calendarserver.mo (from rev 3323, CalendarServer/branches/users/sagen/localization-3308/twistedcaldav/test/data/locales/pig/LC_MESSAGES/calendarserver.mo)</h4>
<pre class="diff"><span>
<span class="cx">(Binary files differ)
</span></span></pre></div>
<a id="CalendarServertrunktwistedcaldavtestdatalocalespigLC_MESSAGEScalendarserverpo"></a>
<div class="delfile"><h4>Deleted: CalendarServer/trunk/twistedcaldav/test/data/locales/pig/LC_MESSAGES/calendarserver.po (3323 => 3325)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/branches/users/sagen/localization-3308/twistedcaldav/test/data/locales/pig/LC_MESSAGES/calendarserver.po        2008-11-06 01:01:07 UTC (rev 3323)
+++ CalendarServer/trunk/twistedcaldav/test/data/locales/pig/LC_MESSAGES/calendarserver.po        2008-11-06 01:45:12 UTC (rev 3325)
</span><span class="lines">@@ -1,250 +0,0 @@
</span><del>-# Pig Latin Translation
-# Copyright (C) YEAR ORGANIZATION
-# FIRST AUTHOR &lt;EMAIL@ADDRESS&gt;, YEAR.
-#
-msgid &quot;&quot;
-msgstr &quot;&quot;
-&quot;Project-Id-Version: PACKAGE VERSION\n&quot;
-&quot;POT-Creation-Date: 2008-10-24 15:03+PDT\n&quot;
-&quot;PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n&quot;
-&quot;Last-Translator: FULL NAME &lt;EMAIL@ADDRESS&gt;\n&quot;
-&quot;Language-Team: LANGUAGE &lt;LL@li.org&gt;\n&quot;
-&quot;MIME-Version: 1.0\n&quot;
-&quot;Content-Type: text/plain; charset=UTF-8\n&quot;
-&quot;Content-Transfer-Encoding: 8bit\n&quot;
-&quot;Generated-By: pygettext.py 1.5\n&quot;
-
-
-#: localization.py:171
-msgid &quot;All day&quot;
-msgstr &quot;Allway ayday&quot;
-
-#: localization.py:177
-msgid &quot;%(startTime)s to %(endTime)s&quot;
-msgstr &quot;%(startTime)s otay %(endTime)s&quot;
-
-#: localization.py:191
-msgid &quot;%(dayName)s, %(monthName)s %(dayNumber)d, %(yearNumber)d&quot;
-msgstr &quot;%(dayName)s, %(monthName)s %(dayNumber)d, %(yearNumber)d&quot;
-
-#: localization.py:207
-msgid &quot;AM&quot;
-msgstr &quot;AMWAY&quot;
-
-#: localization.py:207
-msgid &quot;PM&quot;
-msgstr &quot;PMAY&quot;
-
-#: localization.py:213
-msgid &quot;%(hour12Number)d:%(minuteNumber)02d %(ampm)s&quot;
-msgstr &quot;%(hour24Number)02d:%(minuteNumber)02d&quot;
-
-#: localization.py:236
-msgid &quot;Monday&quot;
-msgstr &quot;Ondaymay&quot;
-
-#: localization.py:237
-msgid &quot;Tuesday&quot;
-msgstr &quot;Uesdaytay&quot;
-
-#: localization.py:238
-msgid &quot;Wednesday&quot;
-msgstr &quot;Ednesdayway&quot;
-
-#: localization.py:239
-msgid &quot;Thursday&quot;
-msgstr &quot;Ursdaythay&quot;
-
-#: localization.py:240
-msgid &quot;Friday&quot;
-msgstr &quot;Idayfray&quot;
-
-#: localization.py:241
-msgid &quot;Saturday&quot;
-msgstr &quot;Aturdaysay&quot;
-
-#: localization.py:242
-msgid &quot;Sunday&quot;
-msgstr &quot;Undaysay&quot;
-
-#: localization.py:246
-msgid &quot;Mon&quot;
-msgstr &quot;&quot;
-
-#: localization.py:247
-msgid &quot;Tue&quot;
-msgstr &quot;&quot;
-
-#: localization.py:248
-msgid &quot;Wed&quot;
-msgstr &quot;&quot;
-
-#: localization.py:249
-msgid &quot;Thu&quot;
-msgstr &quot;&quot;
-
-#: localization.py:250
-msgid &quot;Fri&quot;
-msgstr &quot;&quot;
-
-#: localization.py:251
-msgid &quot;Sun&quot;
-msgstr &quot;&quot;
-
-#: localization.py:252
-msgid &quot;Sat&quot;
-msgstr &quot;&quot;
-
-#: localization.py:257
-msgid &quot;January&quot;
-msgstr &quot;Anuaryjay&quot;
-
-#: localization.py:258
-msgid &quot;February&quot;
-msgstr &quot;Ebruaryfay&quot;
-
-#: localization.py:259
-msgid &quot;March&quot;
-msgstr &quot;Archmay&quot;
-
-#: localization.py:260
-msgid &quot;April&quot;
-msgstr &quot;Aprilway&quot;
-
-#: localization.py:261 localization.py:277
-msgid &quot;May&quot;
-msgstr &quot;Aymay&quot;
-
-#: localization.py:262
-msgid &quot;June&quot;
-msgstr &quot;Unejay&quot;
-
-#: localization.py:263
-msgid &quot;July&quot;
-msgstr &quot;Ulyjay&quot;
-
-#: localization.py:264
-msgid &quot;August&quot;
-msgstr &quot;Augustway&quot;
-
-#: localization.py:265
-msgid &quot;September&quot;
-msgstr &quot;Eptembersay&quot;
-
-#: localization.py:266
-msgid &quot;October&quot;
-msgstr &quot;Octoberway&quot;
-
-#: localization.py:267
-msgid &quot;November&quot;
-msgstr &quot;Ovembernay&quot;
-
-#: localization.py:268
-msgid &quot;December&quot;
-msgstr &quot;Ecemberday&quot;
-
-#: localization.py:273
-msgid &quot;Jan&quot;
-msgstr &quot;&quot;
-
-#: localization.py:274
-msgid &quot;Feb&quot;
-msgstr &quot;&quot;
-
-#: localization.py:275
-msgid &quot;Mar&quot;
-msgstr &quot;&quot;
-
-#: localization.py:276
-msgid &quot;Apr&quot;
-msgstr &quot;&quot;
-
-#: localization.py:278
-msgid &quot;Jun&quot;
-msgstr &quot;&quot;
-
-#: localization.py:279
-msgid &quot;Jul&quot;
-msgstr &quot;&quot;
-
-#: localization.py:280
-msgid &quot;Aug&quot;
-msgstr &quot;&quot;
-
-#: localization.py:281
-msgid &quot;Sep&quot;
-msgstr &quot;&quot;
-
-#: localization.py:282
-msgid &quot;Oct&quot;
-msgstr &quot;&quot;
-
-#: localization.py:283
-msgid &quot;Nov&quot;
-msgstr &quot;&quot;
-
-#: localization.py:284
-msgid &quot;Dec&quot;
-msgstr &quot;&quot;
-
-#: mail.py:726 mail.py:755 mail.py:792
-msgid &quot;Event cancelled&quot;
-msgstr &quot;Eventway ancelledcay&quot;
-
-#: mail.py:727
-msgid &quot;Event invitation: %(summary)s&quot;
-msgstr &quot;Eventway invitationway: %(summary)s&quot;
-
-#: mail.py:736
-msgid &quot;Event Invitation&quot;
-msgstr &quot;Eventway invitationway&quot;
-
-#: mail.py:737
-msgid &quot;Date&quot;
-msgstr &quot;Ateday&quot;
-
-#: mail.py:738
-msgid &quot;Time&quot;
-msgstr &quot;Imetay&quot;
-
-#: mail.py:739
-msgid &quot;Description&quot;
-msgstr &quot;Escriptionday&quot;
-
-#: mail.py:740
-msgid &quot;Organizer&quot;
-msgstr &quot;Organizerway&quot;
-
-#: mail.py:741
-msgid &quot;Attendees&quot;
-msgstr &quot;Attendeesway&quot;
-
-#: mail.py:742
-msgid &quot;Location&quot;
-msgstr &quot;Ocationlay&quot;
-
-
-msgid &quot;1 day&quot;
-msgstr &quot;1 ayday&quot;
-
-msgid &quot;%(dayCount)d days&quot;
-msgstr &quot;%(dayCount)d aysday&quot;
-
-msgid &quot;1 hour&quot;
-msgstr &quot;1 ourhay&quot;
-
-msgid &quot;%(hourCount)d hours&quot;
-msgstr &quot;%(hourCount)d ourshay&quot;
-
-msgid &quot;1 minute&quot;
-msgstr &quot;1 inutemay&quot;
-
-msgid &quot;%(minuteCount)d minutes&quot;
-msgstr &quot;%(minuteCount)d inutesmay&quot;
-
-msgid &quot;1 second&quot;
-msgstr &quot;1 econdsay&quot;
-
-msgid &quot;%(secondCount)d seconds&quot;
-msgstr &quot;%(secondCount)d econdsay&quot;
-
</del></span></pre></div>
<a id="CalendarServertrunktwistedcaldavtestdatalocalespigLC_MESSAGEScalendarserverpofromrev3323CalendarServerbranchesuserssagenlocalization3308twistedcaldavtestdatalocalespigLC_MESSAGEScalendarserverpo"></a>
<div class="copfile"><h4>Copied: CalendarServer/trunk/twistedcaldav/test/data/locales/pig/LC_MESSAGES/calendarserver.po (from rev 3323, CalendarServer/branches/users/sagen/localization-3308/twistedcaldav/test/data/locales/pig/LC_MESSAGES/calendarserver.po) (0 => 3325)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twistedcaldav/test/data/locales/pig/LC_MESSAGES/calendarserver.po                                (rev 0)
+++ CalendarServer/trunk/twistedcaldav/test/data/locales/pig/LC_MESSAGES/calendarserver.po        2008-11-06 01:45:12 UTC (rev 3325)
</span><span class="lines">@@ -0,0 +1,250 @@
</span><ins>+# Pig Latin Translation
+# Copyright (C) YEAR ORGANIZATION
+# FIRST AUTHOR &lt;EMAIL@ADDRESS&gt;, YEAR.
+#
+msgid &quot;&quot;
+msgstr &quot;&quot;
+&quot;Project-Id-Version: PACKAGE VERSION\n&quot;
+&quot;POT-Creation-Date: 2008-10-24 15:03+PDT\n&quot;
+&quot;PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n&quot;
+&quot;Last-Translator: FULL NAME &lt;EMAIL@ADDRESS&gt;\n&quot;
+&quot;Language-Team: LANGUAGE &lt;LL@li.org&gt;\n&quot;
+&quot;MIME-Version: 1.0\n&quot;
+&quot;Content-Type: text/plain; charset=UTF-8\n&quot;
+&quot;Content-Transfer-Encoding: 8bit\n&quot;
+&quot;Generated-By: pygettext.py 1.5\n&quot;
+
+
+#: localization.py:171
+msgid &quot;All day&quot;
+msgstr &quot;Allway ayday&quot;
+
+#: localization.py:177
+msgid &quot;%(startTime)s to %(endTime)s&quot;
+msgstr &quot;%(startTime)s otay %(endTime)s&quot;
+
+#: localization.py:191
+msgid &quot;%(dayName)s, %(monthName)s %(dayNumber)d, %(yearNumber)d&quot;
+msgstr &quot;%(dayName)s, %(monthName)s %(dayNumber)d, %(yearNumber)d&quot;
+
+#: localization.py:207
+msgid &quot;AM&quot;
+msgstr &quot;AMWAY&quot;
+
+#: localization.py:207
+msgid &quot;PM&quot;
+msgstr &quot;PMAY&quot;
+
+#: localization.py:213
+msgid &quot;%(hour12Number)d:%(minuteNumber)02d %(ampm)s&quot;
+msgstr &quot;%(hour24Number)02d:%(minuteNumber)02d&quot;
+
+#: localization.py:236
+msgid &quot;Monday&quot;
+msgstr &quot;Ondaymay&quot;
+
+#: localization.py:237
+msgid &quot;Tuesday&quot;
+msgstr &quot;Uesdaytay&quot;
+
+#: localization.py:238
+msgid &quot;Wednesday&quot;
+msgstr &quot;Ednesdayway&quot;
+
+#: localization.py:239
+msgid &quot;Thursday&quot;
+msgstr &quot;Ursdaythay&quot;
+
+#: localization.py:240
+msgid &quot;Friday&quot;
+msgstr &quot;Idayfray&quot;
+
+#: localization.py:241
+msgid &quot;Saturday&quot;
+msgstr &quot;Aturdaysay&quot;
+
+#: localization.py:242
+msgid &quot;Sunday&quot;
+msgstr &quot;Undaysay&quot;
+
+#: localization.py:246
+msgid &quot;Mon&quot;
+msgstr &quot;&quot;
+
+#: localization.py:247
+msgid &quot;Tue&quot;
+msgstr &quot;&quot;
+
+#: localization.py:248
+msgid &quot;Wed&quot;
+msgstr &quot;&quot;
+
+#: localization.py:249
+msgid &quot;Thu&quot;
+msgstr &quot;&quot;
+
+#: localization.py:250
+msgid &quot;Fri&quot;
+msgstr &quot;&quot;
+
+#: localization.py:251
+msgid &quot;Sun&quot;
+msgstr &quot;&quot;
+
+#: localization.py:252
+msgid &quot;Sat&quot;
+msgstr &quot;&quot;
+
+#: localization.py:257
+msgid &quot;January&quot;
+msgstr &quot;Anuaryjay&quot;
+
+#: localization.py:258
+msgid &quot;February&quot;
+msgstr &quot;Ebruaryfay&quot;
+
+#: localization.py:259
+msgid &quot;March&quot;
+msgstr &quot;Archmay&quot;
+
+#: localization.py:260
+msgid &quot;April&quot;
+msgstr &quot;Aprilway&quot;
+
+#: localization.py:261 localization.py:277
+msgid &quot;May&quot;
+msgstr &quot;Aymay&quot;
+
+#: localization.py:262
+msgid &quot;June&quot;
+msgstr &quot;Unejay&quot;
+
+#: localization.py:263
+msgid &quot;July&quot;
+msgstr &quot;Ulyjay&quot;
+
+#: localization.py:264
+msgid &quot;August&quot;
+msgstr &quot;Augustway&quot;
+
+#: localization.py:265
+msgid &quot;September&quot;
+msgstr &quot;Eptembersay&quot;
+
+#: localization.py:266
+msgid &quot;October&quot;
+msgstr &quot;Octoberway&quot;
+
+#: localization.py:267
+msgid &quot;November&quot;
+msgstr &quot;Ovembernay&quot;
+
+#: localization.py:268
+msgid &quot;December&quot;
+msgstr &quot;Ecemberday&quot;
+
+#: localization.py:273
+msgid &quot;Jan&quot;
+msgstr &quot;&quot;
+
+#: localization.py:274
+msgid &quot;Feb&quot;
+msgstr &quot;&quot;
+
+#: localization.py:275
+msgid &quot;Mar&quot;
+msgstr &quot;&quot;
+
+#: localization.py:276
+msgid &quot;Apr&quot;
+msgstr &quot;&quot;
+
+#: localization.py:278
+msgid &quot;Jun&quot;
+msgstr &quot;&quot;
+
+#: localization.py:279
+msgid &quot;Jul&quot;
+msgstr &quot;&quot;
+
+#: localization.py:280
+msgid &quot;Aug&quot;
+msgstr &quot;&quot;
+
+#: localization.py:281
+msgid &quot;Sep&quot;
+msgstr &quot;&quot;
+
+#: localization.py:282
+msgid &quot;Oct&quot;
+msgstr &quot;&quot;
+
+#: localization.py:283
+msgid &quot;Nov&quot;
+msgstr &quot;&quot;
+
+#: localization.py:284
+msgid &quot;Dec&quot;
+msgstr &quot;&quot;
+
+#: mail.py:726 mail.py:755 mail.py:792
+msgid &quot;Event cancelled&quot;
+msgstr &quot;Eventway ancelledcay&quot;
+
+#: mail.py:727
+msgid &quot;Event invitation: %(summary)s&quot;
+msgstr &quot;Eventway invitationway: %(summary)s&quot;
+
+#: mail.py:736
+msgid &quot;Event Invitation&quot;
+msgstr &quot;Eventway invitationway&quot;
+
+#: mail.py:737
+msgid &quot;Date&quot;
+msgstr &quot;Ateday&quot;
+
+#: mail.py:738
+msgid &quot;Time&quot;
+msgstr &quot;Imetay&quot;
+
+#: mail.py:739
+msgid &quot;Description&quot;
+msgstr &quot;Escriptionday&quot;
+
+#: mail.py:740
+msgid &quot;Organizer&quot;
+msgstr &quot;Organizerway&quot;
+
+#: mail.py:741
+msgid &quot;Attendees&quot;
+msgstr &quot;Attendeesway&quot;
+
+#: mail.py:742
+msgid &quot;Location&quot;
+msgstr &quot;Ocationlay&quot;
+
+
+msgid &quot;1 day&quot;
+msgstr &quot;1 ayday&quot;
+
+msgid &quot;%(dayCount)d days&quot;
+msgstr &quot;%(dayCount)d aysday&quot;
+
+msgid &quot;1 hour&quot;
+msgstr &quot;1 ourhay&quot;
+
+msgid &quot;%(hourCount)d hours&quot;
+msgstr &quot;%(hourCount)d ourshay&quot;
+
+msgid &quot;1 minute&quot;
+msgstr &quot;1 inutemay&quot;
+
+msgid &quot;%(minuteCount)d minutes&quot;
+msgstr &quot;%(minuteCount)d inutesmay&quot;
+
+msgid &quot;1 second&quot;
+msgstr &quot;1 econdsay&quot;
+
+msgid &quot;%(secondCount)d seconds&quot;
+msgstr &quot;%(secondCount)d econdsay&quot;
+
</ins></span></pre></div>
<a id="CalendarServertrunktwistedcaldavtesttest_localizationpyfromrev3323CalendarServerbranchesuserssagenlocalization3308twistedcaldavtesttest_localizationpy"></a>
<div class="copfile"><h4>Copied: CalendarServer/trunk/twistedcaldav/test/test_localization.py (from rev 3323, CalendarServer/branches/users/sagen/localization-3308/twistedcaldav/test/test_localization.py) (0 => 3325)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twistedcaldav/test/test_localization.py                                (rev 0)
+++ CalendarServer/trunk/twistedcaldav/test/test_localization.py        2008-11-06 01:45:12 UTC (rev 3325)
</span><span class="lines">@@ -0,0 +1,137 @@
</span><ins>+##
+# Copyright (c) 2008 Apple Inc. All rights reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an &quot;AS IS&quot; BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+##
+
+from __future__ import with_statement
+
+from twisted.trial.unittest import TestCase
+from twistedcaldav.localization import translationTo
+from twistedcaldav.ical import Component
+from datetime import datetime, time
+import os
+
+def getComp(str):
+    calendar = Component.fromString(str)
+    comp = calendar.masterComponent()
+    if comp is None:
+        comp = calendar.mainComponent(True)
+    return comp
+
+data = (
+    ('1-hour-long-morning', getComp('BEGIN:VCALENDAR\r\nVERSION:2.0\r\nCALSCALE:GREGORIAN\r\nMETHOD:REQUEST\r\nPRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN\r\nBEGIN:VTIMEZONE\r\nTZID:US/Pacific\r\nBEGIN:STANDARD\r\nDTSTART:20071104T020000\r\nRRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU\r\nTZNAME:PST\r\nTZOFFSETFROM:-0700\r\nTZOFFSETTO:-0800\r\nEND:STANDARD\r\nBEGIN:DAYLIGHT\r\nDTSTART:20070311T020000\r\nRRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU\r\nTZNAME:PDT\r\nTZOFFSETFROM:-0800\r\nTZOFFSETTO:-0700\r\nEND:DAYLIGHT\r\nEND:VTIMEZONE\r\nBEGIN:VEVENT\r\nUID:C7C037CC-1485-461B-8866-777C662C5930\r\nDTSTART;TZID=US/Pacific:20081025T091500\r\nDTEND;TZID=US/Pacific:20081025T101501\r\nATTENDEE;CN=test@systemcall.com;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;RSV\r\n P=TRUE:mailto:test@systemcall.com\r\nATTENDEE;CN=Test User;CUTYPE=INDIVIDUAL;PARTSTAT=ACCEPTED:mailto:testuser@\r\n example.com\r\nCREATED:20081024T181749Z\r\nDTSTAMP:20081024T183142Z\r\nORGANIZER;CN=Test User:mailto:testuser@ex
 ample.com\r\nSEQUENCE:5\r\nSUMMARY:testing\r\nTRANSP:OPAQUE\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n')),
+
+    ('2-hour-long-evening', getComp('BEGIN:VCALENDAR\r\nVERSION:2.0\r\nCALSCALE:GREGORIAN\r\nMETHOD:REQUEST\r\nPRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN\r\nBEGIN:VTIMEZONE\r\nTZID:US/Pacific\r\nBEGIN:STANDARD\r\nDTSTART:20071104T020000\r\nRRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU\r\nTZNAME:PST\r\nTZOFFSETFROM:-0700\r\nTZOFFSETTO:-0800\r\nEND:STANDARD\r\nBEGIN:DAYLIGHT\r\nDTSTART:20070311T020000\r\nRRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU\r\nTZNAME:PDT\r\nTZOFFSETFROM:-0800\r\nTZOFFSETTO:-0700\r\nEND:DAYLIGHT\r\nEND:VTIMEZONE\r\nBEGIN:VEVENT\r\nUID:C7C037CC-1485-461B-8866-777C662C5930\r\nDTSTART;TZID=US/Pacific:20081025T131500\r\nDTEND;TZID=US/Pacific:20081025T151502\r\nATTENDEE;CN=test@systemcall.com;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;RSV\r\n P=TRUE:mailto:test@systemcall.com\r\nATTENDEE;CN=Test User;CUTYPE=INDIVIDUAL;PARTSTAT=ACCEPTED:mailto:testuser@\r\n example.com\r\nCREATED:20081024T181749Z\r\nDTSTAMP:20081024T183142Z\r\nORGANIZER;CN=Test User:mailto:testuser@ex
 ample.com\r\nSEQUENCE:5\r\nSUMMARY:testing\r\nTRANSP:OPAQUE\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n')),
+
+    ('3-hour-long-cross-noon', getComp('BEGIN:VCALENDAR\r\nVERSION:2.0\r\nCALSCALE:GREGORIAN\r\nMETHOD:REQUEST\r\nPRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN\r\nBEGIN:VTIMEZONE\r\nTZID:US/Pacific\r\nBEGIN:STANDARD\r\nDTSTART:20071104T020000\r\nRRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU\r\nTZNAME:PST\r\nTZOFFSETFROM:-0700\r\nTZOFFSETTO:-0800\r\nEND:STANDARD\r\nBEGIN:DAYLIGHT\r\nDTSTART:20070311T020000\r\nRRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU\r\nTZNAME:PDT\r\nTZOFFSETFROM:-0800\r\nTZOFFSETTO:-0700\r\nEND:DAYLIGHT\r\nEND:VTIMEZONE\r\nBEGIN:VEVENT\r\nUID:C7C037CC-1485-461B-8866-777C662C5930\r\nDTSTART;TZID=US/Pacific:20081025T110500\r\nDTEND;TZID=US/Pacific:20081025T141500\r\nATTENDEE;CN=test@systemcall.com;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;RSV\r\n P=TRUE:mailto:test@systemcall.com\r\nATTENDEE;CN=Test User;CUTYPE=INDIVIDUAL;PARTSTAT=ACCEPTED:mailto:testuser@\r\n example.com\r\nCREATED:20081024T181749Z\r\nDTSTAMP:20081024T183142Z\r\nORGANIZER;CN=Test User:mailto:testuser
 @example.com\r\nSEQUENCE:5\r\nSUMMARY:testing\r\nTRANSP:OPAQUE\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n')),
+
+    ('all-day', getComp('BEGIN:VCALENDAR\r\nVERSION:2.0\r\nCALSCALE:GREGORIAN\r\nMETHOD:REQUEST\r\nPRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN\r\nBEGIN:VTIMEZONE\r\nTZID:US/Pacific\r\nBEGIN:STANDARD\r\nDTSTART:20071104T020000\r\nRRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU\r\nTZNAME:PST\r\nTZOFFSETFROM:-0700\r\nTZOFFSETTO:-0800\r\nEND:STANDARD\r\nBEGIN:DAYLIGHT\r\nDTSTART:20070311T020000\r\nRRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU\r\nTZNAME:PDT\r\nTZOFFSETFROM:-0800\r\nTZOFFSETTO:-0700\r\nEND:DAYLIGHT\r\nEND:VTIMEZONE\r\nBEGIN:VEVENT\r\nUID:C7C037CC-1485-461B-8866-777C662C5930\r\nDTSTART;TZID=US/Pacific:20081025\r\nATTENDEE;CN=test@systemcall.com;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;RSV\r\n P=TRUE:mailto:test@systemcall.com\r\nATTENDEE;CN=Test User;CUTYPE=INDIVIDUAL;PARTSTAT=ACCEPTED:mailto:testuser@\r\n example.com\r\nCREATED:20081024T181749Z\r\nDTSTAMP:20081024T183142Z\r\nORGANIZER;CN=Test User:mailto:testuser@example.com\r\nSEQUENCE:5\r\nSUMMARY:testing\r\nTRANSP:OPAQUE\
 r\nEND:VEVENT\r\nEND:VCALENDAR\r\n')),
+
+    ('instantaneous', getComp('BEGIN:VCALENDAR\r\nVERSION:2.0\r\nCALSCALE:GREGORIAN\r\nMETHOD:REQUEST\r\nPRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN\r\nBEGIN:VTIMEZONE\r\nTZID:US/Pacific\r\nBEGIN:STANDARD\r\nDTSTART:20071104T020000\r\nRRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU\r\nTZNAME:PST\r\nTZOFFSETFROM:-0700\r\nTZOFFSETTO:-0800\r\nEND:STANDARD\r\nBEGIN:DAYLIGHT\r\nDTSTART:20070311T020000\r\nRRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU\r\nTZNAME:PDT\r\nTZOFFSETFROM:-0800\r\nTZOFFSETTO:-0700\r\nEND:DAYLIGHT\r\nEND:VTIMEZONE\r\nBEGIN:VEVENT\r\nUID:C7C037CC-1485-461B-8866-777C662C5930\r\nDTSTART;TZID=US/Pacific:20081025T131500\r\nDTEND;TZID=US/Pacific:20081025T131500\r\nATTENDEE;CN=test@systemcall.com;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;RSV\r\n P=TRUE:mailto:test@systemcall.com\r\nATTENDEE;CN=Test User;CUTYPE=INDIVIDUAL;PARTSTAT=ACCEPTED:mailto:testuser@\r\n example.com\r\nCREATED:20081024T181749Z\r\nDTSTAMP:20081024T183142Z\r\nORGANIZER;CN=Test User:mailto:testuser@example.
 com\r\nSEQUENCE:5\r\nSUMMARY:testing\r\nTRANSP:OPAQUE\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n')),
+
+    ('cross-timezone', getComp('BEGIN:VCALENDAR\r\nVERSION:2.0\r\nCALSCALE:GREGORIAN\r\nMETHOD:REQUEST\r\nPRODID:-//CALENDARSERVER.ORG//NONSGML Version 1//EN\r\nBEGIN:VTIMEZONE\r\nTZID:US/Pacific\r\nBEGIN:STANDARD\r\nDTSTART:20071104T020000\r\nRRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU\r\nTZNAME:PST\r\nTZOFFSETFROM:-0700\r\nTZOFFSETTO:-0800\r\nEND:STANDARD\r\nBEGIN:DAYLIGHT\r\nDTSTART:20070311T020000\r\nRRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU\r\nTZNAME:PDT\r\nTZOFFSETFROM:-0800\r\nTZOFFSETTO:-0700\r\nEND:DAYLIGHT\r\nEND:VTIMEZONE\r\nBEGIN:VTIMEZONE\r\nTZID:US/Eastern\r\nBEGIN:STANDARD\r\nDTSTART:20071104T020000\r\nRRULE:FREQ=YEARLY;BYMONTH=11;BYDAY=1SU\r\nTZNAME:EST\r\nTZOFFSETFROM:-0400\r\nTZOFFSETTO:-0500\r\nEND:STANDARD\r\nBEGIN:DAYLIGHT\r\nDTSTART:20070311T020000\r\nRRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=2SU\r\nTZNAME:EDT\r\nTZOFFSETFROM:-0500\r\nTZOFFSETTO:-0400\r\nEND:DAYLIGHT\r\nEND:VTIMEZONE\r\nBEGIN:VEVENT\r\nUID:C7C037CC-1485-461B-8866-777C662C5930\r\nDTSTART;TZID=US/Pacific:
 20081025T110500\r\nDTEND;TZID=US/Eastern:20081025T181500\r\nATTENDEE;CN=test@systemcall.com;CUTYPE=INDIVIDUAL;ROLE=REQ-PARTICIPANT;RSV\r\n P=TRUE:mailto:test@systemcall.com\r\nATTENDEE;CN=Test User;CUTYPE=INDIVIDUAL;PARTSTAT=ACCEPTED:mailto:testuser@\r\n example.com\r\nCREATED:20081024T181749Z\r\nDTSTAMP:20081024T183142Z\r\nORGANIZER;CN=Test User:mailto:testuser@example.com\r\nSEQUENCE:5\r\nSUMMARY:testing\r\nTRANSP:OPAQUE\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n')),
+
+
+)
+
+localeDir = os.path.join(os.path.dirname(__file__), &quot;data&quot;, &quot;locales&quot;)
+
+class LocalizationTests(TestCase):
+
+    def test_BasicStringLocalization(self):
+
+        with translationTo('pig', localeDir=localeDir):
+
+            self.assertEquals(_(&quot;All day&quot;), &quot;Allway ayday&quot;)
+
+            self.assertEquals(_(&quot;%(startTime)s to %(endTime)s&quot;) %
+                { 'startTime' : 'a', 'endTime' : 'b' },
+                &quot;a otay b&quot;
+            )
+
+    def test_TimeFormattingAMPM(self):
+
+        with translationTo('en', localeDir=localeDir) as t:
+
+            self.assertEquals(t.dtTime(time(0,0)), &quot;12:00 AM&quot;)
+            self.assertEquals(t.dtTime(time(12,0)), &quot;12:00 PM&quot;)
+            self.assertEquals(t.dtTime(time(23,59)), &quot;11:59 PM&quot;)
+            self.assertEquals(t.dtTime(time(6,5)), &quot;6:05 AM&quot;)
+            self.assertEquals(t.dtTime(time(16,5)), &quot;4:05 PM&quot;)
+
+    def test_TimeFormatting24Hour(self):
+
+        with translationTo('pig', localeDir=localeDir) as t:
+
+            self.assertEquals(t.dtTime(time(0,0)), &quot;00:00&quot;)
+            self.assertEquals(t.dtTime(time(12,0)), &quot;12:00&quot;)
+            self.assertEquals(t.dtTime(time(23,59)), &quot;23:59&quot;)
+            self.assertEquals(t.dtTime(time(6,5)), &quot;06:05&quot;)
+            self.assertEquals(t.dtTime(time(16,5)), &quot;16:05&quot;)
+
+    def test_CalendarFormatting(self):
+
+        with translationTo('en', localeDir=localeDir) as t:
+
+            comp = data[0][1]
+            self.assertEquals(t.date(comp), &quot;Saturday, October 25, 2008&quot;)
+            self.assertEquals(t.time(comp),
+                (u'9:15 AM to 10:15 AM PDT', u'1 hour 1 second'))
+
+            comp = data[1][1]
+            self.assertEquals(t.time(comp),
+                (u'1:15 PM to 3:15 PM PDT', u'2 hours 2 seconds'))
+
+            comp = data[2][1]
+            self.assertEquals(t.time(comp),
+                (u'11:05 AM to 2:15 PM PDT', u'3 hours 10 minutes'))
+
+            comp = data[3][1]
+            self.assertEquals(t.time(comp),
+                (&quot;&quot;, u'All day'))
+
+            comp = data[4][1]
+            self.assertEquals(t.time(comp),
+                (u'1:15 PM PDT', &quot;&quot;))
+
+            comp = data[5][1]
+            self.assertEquals(t.time(comp),
+                (u'11:05 AM PDT to 6:15 PM EDT', u'4 hours 10 minutes'))
+
+        with translationTo('pig', localeDir=localeDir) as t:
+
+            comp = data[0][1]
+            self.assertEquals(t.date(comp), 'Aturdaysay, Octoberway 25, 2008')
+            self.assertEquals(t.time(comp),
+                (u'09:15 otay 10:15 PDT', u'1 ourhay 1 econdsay'))
+
+            comp = data[1][1]
+            self.assertEquals(t.time(comp),
+                (u'13:15 otay 15:15 PDT', u'2 ourshay 2 econdsay'))
+
+            comp = data[2][1]
+            self.assertEquals(t.time(comp),
+                (u'11:05 otay 14:15 PDT', u'3 ourshay 10 inutesmay'))
+
+            comp = data[3][1]
+            self.assertEquals(t.time(comp),
+                (&quot;&quot;, u'Allway ayday'))
+
+            comp = data[4][1]
+            self.assertEquals(t.time(comp),
+                (u'13:15 PDT', &quot;&quot;))
+
+            comp = data[5][1]
+            self.assertEquals(t.time(comp),
+                (u'11:05 PDT otay 18:15 EDT', u'4 ourshay 10 inutesmay'))
</ins></span></pre></div>
<a id="CalendarServertrunktwistedcaldavtesttest_mailpy"></a>
<div class="modfile"><h4>Modified: CalendarServer/trunk/twistedcaldav/test/test_mail.py (3324 => 3325)</h4>
<pre class="diff"><span>
<span class="info">--- CalendarServer/trunk/twistedcaldav/test/test_mail.py        2008-11-06 01:28:37 UTC (rev 3324)
+++ CalendarServer/trunk/twistedcaldav/test/test_mail.py        2008-11-06 01:45:12 UTC (rev 3325)
</span><span class="lines">@@ -57,7 +57,7 @@
</span><span class="cx"> 
</span><span class="cx">         # Make sure a known token *is* processed
</span><span class="cx">         token = self.handler.db.createToken(&quot;mailto:user01@example.com&quot;,
</span><del>-            &quot;mailto:user02@example.com&quot;)
</del><ins>+            &quot;mailto:user02@example.com&quot;, &quot;1E71F9C8-AEDA-48EB-98D0-76E898F6BB5C&quot;)
</ins><span class="cx">         calBody = template % token
</span><span class="cx">         organizer, attendee, calendar, msgId = self.handler.processDSN(calBody,
</span><span class="cx">             &quot;xyzzy&quot;, echo)
</span><span class="lines">@@ -78,7 +78,7 @@
</span><span class="cx">         self.assertEquals(result, None)
</span><span class="cx"> 
</span><span class="cx">         # Make sure a known token *is* processed
</span><del>-        self.handler.db.createToken(&quot;mailto:user01@example.com&quot;, &quot;mailto:xyzzy@example.com&quot;, token=&quot;d7cdf68d-8b73-4df1-ad3b-f08002fb285f&quot;)
</del><ins>+        self.handler.db.createToken(&quot;mailto:user01@example.com&quot;, &quot;mailto:xyzzy@example.com&quot;, icaluid=&quot;1E71F9C8-AEDA-48EB-98D0-76E898F6BB5C&quot;, token=&quot;d7cdf68d-8b73-4df1-ad3b-f08002fb285f&quot;)
</ins><span class="cx">         organizer, attendee, calendar, msgId = self.handler.processReply(msg,
</span><span class="cx">             echo)
</span><span class="cx">         self.assertEquals(organizer, 'mailto:user01@example.com')
</span><span class="lines">@@ -90,7 +90,7 @@
</span><span class="cx">             file(os.path.join(self.dataDir, 'reply_missing_organizer')).read()
</span><span class="cx">         )
</span><span class="cx">         # stick the token in the database first
</span><del>-        self.handler.db.createToken(&quot;mailto:user01@example.com&quot;, &quot;mailto:xyzzy@example.com&quot;, token=&quot;d7cdf68d-8b73-4df1-ad3b-f08002fb285f&quot;)
</del><ins>+        self.handler.db.createToken(&quot;mailto:user01@example.com&quot;, &quot;mailto:xyzzy@example.com&quot;, icaluid=&quot;1E71F9C8-AEDA-48EB-98D0-76E898F6BB5C&quot;, token=&quot;d7cdf68d-8b73-4df1-ad3b-f08002fb285f&quot;)
</ins><span class="cx"> 
</span><span class="cx">         organizer, attendee, calendar, msgId = self.handler.processReply(msg,
</span><span class="cx">             echo)
</span><span class="lines">@@ -105,9 +105,9 @@
</span><span class="cx">     def test_tokens(self):
</span><span class="cx">         self.assertEquals(self.db.lookupByToken(&quot;xyzzy&quot;), None)
</span><span class="cx"> 
</span><del>-        token = self.db.createToken(&quot;organizer&quot;, &quot;attendee&quot;)
-        self.assertEquals(self.db.getToken(&quot;organizer&quot;, &quot;attendee&quot;), token)
</del><ins>+        token = self.db.createToken(&quot;organizer&quot;, &quot;attendee&quot;, &quot;icaluid&quot;)
+        self.assertEquals(self.db.getToken(&quot;organizer&quot;, &quot;attendee&quot;, &quot;icaluid&quot;), token)
</ins><span class="cx">         self.assertEquals(self.db.lookupByToken(token),
</span><del>-            (&quot;organizer&quot;, &quot;attendee&quot;))
</del><ins>+            (&quot;organizer&quot;, &quot;attendee&quot;, &quot;icaluid&quot;))
</ins><span class="cx">         self.db.deleteToken(token)
</span><span class="cx">         self.assertEquals(self.db.lookupByToken(token), None)
</span></span></pre>
</div>
</div>

</body>
</html>