Title: [commits] (bkirsch) [15344] fixes bug 10880 Localization string clean up and new layout method.

Diff

Modified: trunk/chandler/application/Utility.py (15343 => 15344)

--- trunk/chandler/application/Utility.py	2007-09-19 21:02:20 UTC (rev 15343)
+++ trunk/chandler/application/Utility.py	2007-09-21 19:48:51 UTC (rev 15344)
@@ -235,6 +235,7 @@
     'wing':       ('-w', '--wing',       'b', False, None, ''),
     'komodo':     ('-k', '--komodo',     'b', False, None, ''),
     'locale':     ('-l', '--locale',     's', None,  None, 'Set the default locale'),
+    'expand':      ('',   '--expand',      's', '0', None, 'Expands the length of localized strings by the percentage specified between 0 and 100'),
     'encrypt':    ('-S', '--encrypt',    'b', False, None, 'Request prompt for password for repository encryption'),
     'nosplash':   ('-N', '--nosplash',   'b', False, 'CHANDLERNOSPLASH', ''),
     'logging':    ('-L', '--logging',    's', 'logging.conf',  'CHANDLERLOGCONFIG', 'The logging config file'),
@@ -454,7 +455,7 @@
 
 def initI18n(options):
     #Will discover locale set if options.locale is None
-    i18n._I18nManager.initialize(options.locale)
+    i18n._I18nManager.initialize(localeSet=options.locale, expand=options.expand)
 
 
 class ChandlerRotatingFileHandler(logging.handlers.RotatingFileHandler):

Modified: trunk/chandler/application/dialogs/PublishCollection.py (15343 => 15344)

--- trunk/chandler/application/dialogs/PublishCollection.py	2007-09-19 21:02:20 UTC (rev 15343)
+++ trunk/chandler/application/dialogs/PublishCollection.py	2007-09-21 19:48:51 UTC (rev 15344)
@@ -190,9 +190,9 @@
 
         share = sharing.getShare(self.collection)
         if sharing.isSharedByMe(share):
-            self.UnPubSub.SetLabel("Unpublish")
+            self.UnPubSub.SetLabel(_(u"Unpublish"))
         else:
-            self.UnPubSub.SetLabel("Unsubscribe")
+            self.UnPubSub.SetLabel(_(u"Unsubscribe"))
 
 
         self.CheckboxShareAlarms = wx.xrc.XRCCTRL(self, "CHECKBOX_ALARMS")
@@ -639,7 +639,7 @@
         if not self.statusPanel.IsShown():
             self.mySizer.Insert(1, self.statusPanel, 0, wx.GROW, 5)
             self.statusPanel.Show()
-        self.textStatus.SetLabel("%s%s" % (self.textStatus.GetLabel(), msg))
+        self.textStatus.SetLabel(u"%s%s" % (self.textStatus.GetLabel(), msg))
         # self.textStatus.ShowPosition(self.textStatus.GetLastPosition())
         self._resize()
 

Modified: trunk/chandler/application/dialogs/Util.py (15343 => 15344)

--- trunk/chandler/application/dialogs/Util.py	2007-09-19 21:02:20 UTC (rev 15343)
+++ trunk/chandler/application/dialogs/Util.py	2007-09-21 19:48:51 UTC (rev 15344)
@@ -426,7 +426,7 @@
         # creation, and then we create the GUI dialog using the Create
         # method.
         pre = wx.PreDialog()
-        pre.Create(None, -1, "Logs", pos, size, style)
+        pre.Create(None, -1, _(u"Logs"), pos, size, style)
 
         # This next step is the most important, it turns this Python
         # object into the real wrapper of the dialog (instead of pre)
@@ -445,7 +445,10 @@
             f = codecs.open(log, encoding='utf-8', mode="r", errors="ignore")
             #combined is a list of unicode text
             combined = u"".join(f.readlines()[-500:])
-            label = wx.StaticText(self, -1, log)
+
+            label = wx.StaticText(self, -1,
+                            _(u"Log Path: %(path)s") % {"path": log})
+
             sizer.Add(label, 0, wx.ALIGN_LEFT|wx.ALL, 5)
 
             self.forClipboard += u"==> %s <==\n\n" % log

Modified: trunk/chandler/i18n/i18nmanager.py (15343 => 15344)

--- trunk/chandler/i18n/i18nmanager.py	2007-09-19 21:02:20 UTC (rev 15343)
+++ trunk/chandler/i18n/i18nmanager.py	2007-09-21 19:48:51 UTC (rev 15344)
@@ -78,7 +78,7 @@
 class I18nManager(EggTranslations):
     _NAME = "I18nManager"
 
-    __slots__ = ["_testing", "_lookupCache", "_wx_filehandler",
+    __slots__ = ["_testing", "_expand", "_lookupCache", "_wx_filehandler",
                  "_DEFAULT_PROJECT", "_DEFAULT_CATALOG", "_DEFAULT_IMAGE",
                  "_DEFAULT_HTML"]
 
@@ -107,6 +107,7 @@
         self._lookupCache = None
         self._wx_filehandler = None
         self._testing = False
+        self._expand = 0
 
     def __repr__(self):
         return "I18nManager(%s, %s, %s, %s)" % (
@@ -117,7 +118,7 @@
 
 
     def initialize(self, localeSet=None, iniFileName="resources.ini",
-                   encoding="UTF-8", fallback=True):
+                   encoding="UTF-8", fallback=True, expand=0):
         """
         The initialize method performs the following operations:
 
@@ -196,11 +197,34 @@
 
 
           @type fallback: c{boolean}
+
+          @param expand: This feature is used for UI layout testing.
+                         The value represents the percentage to
+                         increase localized string sizes by.
+                         The value must be between 0 and 100
+                         where 100 represents a 100% increase
+                         in the string expansion size. Any value
+                         less than 0 or greater than 100 is ignored.
+                         If the expand value is 100 (100%) and
+                         the localized string is u"test" the
+                         c{I18nManager.getText) method will return
+                         u"test---->" which represents a 100%
+                         doubling of the string length (4) with
+                         u"-" characters plus a terminating u">".
+
+            @type expand: c{int}
         """
 
         super(I18nManager, self).initialize(localeSet, iniFileName,
                                             encoding, fallback)
 
+        try:
+            ex = int(expand)
+
+            self._expand = (ex > 0 and ex <= 100) and (ex / 100.0) or 0
+        except:
+            self._expand = 0
+
         if wxIsAvailable():
             self._wx_filehandler = I18nFileSystemHandler(self)
             wx.FileSystem.AddHandler(self._wx_filehandler)
@@ -261,16 +285,9 @@
 
         A locale of 'test' can be passed to this method.
 
-        The 'test' locale is a debug keyword
-        which sets the locale set to ['fr_CA', 'fr']
-        and enables the testing mode flag.
-
         In testing mode all values returned by
-        the c{I18nManager.getText} method insert
-        a (\u00FC): at the start of the string.
-        All values returned by the c{I18nManager.wxTranslate}
-        method return (WX): at the start of the
-        string.
+        the c{I18nManager.getText} and c{i18nManager.wxTranslate}
+        methods insert a (\u00FC): at the start of the string.
 
         This method sets the following:
            1. The PyICU Locale
@@ -323,7 +340,7 @@
                    type(localeSet) == StringType)
 
             if 'test' in localeSet:
-                localeSet = ['fr_CA', 'fr']
+                localeSet = ['en_US']
                 self._testing = True
 
         if type(localeSet) != ListType:
@@ -564,25 +581,42 @@
 
         res = super(I18nManager, self).getText(project, name, txt, *args)
 
-        #If the additional argument passed to getText is
-        #the same as res meaning no translation was found
-        #then do not add u"(\u00FC):" to it.
+        # If the additional argument passed to getText is
+        # the same as res meaning no translation was found
+        # then do not call the expandText or wrapText
+        # methods.
         ignore = args and args[0] == res
 
-        if self._testing \
-           and not ignore \
-           and not "Ctrl+" in res \
-           and not "DELETE" == res \
-           and not "Del" == res \
-           and not ":mm" in res \
-           and not "yy" in res \
-           and not "hh" in res \
-           and not "0:00" in res:
-             return u"(\u00FC): %s" % res
+        if self._testing and not ignore:
+            return self._wrapText(res)
 
+        if self._expand and not ignore:
+            return self._expandText(res)
+
         return res
 
+    def _wrapText(self, msg):
+        if not "Ctrl+" in msg \
+           and not "DELETE" == msg \
+           and not "Del" == msg \
+           and not ":mm" in msg \
+           and not "yy" in msg \
+           and not "hh" in msg \
+           and not "0:00" in msg:
+            return u"(\u00FC): %s" % msg
 
+        return msg
+
+
+    def _expandText(self, msg):
+        res = u"%s%s" % (msg, "-" * (int(len(msg) * self._expand)))
+
+        if res != msg:
+            res += u">"
+
+        return res
+
+
     def wxTranslate(self, txt):
         """
         Returns the current locale set translation for the
@@ -604,7 +638,7 @@
             res = txt
 
         if self._testing:
-            return u"(WX): %s" % res
+            return self._wrapText(res)
 
         return res
 
@@ -1256,6 +1290,12 @@
             if msg is missing:
                 msg = wx.GetTranslation(txt)
 
+                if self.i18nMan._testing:
+                    return self.i18nMan._wrapText(msg)
+
+                if self.i18nMan._expand:
+                    return self.i18nMan._expandText(msg)
+
             return msg
 
     #    # this handler captures all plural translation requests

Modified: trunk/chandler/parcels/osaf/sharing/ootb.py (15343 => 15344)

--- trunk/chandler/parcels/osaf/sharing/ootb.py	2007-09-19 21:02:20 UTC (rev 15343)
+++ trunk/chandler/parcels/osaf/sharing/ootb.py	2007-09-21 19:48:51 UTC (rev 15344)
@@ -13,9 +13,10 @@
 #   limitations under the License.
 
 import accounts, cosmo
+from i18n import ChandlerMessageFactory as _
 
 __all__ = ["prepareAccounts"]
 
 def prepareAccounts(rv):
     if len(list(accounts.SharingAccount.iterItems(rv))) == 0:
-        cosmo.HubAccount(itsView=rv, displayName="Chandler Hub sharing")
+        cosmo.HubAccount(itsView=rv, displayName=_(u"Chandler Hub sharing"))

Modified: trunk/chandler/parcels/osaf/views/main/SideBar.py (15343 => 15344)

--- trunk/chandler/parcels/osaf/views/main/SideBar.py	2007-09-19 21:02:20 UTC (rev 15343)
+++ trunk/chandler/parcels/osaf/views/main/SideBar.py	2007-09-21 19:48:51 UTC (rev 15344)
@@ -1281,10 +1281,7 @@
             event.arguments['Enable'] = False
             event.arguments['Check'] = False
         else:
-            arguments = {'collection': selectedItem.displayName,
-                         'dashboard': schema.ns("osaf.pim", self).allCollection.displayName}
-                         
-            menuTitle = _(u'&Keep out of %(dashboard)s') % arguments
+            menuTitle = _(u'&Keep out of Dashboard')
 
             if UserCollection(selectedItem).outOfTheBoxCollection:
                 enabled = False

Modified: trunk/chandler/parcels/osaf/views/main/menus.py (15343 => 15344)

--- trunk/chandler/parcels/osaf/views/main/menus.py	2007-09-19 21:02:20 UTC (rev 15343)
+++ trunk/chandler/parcels/osaf/views/main/menus.py	2007-09-21 19:48:51 UTC (rev 15344)
@@ -173,7 +173,7 @@
                             MenuItem.template('SyncIMAPItem',
                                 event = main.GetNewMail,
                                 title = _(u'&Mail'),
-                                helpString = _(u'Sync Mail')),
+                                helpString = _(u'Sync mail')),
                             MenuItem.template('SyncWebDAVItem',
                                 event = main.SyncWebDAV,
                                 title = _(u'&Shares'),

Modified: trunk/chandler/projects/Chandler-EventLoggerPlugin/eventLogger/__init__.py (15343 => 15344)

--- trunk/chandler/projects/Chandler-EventLoggerPlugin/eventLogger/__init__.py	2007-09-19 21:02:20 UTC (rev 15343)
+++ trunk/chandler/projects/Chandler-EventLoggerPlugin/eventLogger/__init__.py	2007-09-21 19:48:51 UTC (rev 15344)
@@ -31,6 +31,9 @@
 import logging.handlers
 import os
 
+from i18n import MessageFactory
+_ = MessageFactory("Chandler-EventLoggerPlugin")
+
 logger = logging.getLogger(__name__)
 
 logDir = os.path.join(Globals.options.profileDir, 'eventLogger')
@@ -193,8 +196,8 @@
         parcel, 'StartLogging',
         blockName = 'StartLoggingMenuItem',
         menuItemKind = 'Check',
-        title = u'Log &user actions',
-        helpString = u'Turn on logging and send result to OSAF',
+        title = _(u'Log &user actions'),
+        helpString = _(u'Turn on logging and send result to OSAF'),
         event = ToggleLogging,
         eventsForNamedLookup = [ToggleLogging],
         parentBlock = mainView.LoggingMenu)




_______________________________________________
Commits mailing list
[email protected]
http://lists.osafoundation.org/mailman/listinfo/commits

Reply via email to