X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=share%2Fextensions%2Finkex.py;h=c190fdde031918d62c33f6e55efcc6f792aed1da;hb=a34e754dfd715b6f6338a2a4586da47e8fb3580c;hp=379cfa070f33a15fddb48ba5e61af7b15b48b35f;hpb=5339875bc1c522977c74c35e535d4f98e9036488;p=inkscape.git diff --git a/share/extensions/inkex.py b/share/extensions/inkex.py index 379cfa070..c190fdde0 100755 --- a/share/extensions/inkex.py +++ b/share/extensions/inkex.py @@ -20,6 +20,8 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """ import sys, copy, optparse, random, re +import gettext +_ = gettext.gettext #a dictionary of all of the xmlns prefixes in a standard inkscape doc NSS = { @@ -56,12 +58,29 @@ def unittouu(string): try: from lxml import etree except: - sys.exit('The fantastic lxml wrapper for libxml2 is required by inkex.py and therefore this extension. Please download and install the latest version from , or install it through your package manager by a command like: sudo apt-get install python-lxml') + sys.exit(_('The fantastic lxml wrapper for libxml2 is required by inkex.py and therefore this extension. Please download and install the latest version from http://cheeseshop.python.org/pypi/lxml/, or install it through your package manager by a command like: sudo apt-get install python-lxml')) def debug(what): sys.stderr.write(str(what) + "\n") return what +def errormsg(msg): + """Intended for end-user-visible error messages. + + (Currently just writes to stderr with an appended newline, but could do + something better in future: e.g. could add markup to distinguish error + messages from status messages or debugging output.) + + Note that this should always be combined with translation: + + import gettext + _ = gettext.gettext + ... + inkex.errormsg(_("This extension requires two selected paths.")) + """ + sys.stderr.write(str(msg) + "\n") + return what + def check_inkbool(option, opt, value): if str(value).capitalize() == 'True': return True @@ -165,7 +184,9 @@ class Effect: try: retval = self.document.xpath(path, namespaces=NSS)[0] except: - debug("No matching node for expression: %s" % path) + errormsg(_("No matching node for expression: %s") % path) retval = None return retval + +# vim: expandtab shiftwidth=4 tabstop=8 softtabstop=4 encoding=utf-8 textwidth=99