From 5c73926324ea56e652409b41dd7f308af02931e1 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 21 Nov 2011 00:04:44 +0000 Subject: [PATCH] Simple ambiguitity-resolution wrapper for gettext; use for Manual (#4496). git-svn-id: svn://localhost/ardour2/branches/3.0@10720 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/ardour_ui_ed.cc | 3 ++- gtk2_ardour/automation_time_axis.cc | 6 +++--- gtk2_ardour/gain_meter.cc | 2 +- gtk2_ardour/generic_pluginui.cc | 4 ++-- gtk2_ardour/i18n.h | 4 ++++ gtk2_ardour/panner_ui.cc | 5 ++++- libs/pbd/convert.cc | 15 +++++++++++++++ libs/pbd/pbd/convert.h | 3 +++ 8 files changed, 34 insertions(+), 8 deletions(-) diff --git a/gtk2_ardour/ardour_ui_ed.cc b/gtk2_ardour/ardour_ui_ed.cc index 88b7e409b8..075c0818a3 100644 --- a/gtk2_ardour/ardour_ui_ed.cc +++ b/gtk2_ardour/ardour_ui_ed.cc @@ -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)); diff --git a/gtk2_ardour/automation_time_axis.cc b/gtk2_ardour/automation_time_axis.cc index 7b44bac1d8..379e8543b2 100644 --- a/gtk2_ardour/automation_time_axis.cc +++ b/gtk2_ardour/automation_time_axis.cc @@ -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(&as_items.back()); diff --git a/gtk2_ardour/gain_meter.cc b/gtk2_ardour/gain_meter.cc index 0618e5ee80..0324f3d93c 100644 --- a/gtk2_ardour/gain_meter.cc +++ b/gtk2_ardour/gain_meter.cc @@ -204,7 +204,7 @@ GainMeterBase::set_controls (boost::shared_ptr 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"), diff --git a/gtk2_ardour/generic_pluginui.cc b/gtk2_ardour/generic_pluginui.cc index 30be93c140..8341883e9b 100644 --- a/gtk2_ardour/generic_pluginui.cc +++ b/gtk2_ardour/generic_pluginui.cc @@ -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))); diff --git a/gtk2_ardour/i18n.h b/gtk2_ardour/i18n.h index d9c2a44541..0fae5e5ca0 100644 --- a/gtk2_ardour/i18n.h +++ b/gtk2_ardour/i18n.h @@ -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__ diff --git a/gtk2_ardour/panner_ui.cc b/gtk2_ardour/panner_ui.cc index c086ce177c..6c594b4260 100644 --- a/gtk2_ardour/panner_ui.cc +++ b/gtk2_ardour/panner_ui.cc @@ -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 ( diff --git a/libs/pbd/convert.cc b/libs/pbd/convert.cc index bda0683910..02d7f3c0a4 100644 --- a/libs/pbd/convert.cc +++ b/libs/pbd/convert.cc @@ -22,6 +22,7 @@ #include #include #include +#include #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 diff --git a/libs/pbd/pbd/convert.h b/libs/pbd/pbd/convert.h index cbc898011d..7bf922e94f 100644 --- a/libs/pbd/pbd/convert.h +++ b/libs/pbd/pbd/convert.h @@ -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__ */