mirror of
https://github.com/progval/Limnoria.git
synced 2025-05-01 07:51:06 -05:00
src/i18n.py: fix error when running @reloadlocale with a plugin loaded before but not available any longer.
This commit is contained in:
parent
49e14f9a92
commit
1c366a2899
@ -50,6 +50,9 @@ MSGSTR = 'msgstr "'
|
|||||||
|
|
||||||
currentLocale = 'en'
|
currentLocale = 'en'
|
||||||
|
|
||||||
|
class PluginNotFound(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
def getLocaleFromRegistryFilename(filename):
|
def getLocaleFromRegistryFilename(filename):
|
||||||
"""Called by the 'supybot' script. Gets the locale name before conf is
|
"""Called by the 'supybot' script. Gets the locale name before conf is
|
||||||
loaded."""
|
loaded."""
|
||||||
@ -88,7 +91,7 @@ def getPluginDir(plugin_name):
|
|||||||
for allowed_file in allowed_files:
|
for allowed_file in allowed_files:
|
||||||
if filename.endswith(allowed_file):
|
if filename.endswith(allowed_file):
|
||||||
return filename[0:-len(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):
|
def getLocalePath(name, localeName, extension):
|
||||||
"""Gets the path of the locale file of the given plugin ('supybot' stands
|
"""Gets the path of the locale file of the given plugin ('supybot' stands
|
||||||
@ -153,7 +156,7 @@ class _PluginInternationalization:
|
|||||||
translationFile = open(getLocalePath(self.name,
|
translationFile = open(getLocalePath(self.name,
|
||||||
localeName, 'po'), 'r')
|
localeName, 'po'), 'r')
|
||||||
self._parse(translationFile)
|
self._parse(translationFile)
|
||||||
except IOError: # The translation is unavailable
|
except IOError, PluginNotFound: # The translation is unavailable
|
||||||
self.translations = {}
|
self.translations = {}
|
||||||
def _parse(self, translationFile):
|
def _parse(self, translationFile):
|
||||||
"""A .po files parser.
|
"""A .po files parser.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user