From 76ce73061550ff42e97c1fec9836c35cc0e24d64 Mon Sep 17 00:00:00 2001 From: Patrick Storz Date: Thu, 17 Oct 2019 02:16:32 +0200 Subject: Extensions: Implement translationdomain functionality Inkscape will read the "translationdomain" attribute from the root element in the .inx file. It will then attempt to lookup a message catalog that matches this domain, register it with gettext, and use it for translations. Message catalogs may be located in either - the .inx file's location - the root of the "extensions" directory containing the .inx - the system location Inkscape's own catalog is loaded from To make this functionality available to script extensions, Inkscape will set the environment variables INKEX_GETTEXT_DOMAIN and INKEX_GETTEXT_DIRECTORY so extension scripts can then use something like bindtextdomain(INKEX_GETTEXT_DOMAIN, INKEX_GETTEXT_DIRECTORY) textdomain(INKEX_GETTEXT_DOMAIN) to enable the feature. See also https://gitlab.com/inkscape/inkscape/issues/333 https://gitlab.com/inkscape/extensions/issues/117 --- src/extension/extension.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/extension/extension.h') diff --git a/src/extension/extension.h b/src/extension/extension.h index 2ddd8f3f4..476be37d5 100644 --- a/src/extension/extension.h +++ b/src/extension/extension.h @@ -126,8 +126,13 @@ protected: * relative paths in the extension should usually be relative to it */ ExpirationTimer * timer = nullptr; /**< Timeout to unload after a given time */ bool _translation_enabled = true; /**< Attempt translation of strings provided by the extension? */ + +private: const char *_translationdomain = nullptr; /**< Domainname of gettext textdomain that should * be used for translation of the extension's strings */ + std::string _gettext_catalog_dir; /**< Directory containing the gettext catalog for _translationdomain */ + + void lookup_translation_catalog(); public: Extension(Inkscape::XML::Node *in_repr, Implementation::Implementation *in_imp, std::string *base_directory); @@ -151,6 +156,7 @@ public: void set_base_directory(std::string base_directory) { _base_directory = base_directory; }; std::string get_dependency_location(const char *name); const char *get_translation(const char* msgid, const char *msgctxt=nullptr); + void set_environment(); /* Parameter Stuff */ private: -- cgit v1.2.3