diff options
author | Carl Hetherington <carl@carlh.net> | 2011-11-21 00:04:44 +0000 |
---|---|---|
committer | Carl Hetherington <carl@carlh.net> | 2011-11-21 00:04:44 +0000 |
commit | 5c73926324ea56e652409b41dd7f308af02931e1 (patch) | |
tree | 446d8b6e1886dc6afd6c6feec081a3f3eeb23082 /libs/pbd/convert.cc | |
parent | 1ca3930e7aec720af7edeaac9940d6411dae754a (diff) |
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
Diffstat (limited to 'libs/pbd/convert.cc')
-rw-r--r-- | libs/pbd/convert.cc | 15 |
1 files changed, 15 insertions, 0 deletions
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 <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 |