Simple ambiguitity-resolution wrapper for gettext; use for
authorCarl Hetherington <carl@carlh.net>
Mon, 21 Nov 2011 00:04:44 +0000 (00:04 +0000)
committerCarl Hetherington <carl@carlh.net>
Mon, 21 Nov 2011 00:04:44 +0000 (00:04 +0000)
Manual (#4496).

git-svn-id: svn://localhost/ardour2/branches/3.0@10720 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/ardour_ui_ed.cc
gtk2_ardour/automation_time_axis.cc
gtk2_ardour/gain_meter.cc
gtk2_ardour/generic_pluginui.cc
gtk2_ardour/i18n.h
gtk2_ardour/panner_ui.cc
libs/pbd/convert.cc
libs/pbd/pbd/convert.h

index 88b7e409b8dad45335f43fd78ed8e0e20daa371c..075c0818a3d236fc5b75b048527c3fe5999854d0 100644 (file)
@@ -246,7 +246,8 @@ ARDOUR_UI::install_actions ()
        ActionManager::session_sensitive_actions.push_back (act);
        ActionManager::register_action (common_actions, X_("About"), _("About"),  sigc::mem_fun(*this, &ARDOUR_UI::show_about));
        ActionManager::register_action (common_actions, X_("Chat"), _("Chat"),  sigc::mem_fun(*this, &ARDOUR_UI::launch_chat));
-       ActionManager::register_action (common_actions, X_("Manual"), _("Manual"),  mem_fun(*this, &ARDOUR_UI::launch_manual));
+       /** TRANSLATORS: This is `Manual' in the sense of an instruction book that tells a user how to use Ardour */
+       ActionManager::register_action (common_actions, X_("Manual"), S_("Help|Manual"),  mem_fun(*this, &ARDOUR_UI::launch_manual));
        ActionManager::register_action (common_actions, X_("Reference"), _("Reference"),  mem_fun(*this, &ARDOUR_UI::launch_reference));
        ActionManager::register_toggle_action (common_actions, X_("ToggleThemeManager"), _("Theme Manager"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_theme_manager));
        ActionManager::register_toggle_action (common_actions, X_("ToggleKeyEditor"), _("Key Bindings"), sigc::mem_fun(*this, &ARDOUR_UI::toggle_key_editor));
index 7b44bac1d84511e2f542dd96b92b5fa3417bf85e..379e8543b2182c54d609df7ca7e987ed1aa76646 100644 (file)
@@ -249,7 +249,7 @@ AutomationTimeAxisView::auto_clicked ()
                automation_menu->set_name ("ArdourContextMenu");
                MenuList& items (automation_menu->items());
 
-               items.push_back (MenuElem (_("Manual"), sigc::bind (sigc::mem_fun(*this,
+               items.push_back (MenuElem (S_("Automation|Manual"), sigc::bind (sigc::mem_fun(*this,
                                &AutomationTimeAxisView::set_automation_state), (AutoState) Off)));
                items.push_back (MenuElem (_("Play"), sigc::bind (sigc::mem_fun(*this,
                                &AutomationTimeAxisView::set_automation_state), (AutoState) Play)));
@@ -301,7 +301,7 @@ AutomationTimeAxisView::automation_state_changed ()
 
        switch (state & (Off|Play|Touch|Write)) {
        case Off:
-               auto_button.set_label (_("Manual"));
+               auto_button.set_label (S_("Automation|Manual"));
                if (auto_off_item) {
                        ignore_state_request = true;
                        auto_off_item->set_active (true);
@@ -501,7 +501,7 @@ AutomationTimeAxisView::build_display_menu ()
        auto_state_menu->set_name ("ArdourContextMenu");
        MenuList& as_items = auto_state_menu->items();
 
-       as_items.push_back (CheckMenuElem (_("Manual"), sigc::bind (
+       as_items.push_back (CheckMenuElem (S_("Automation|Manual"), sigc::bind (
                        sigc::mem_fun(*this, &AutomationTimeAxisView::set_automation_state),
                        (AutoState) Off)));
        auto_off_item = dynamic_cast<CheckMenuItem*>(&as_items.back());
index 0618e5ee80c5d75bb8dcd800a5afa5a2806f4ee1..0324f3d93cfe39eb232b5e922e950d6e9bb2e5ee 100644 (file)
@@ -204,7 +204,7 @@ GainMeterBase::set_controls (boost::shared_ptr<Route> r,
 
                gain_astate_menu.items().clear ();
 
-               gain_astate_menu.items().push_back (MenuElem (_("Manual"),
+               gain_astate_menu.items().push_back (MenuElem (S_("Automation|Manual"),
                                                              sigc::bind (sigc::mem_fun (*(amp.get()), &Automatable::set_parameter_automation_state),
                                                                    Evoral::Parameter(GainAutomation), (AutoState) Off)));
                gain_astate_menu.items().push_back (MenuElem (_("Play"),
index 30be93c1406857a73ffaba3760c59b298ddf8292..8341883e9bbed801bb097739a4d96dd9686a7e70 100644 (file)
@@ -445,7 +445,7 @@ GenericPluginUI::automation_state_changed (ControlUI* cui)
        switch (insert->get_parameter_automation_state (cui->parameter())
                        & (Off|Play|Touch|Write)) {
        case Off:
-               cui->automate_button.set_label (_("Manual"));
+               cui->automate_button.set_label (S_("Automation|Manual"));
                break;
        case Play:
                cui->automate_button.set_label (_("Play"));
@@ -696,7 +696,7 @@ GenericPluginUI::astate_clicked (ControlUI* cui, uint32_t /*port*/)
        MenuList& items (automation_menu->items());
 
        items.clear ();
-       items.push_back (MenuElem (_("Manual"),
+       items.push_back (MenuElem (S_("Automation|Manual"),
                                   sigc::bind (sigc::mem_fun(*this, &GenericPluginUI::set_automation_state), (AutoState) Off, cui)));
        items.push_back (MenuElem (_("Play"),
                                   sigc::bind (sigc::mem_fun(*this, &GenericPluginUI::set_automation_state), (AutoState) Play, cui)));
index d9c2a44541068a85d0d28ab51dbf070e6f3c02ec..0fae5e5ca06331fc52317265dd6868db3e7cb181 100644 (file)
@@ -31,5 +31,9 @@
 #define N_(Text) gettext_noop (Text)
 #define X_(Text) Text
 #define I18N(Array) PBD::internationalize (PACKAGE, Array)
+/** Use this to translate strings that have different meanings in different places.
+ *  Text should be of the form Context|Message.
+ */
+#define S_(Text) sgettext (PACKAGE, Text)
 
 #endif // __i18n_h__
index c086ce177ca5fd83b1ae6b39ac7ee5f53eef6e7a..6c594b4260e7f02416ac2b43fb1feeebc3ea5239 100644 (file)
@@ -144,7 +144,10 @@ PannerUI::build_astate_menu ()
                pan_astate_menu->items().clear ();
        }
 
-       pan_astate_menu->items().push_back (MenuElem (_("Manual"), sigc::bind (
+       /** TRANSLATORS: this is `Manual' in the sense of automation not being played,
+           so that changes to pan must be done by hand.
+       */
+       pan_astate_menu->items().push_back (MenuElem (S_("Automation|Manual"), sigc::bind (
                        sigc::mem_fun (_panner.get(), &Panner::set_automation_state),
                        (AutoState) Off)));
        pan_astate_menu->items().push_back (MenuElem (_("Play"), sigc::bind (
index bda0683910661f6f9e352fbe86e7fd8ff85c7795..02d7f3c0a415fcf9621a7d0bef8d20f7de2bd542 100644 (file)
@@ -22,6 +22,7 @@
 #include <stdlib.h>
 #include <cstdio>
 #include <ctype.h>
+#include <cstring>
 #ifndef __STDC_FORMAT_MACROS
 #define __STDC_FORMAT_MACROS
 #endif
@@ -325,5 +326,19 @@ strings_equal_ignore_case (const string& a, const string& b)
        return false;
 }
 
+/** A wrapper for dgettext that takes a msgid of the form Context|Text.
+ *  If Context|Text is translated, the translation is returned, otherwise
+ *  just Text is returned.  Useful for getting translations of words or phrases
+ *  that have different meanings in different contexts.
+ */
+const char *
+sgettext (const char* domain_name, const char* msgid)
+{
+       const char * msgval = dgettext (domain_name, msgid);
+       if (msgval == msgid) {
+               msgval = strrchr (msgid, '|') + 1;
+       }
+       return msgval;
+}
 
 } // namespace PBD
index cbc898011d78fa2c5efaf55ce164196370798211..7bf922e94f0ade0d130f4dd7865f48cedb869b1c 100644 (file)
@@ -54,6 +54,9 @@ to_string (T t, std::ios_base & (*f)(std::ios_base&))
        return oss.str();
 }
 
+const char *
+sgettext (const char *, const char *);
+
 } //namespace PBD
 
 #endif /* __pbd_convert_h__ */