@@ -117,7 +117,7 @@ def getLocalePath(name, localeName, extension):
117
117
return '%s/%s.%s' % (directory , localeName , extension )
118
118
119
119
i18nClasses = weakref .WeakValueDictionary ()
120
- internationalizedCommands = weakref .WeakValueDictionary ()
120
+ internationalizedCommands = weakref .WeakSet ()
121
121
122
122
def reloadLocalesIfRequired ():
123
123
global currentLocale
@@ -132,7 +132,7 @@ def reloadLocales():
132
132
133
133
for pluginClass in i18nClasses .values ():
134
134
pluginClass .loadLocale ()
135
- for command in list (internationalizedCommands . values () ):
135
+ for command in list (internationalizedCommands ):
136
136
internationalizeDocstring (command )
137
137
utils .str ._relocalizeFunctions (PluginInternationalization ())
138
138
@@ -331,19 +331,10 @@ def localizeFunction(self, name):
331
331
return self ._l10nFunctions [name ]
332
332
333
333
334
- try :
335
- class InternationalizedString (str ):
336
- """Simple subclass to str, that allow to add attributes. Also used to
337
- know if a string is already localized"""
338
- __slots__ = ('_original' , '_internationalizer' )
339
- except TypeError :
340
- # Fallback for CPython 2.x:
341
- # TypeError: Error when calling the metaclass bases
342
- # nonempty __slots__ not supported for subtype of 'str'
343
- class InternationalizedString (str ):
344
- """Simple subclass to str, that allow to add attributes. Also used to
345
- know if a string is already localized"""
346
- pass
334
+ class InternationalizedString (str ):
335
+ """Simple subclass to str, that allow to add attributes. Also used to
336
+ know if a string is already localized"""
337
+ __slots__ = ('_original' , '_internationalizer' )
347
338
348
339
349
340
def internationalizeDocstring (obj ):
@@ -354,7 +345,7 @@ def internationalizeDocstring(obj):
354
345
return obj
355
346
plugin_module = sys .modules [obj .__module__ ]
356
347
if '_' in plugin_module .__dict__ :
357
- internationalizedCommands .update ({ hash ( obj ): obj } )
348
+ internationalizedCommands .add ( obj )
358
349
try :
359
350
obj .__doc__ = plugin_module ._ .__call__ (obj .__doc__ )
360
351
# We use _.__call__() instead of _() because of a pygettext warning.
0 commit comments