mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Don't crash anymore if an .ui file contains unicode labels
* 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
This commit is contained in:
parent
3e40bf3dbf
commit
83525c9570
@ -275,7 +275,7 @@ Menu & Menu::read(LyXLex & lex)
|
||||
// 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);
|
||||
@ -349,7 +349,7 @@ Menu & Menu::read(LyXLex & lex)
|
||||
// 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,
|
||||
|
@ -97,7 +97,7 @@ void ToolbarBackend::read(LyXLex & lex)
|
||||
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]
|
||||
|
@ -13,7 +13,9 @@
|
||||
|
||||
#include "gettext.h"
|
||||
#include "messages.h"
|
||||
|
||||
#include "support/environment.h"
|
||||
#include "support/lstrings.h"
|
||||
|
||||
|
||||
namespace lyx {
|
||||
@ -68,4 +70,18 @@ void locale_init()
|
||||
#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
|
||||
|
@ -61,6 +61,13 @@ docstring const _(std::string const &);
|
||||
|
||||
# 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();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user