From 62f20457cf5ee85ac42dcd24b564ea68c1b3441d Mon Sep 17 00:00:00 2001 From: Patrick Storz Date: Thu, 1 Aug 2019 22:15:48 +0200 Subject: Add function to get proper translation within context of Parameter --- src/extension/prefdialog/parameter.cpp | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'src/extension/prefdialog/parameter.cpp') diff --git a/src/extension/prefdialog/parameter.cpp b/src/extension/prefdialog/parameter.cpp index 2bf83f359..18d2a40ec 100644 --- a/src/extension/prefdialog/parameter.cpp +++ b/src/extension/prefdialog/parameter.cpp @@ -229,11 +229,7 @@ Parameter::Parameter (Inkscape::XML::Node *in_repr, Inkscape::Extension::Extensi } if (gui_text) { if (_translatable != NO) { // translate unless explicitly marked untranslatable - if (_context) { - gui_text = g_dpgettext2(nullptr, context, gui_text); - } else { - gui_text = _(gui_text); - } + gui_text = get_translation(gui_text); } _text = g_strdup(gui_text); } @@ -245,11 +241,7 @@ Parameter::Parameter (Inkscape::XML::Node *in_repr, Inkscape::Extension::Extensi } if (gui_description) { if (_translatable != NO) { // translate unless explicitly marked untranslatable - if (_context) { - gui_description = g_dpgettext2(nullptr, context, gui_description); - } else { - gui_description = _(gui_description); - } + gui_description = get_translation(gui_description); } _description = g_strdup(gui_description); } @@ -331,6 +323,17 @@ Parameter *Parameter::get_param(const gchar */*name*/) return nullptr; } + +const char *Parameter::get_translation(const char* msgid) { + // TODO: translation domain + + if (_context) { + return g_dpgettext2(nullptr, _context, msgid); + } else { + return _(msgid); + } +} + Glib::ustring const extension_pref_root = "/extensions/"; } // namespace Extension -- cgit v1.2.3