Patch: PENDING_LIFETIME_I18N i18n for PENDING_LIFETIME format

"Vitor EspĂ­ndola" <[email protected]> Fri, 23 Feb 2007 11:52:18 -0200
Newsgroups gmane.mail.spam.tmda.devel
Message-ID <[email protected]>
Hi!

I'm propose here a patch for internationalize the formated string of
PENDING_LIFETIME configuration.

I've been created a new configuration called PENDING_LIFETIME_I18N
that must be a dictionary like bellow, were values must contains
internationalized representations of "years", "days"...

#English
PENDING_LIFETIME_I18N = {
        'Y' : "years",
        'M' : "months",
        'w' : "weeks",
        'd' : "days",
        'h' : "hours",
        'm' : "minutes",
        's' : "seconds"
}

#Portuguese
PENDING_LIFETIME_I18N = {
        'Y' : "anos",
        'M' : "meses",
        'w' : "semanas",
        'd' : "dias",
        'h' : "horas",
        'm' : "minutos",
        's' : "segundos"
}

I'm Brazilian and needed that for my portuguese templates.

PS: Sorry my poor english.

-- 
Vitor EspĂ­ndola
tmda.diff (text/x-patch, 1.7 KB)
Index: TMDA/Defaults.py
===================================================================
--- TMDA/Defaults.py	(reviso 2144)
+++ TMDA/Defaults.py	(cpia de trabalho)
@@ -1099,6 +1099,22 @@
 if not vars().has_key('PENDING_LIFETIME'):
     PENDING_LIFETIME = '14d'
 
+# PENDING_LIFETIME_I18N
+# Dictionary that contains translations of timeout representative 
+# strings. This dictionary must contains the keys Y,M,w,d,h,m,s with 
+# respective internationalized string as value.
+# Default for english language
+if not vars().has_key('PENDING_LIFETIME_I18N'):
+    PENDING_LIFETIME_I18N = {
+        'Y' : "years",
+        'M' : "months",
+        'w' : "weeks",
+        'd' : "days",
+        'h' : "hours",
+        'm' : "minutes",
+        's' : "seconds"
+        }
+
 # PENDING_CLEANUP_ODDS
 # A floating point number which describes the odds that tmda-filter
 # will automatically clean the pending queue of expired messages upon
Index: TMDA/Util.py
===================================================================
--- TMDA/Util.py	(reviso 2144)
+++ TMDA/Util.py	(cpia de trabalho)
@@ -244,20 +244,8 @@
     if not match:
         return timeout
     (num, unit) = match.groups()
-    if unit == 'Y':
-        timeout = num + " years"
-    elif unit == 'M':
-        timeout = num + " months"
-    elif unit == 'w':
-        timeout = num + " weeks"
-    elif unit == 'd':
-        timeout = num + " days"
-    elif unit == 'h':
-        timeout = num + " hours"
-    elif unit == 'm':
-        timeout = num + " minutes"
-    else:
-        timeout = num + " seconds"
+    import Defaults
+    timeout = num + " " + Defaults.PENDING_LIFETIME_I18N[unit]
     if int(num) == 1:
         timeout = timeout[:-1]
     return timeout