[CalendarServer-changes] [15610] CalendarServer/trunk/twistedcaldav
source_changes at macosforge.org
source_changes at macosforge.org
Thu May 19 09:22:09 PDT 2016
Revision: 15610
http://trac.calendarserver.org//changeset/15610
Author: cdaboo at apple.com
Date: 2016-05-19 09:22:09 -0700 (Thu, 19 May 2016)
Log Message:
-----------
Fix failure to translate localization strings on OS X.
Modified Paths:
--------------
CalendarServer/trunk/twistedcaldav/localization.py
CalendarServer/trunk/twistedcaldav/test/test_localization.py
Added Paths:
-----------
CalendarServer/trunk/twistedcaldav/test/data/translations/
CalendarServer/trunk/twistedcaldav/test/data/translations/Testlang.lproj/
CalendarServer/trunk/twistedcaldav/test/data/translations/Testlang.lproj/calendarserver.strings
Modified: CalendarServer/trunk/twistedcaldav/localization.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/localization.py 2016-05-19 16:19:55 UTC (rev 15609)
+++ CalendarServer/trunk/twistedcaldav/localization.py 2016-05-19 16:22:09 UTC (rev 15610)
@@ -27,8 +27,8 @@
from pycalendar.duration import Duration
try:
- from osx.corefoundation import CFError
- from osx.utils import CFLocaleRef, CFDataRef, CFPropertyListRef
+ from osx.corefoundation import CFError, CFDataRef
+ from osx.utils import CFLocaleRef, CFPropertyListRef
foundationImported = True
except ImportError:
foundationImported = False
Added: CalendarServer/trunk/twistedcaldav/test/data/translations/Testlang.lproj/calendarserver.strings
===================================================================
(Binary files differ)
Property changes on: CalendarServer/trunk/twistedcaldav/test/data/translations/Testlang.lproj/calendarserver.strings
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Modified: CalendarServer/trunk/twistedcaldav/test/test_localization.py
===================================================================
--- CalendarServer/trunk/twistedcaldav/test/test_localization.py 2016-05-19 16:19:55 UTC (rev 15609)
+++ CalendarServer/trunk/twistedcaldav/test/test_localization.py 2016-05-19 16:22:09 UTC (rev 15610)
@@ -17,7 +17,7 @@
from __future__ import with_statement
from twistedcaldav.localization import (
- translationTo, getLanguage, _remapLanguageCode, _
+ foundationImported, processLocalizationFiles, translationTo, getLanguage, _remapLanguageCode, _
)
from twistedcaldav.ical import Component
from twistedcaldav.test.util import TestCase
@@ -26,6 +26,7 @@
from pycalendar.datetime import DateTime
import os
+import sys
def getComp(str):
calendar = Component.fromString(str)
@@ -203,3 +204,32 @@
self.assertEquals(_remapLanguageCode("en"), "en")
self.assertEquals(_remapLanguageCode("zh-Hans"), "zh_CN")
self.assertEquals(_remapLanguageCode("zh-Hant"), "zh_TW")
+
+
+ def test_foundationImport(self):
+ """
+ Make sure that on OS X the CoreFoundation imports work.
+ """
+ if sys.platform == "darwin":
+ self.assertTrue(foundationImported)
+
+
+ def test_processLocalizationFiles(self):
+ """
+ Make sure that on OS X the .lproj files are converted properly.
+ """
+ if sys.platform == "darwin":
+ tmpdir = self.mktemp()
+
+ settings = ConfigDict({
+ "TranslationsDirectory": os.path.join(os.path.dirname(__file__), "data", "translations"),
+ "LocalesDirectory": tmpdir,
+ })
+
+ processLocalizationFiles(settings)
+
+ self.assertTrue(os.path.exists(os.path.join(tmpdir, "Testlang", "LC_MESSAGES", "calendarserver.mo")))
+
+ with translationTo('Testlang', localeDir=tmpdir):
+ self.assertEquals(_("String1"), "string 1")
+ self.assertEquals(_("String2"), "string 2")
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.macosforge.org/pipermail/calendarserver-changes/attachments/20160519/ea007c7e/attachment-0001.html>
More information about the calendarserver-changes
mailing list