summaryrefslogtreecommitdiffstats
path: root/src/extension/extension.h
diff options
context:
space:
mode:
authorPatrick Storz <eduard.braun2@gmx.de>2019-10-17 00:16:32 +0000
committerPatrick Storz <eduard.braun2@gmx.de>2019-10-19 12:33:34 +0000
commit76ce73061550ff42e97c1fec9836c35cc0e24d64 (patch)
tree9ea6f017e13bc4f5cc63eb17f8a23e1e58ccee3a /src/extension/extension.h
parentAdd export/import PDF blend modes and add isolation modifier (diff)
downloadinkscape-76ce73061550ff42e97c1fec9836c35cc0e24d64.tar.gz
inkscape-76ce73061550ff42e97c1fec9836c35cc0e24d64.zip
Extensions: Implement translationdomain functionality
Inkscape will read the "translationdomain" attribute from the <inkscape-extension> 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
Diffstat (limited to 'src/extension/extension.h')
-rw-r--r--src/extension/extension.h6
1 files changed, 6 insertions, 0 deletions
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: