From: JazzyNico Date: Sat, 9 Oct 2010 07:14:28 +0000 (+0200) Subject: Extensions, i18n. Adding context to description, groupheader and radiobutton extensio... X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=2bcd615f0c56578f589efcdfa36be3d349803352;p=inkscape.git Extensions, i18n. Adding context to description, groupheader and radiobutton extension parameters. --- diff --git a/src/extension/param/description.cpp b/src/extension/param/description.cpp index d73439414..f17b45b4b 100644 --- a/src/extension/param/description.cpp +++ b/src/extension/param/description.cpp @@ -40,7 +40,9 @@ ParamDescription::ParamDescription (const gchar * name, const gchar * guitext, c if (defaultval != NULL) _value = g_strdup(defaultval); - + + _context = xml->attribute("msgctxt"); + return; } @@ -50,7 +52,16 @@ ParamDescription::get_widget (SPDocument * /*doc*/, Inkscape::XML::Node * /*node { if (_gui_hidden) return NULL; - Gtk::Label * label = Gtk::manage(new Gtk::Label(_(_value), Gtk::ALIGN_LEFT)); + Glib::ustring newguitext; + + if (_context != NULL) { + newguitext = g_dpgettext2(NULL, _context, _value); + } else { + newguitext = _(_value); + } + + Gtk::Label * label = Gtk::manage(new Gtk::Label(newguitext, Gtk::ALIGN_LEFT)); + label->set_line_wrap(); label->show(); diff --git a/src/extension/param/description.h b/src/extension/param/description.h index c305ea6df..c56b5c21d 100644 --- a/src/extension/param/description.h +++ b/src/extension/param/description.h @@ -21,6 +21,7 @@ class ParamDescription : public Parameter { private: /** \brief Internal value. */ gchar * _value; + const gchar* _context; public: ParamDescription(const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml); Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal * changeSignal); diff --git a/src/extension/param/groupheader.cpp b/src/extension/param/groupheader.cpp index 8bdb7f382..abf5f8beb 100755 --- a/src/extension/param/groupheader.cpp +++ b/src/extension/param/groupheader.cpp @@ -42,6 +42,8 @@ ParamGroupHeader::ParamGroupHeader (const gchar * name, const gchar * guitext, c if (defaultval != NULL) _value = g_strdup(defaultval); + _context = xml->attribute("msgctxt"); + return; } @@ -51,7 +53,15 @@ ParamGroupHeader::get_widget (SPDocument * /*doc*/, Inkscape::XML::Node * /*node { if (_gui_hidden) return NULL; - Gtk::Label * label = Gtk::manage(new Gtk::Label(Glib::ustring("") + _(_value) + Glib::ustring(""), Gtk::ALIGN_LEFT)); + Glib::ustring newguitext; + + if (_context != NULL) { + newguitext = g_dpgettext2(NULL, _context, _value); + } else { + newguitext = _(_value); + } + + Gtk::Label * label = Gtk::manage(new Gtk::Label(Glib::ustring("") +newguitext + Glib::ustring(""), Gtk::ALIGN_LEFT)); label->set_line_wrap(); label->set_padding(0,5); label->set_use_markup(true); diff --git a/src/extension/param/groupheader.h b/src/extension/param/groupheader.h index 92908caaa..94fe880f9 100755 --- a/src/extension/param/groupheader.h +++ b/src/extension/param/groupheader.h @@ -22,6 +22,7 @@ class ParamGroupHeader : public Parameter { private: /** \brief Internal value. */ gchar * _value; + const gchar* _context; public: ParamGroupHeader(const gchar * name, const gchar * guitext, const gchar * desc, const Parameter::_scope_t scope, bool gui_hidden, const gchar * gui_tip, Inkscape::Extension::Extension * ext, Inkscape::XML::Node * xml); Gtk::Widget * get_widget(SPDocument * doc, Inkscape::XML::Node * node, sigc::signal * changeSignal); diff --git a/src/extension/param/radiobutton.cpp b/src/extension/param/radiobutton.cpp index c17839001..23655baea 100644 --- a/src/extension/param/radiobutton.cpp +++ b/src/extension/param/radiobutton.cpp @@ -84,12 +84,22 @@ ParamRadioButton::ParamRadioButton (const gchar * name, Glib::ustring * newvalue = NULL; const char * contents = sp_repr_children(child_repr)->content(); - if (contents != NULL) - // don't translate when 'option' but do translate when '_option' - newguitext = new Glib::ustring( !strcmp(chname, INKSCAPE_EXTENSION_NS "_option") ? _(contents) : contents ); - else + if (contents != NULL) { + // don't translate when 'item' but do translate when '_option' + if (!strcmp(chname, INKSCAPE_EXTENSION_NS "_option")) { + if (child_repr->attribute("msgctxt") != NULL) { + newguitext = new Glib::ustring(g_dpgettext2(NULL, child_repr->attribute("msgctxt"), contents)); + } else { + newguitext = new Glib::ustring(_(contents)); + } + } else { + newguitext = new Glib::ustring(contents); + } + } else continue; + + const char * val = child_repr->attribute("value"); if (val != NULL) newvalue = new Glib::ustring(val);