]> git.lyx.org Git - lyx.git/blob - src/support/gettext.cpp
Fix text direction issue for InsetInfo in RTL context
[lyx.git] / src / support / gettext.cpp
1 /**
2  * \file src/gettext.cpp
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Lars Gullik Bjønnes
7  * \author Jean-Marc Lasgouttes
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #include <config.h>
13
14 #include "support/gettext.h"
15
16 #include "support/lstrings.h"
17 #include "support/Messages.h"
18 #include "support/Package.h"
19
20 using namespace std;
21
22 namespace lyx {
23
24 docstring const _(string const & str)
25 {
26         return getGuiMessages().get(str);
27 }
28
29
30 docstring const translateIfPossible(docstring const & name)
31 {
32         if (support::isAscii(name) && !name.empty())
33                 // Probably from a standard configuration file, try to
34                 // translate
35                 return _(to_ascii(name));
36         else
37                 // This must be from a user defined configuration file. We
38                 // cannot translate this, since gettext accepts only ascii
39                 // keys.
40                 return name;
41 }
42
43
44 docstring const translateIfPossible(docstring const & name, std::string const & language)
45 {
46         if (support::isAscii(name) && !name.empty())
47                 // Probably from a standard configuration file, try to
48                 // translate
49                 return getMessages(language).get(to_ascii(name));
50         else
51                 // This must be from a user defined configuration file. We
52                 // cannot translate this, since gettext accepts only ascii
53                 // keys.
54                 return name;
55 }
56
57
58 } // namespace lyx