* src/gettext.[Ch]
(translateIfPossible): new function to translate stuff that might
already be in the native language
* src/MenuBackend.C
(Menu::read): Use translateIfPossible for item names and submenu
labels, since the user may have already entered them in his native
language into the .ui file
* src/ToolbarBackend.C
(ToolbarBackend::read): do the same with the tooltip
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@16015
a592a061-630c-0410-9148-
cb99ea01b6c8
// fallback to md_item
case md_item: {
lex.next(true);
- docstring const name = _(lex.getString());
+ docstring const name = translateIfPossible(lex.getDocString());
lex.next(true);
string const command = lex.getString();
FuncRequest func = lyxaction.lookupFunc(command);
// fallback to md_submenu
case md_submenu: {
lex.next(true);
- docstring const mlabel = _(lex.getString());
+ docstring const mlabel = translateIfPossible(lex.getDocString());
lex.next(true);
docstring const mname = lex.getDocString();
add(MenuItem(MenuItem::Submenu, mlabel, mname,
switch (lex.lex()) {
case TO_ADD:
if (lex.next(true)) {
- docstring const tooltip = _(lex.getString());
+ docstring const tooltip = translateIfPossible(lex.getDocString());
lex.next(true);
string const func_arg = lex.getString();
lyxerr[Debug::PARSER]
#include "gettext.h"
#include "messages.h"
+
#include "support/environment.h"
+#include "support/lstrings.h"
namespace lyx {
#endif
+docstring const translateIfPossible(docstring const & name)
+{
+ if (support::isAscii(name))
+ // Probably from a standard configuration file, try to
+ // translate
+ return _(to_ascii(name));
+ else
+ // This must be from a user defined configuration file. We
+ // cannot translate this, since gettext accepts only ascii
+ // keys.
+ return name;
+}
+
+
} // namespace lyx
# define N_(str) (str) // for detecting static strings
+/**
+ * Translate \p name if it is possible.
+ * This should be used to translate strings that come from configuration
+ * files like .ui files. These strings could already be in the native
+ * language if they come from a file in the personal directory. */
+docstring const translateIfPossible(docstring const & name);
+
///
void locale_init();