Extensions: Translations in inkex.py fail unless extension script itself initalizes gettext
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Inkscape |
Fix Released
|
Medium
|
jazzynico |
Bug Description
Messages in inkex.py marked for translation (with '_()') cause the script / extension to abort with 'NameError' unless the extension which imports inkex does run 'inkex.localize()' (currently, only extensions which themselves need gettext for translated messages do this).
Steps to reproduce:
1) apply attached diff to $PREFIX/
2) launch Inkscape 0.91 or trunk
3) apply an extension which runs 'inkex.localize()':
Extensions > Render > Alphabet Soup
--> success: renders and returns "This is a test" as expected
4) apply an extension which does not run 'inkex.localize()':
Extensions > Render > Gear > Gear
--> failure:
Traceback (most recent call last):
File "render_gears.py", line 184, in <module>
e.affect()
File "$PREFIX/
self.parse()
File "$PREFIX/
errormsg(
NameError: global name '_' is not defined
Possible workaround / fix:
Run 'localize()' early on in the definition of 'affect()' instead of delegating this to individual extensions?
Reproduced with Inkscape 0.91 and 0.91+devel r14615 on OS X 10.7.5.
Related branches
Changed in inkscape: | |
assignee: | nobody → jazzynico (jazzynico) |
importance: | Undecided → Medium |
status: | New → Triaged |
Changed in inkscape: | |
status: | Fix Committed → Fix Released |
Fixed in the trunk, rev. 14918.
I have removed the inkex.localize() call from the extensions, but the change won't break custom extensions that still use it (it can be called several times with no issue).
Thanks for your suggestion, ~suv. Not only it solves the issue, but the extensions are a bit cleaner and easier to maintain. I'm still wondering why I didn't implement it from the beginning ;)