Changes between Version 28 and Version 29 of CookBook/PluginL10N
- Timestamp:
- Mar 20, 2014, 11:58:19 AM (10 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
CookBook/PluginL10N
v28 v29 186 186 {{{#!python 187 187 def __init__(self): 188 import pkg_resources # here or with the other imports188 import pkg_resources # here or with the other imports 189 189 # bind the 'foo' catalog to the specified locale directory 190 locale_dir = pkg_resources.resource_filename(__name__, 'locale') 191 add_domain(self.env.path, locale_dir) 190 try: 191 locale_dir = pkg_resources.resource_filename(__name__, 'locale') 192 except KeyError: 193 pass # no locale directory in plugin if Babel is not installed 194 else: 195 add_domain(self.env.path, locale_dir) 192 196 }}} 193 197 assuming that folder `locale` will reside in the same folder as the file containing the code above, referred to as `<path>` below (as can be observed inside the Python egg after packaging).