Skip to content

Commit

Permalink
Fix #2895: Problems with translations in plugins (part 1)
Browse files Browse the repository at this point in the history
`ckan.lib.plugin.DefaultTranslation` relies on the extension package's
`__file__` attribute which is not available for namespace packages.

The fix is to use `ckanext.my_extension.plugin.__file__` instead. Note
that the existing code already assumes the existance of the `plugin`
module.
  • Loading branch information
torfsen committed Mar 3, 2016
1 parent 0fe167e commit 0cff7b7
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion ckan/lib/plugins.py
Expand Up @@ -537,7 +537,7 @@ def i18n_directory(self):
i18n/
'''
# assume plugin is called ckanext.<myplugin>.<...>.PluginClass
extension_module_name = '.'.join(self.__module__.split('.')[0:2])
extension_module_name = '.'.join(self.__module__.split('.')[:3])
module = sys.modules[extension_module_name]
return os.path.join(os.path.dirname(module.__file__), 'i18n')

Expand Down

0 comments on commit 0cff7b7

Please sign in to comment.