From 1c366a28999dc7acc351f0cfa9a3f85ca6a6587d Mon Sep 17 00:00:00 2001 From: Valentin Lorentz Date: Tue, 28 Jun 2011 19:52:18 +0200 Subject: [PATCH] src/i18n.py: fix error when running @reloadlocale with a plugin loaded before but not available any longer. --- src/i18n.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/i18n.py b/src/i18n.py index 3f64a82c9..ba57edfdf 100644 --- a/src/i18n.py +++ b/src/i18n.py @@ -50,6 +50,9 @@ MSGSTR = 'msgstr "' currentLocale = 'en' +class PluginNotFound(Exception): + pass + def getLocaleFromRegistryFilename(filename): """Called by the 'supybot' script. Gets the locale name before conf is loaded.""" @@ -88,7 +91,7 @@ def getPluginDir(plugin_name): for allowed_file in allowed_files: if filename.endswith(allowed_file): return filename[0:-len(allowed_file)] - raise Exception('Plugin %s not found by i18n.' % plugin_name) + raise PluginNotFound() def getLocalePath(name, localeName, extension): """Gets the path of the locale file of the given plugin ('supybot' stands @@ -153,7 +156,7 @@ class _PluginInternationalization: translationFile = open(getLocalePath(self.name, localeName, 'po'), 'r') self._parse(translationFile) - except IOError: # The translation is unavailable + except IOError, PluginNotFound: # The translation is unavailable self.translations = {} def _parse(self, translationFile): """A .po files parser.