4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Lars Gullik Bjønnes
8 * \author Jean-Marc Lasgouttes
10 * \author Jürgen Vigna
12 * Full author contact details are available in file CREDITS.
18 #include "support/docstring.h"
25 namespace support { class FileName; }
34 Language() : rightToLeft_(false), translated_(false) {}
36 std::string const & lang() const { return lang_; }
37 /// Babel language name
38 std::string const & babel() const { return babel_; }
39 /// polyglossia language name
40 std::string const & polyglossia() const { return polyglossia_name_; }
41 /// polyglossia language options
42 std::string const & polyglossiaOpts() const { return polyglossia_opts_; }
43 /// quotation marks style
44 std::string const & quoteStyle() const { return quote_style_; }
45 /// requirement (package, function)
46 std::string const & requires() const { return requires_; }
47 /// translatable GUI name
48 std::string const & display() const { return display_; }
49 /// is this a RTL language?
50 bool rightToLeft() const { return rightToLeft_; }
51 /// Is an (at least partial) translation of this language available?
52 bool translated() const { return translated_; }
53 /// Is an (at least partial) translation of this language available?
54 void translated(bool trans) { translated_ = trans; }
56 * Translate a string from the layout files that appears in the output.
57 * It takes the translations from lib/layouttranslations instead of
58 * the .mo files. This should be used for every translation that
59 * appears in the exported document, since the output must not depend
60 * on installed locales. Non-ASCII keys are not translated. */
61 docstring const translateLayout(std::string const & msg) const;
63 Encoding const * encoding() const { return encoding_; }
65 std::string const & encodingStr() const { return encodingStr_; }
67 std::string const & code() const { return code_; }
68 /// set code (needed for rc.spellchecker_alt_lang)
69 void setCode(std::string const c) { code_ = c; }
70 /// language variety (needed by aspell checker)
71 std::string const & variety() const { return variety_; }
72 /// set variety (needed for rc.spellchecker_alt_lang)
73 void setVariety(std::string const v) { variety_ = v; }
74 /// preamble settings after babel was called
75 std::string const & babel_postsettings() const { return babel_postsettings_; }
76 /// preamble settings before babel is called
77 std::string const & babel_presettings() const { return babel_presettings_; }
78 /// This language internally sets a font encoding
79 bool internalFontEncoding() const { return internal_enc_; }
80 /// This language needs to be passed to babel itself (not the class)
81 bool asBabelOptions() const { return as_babel_options_; }
83 bool read(Lexer & lex);
85 bool readLanguage(Lexer & lex);
87 typedef std::map<std::string, docstring> TranslationMap;
89 void readLayoutTranslations(TranslationMap const & trans, bool replace);
90 // for the use in std::map
91 friend bool operator<(Language const & p, Language const & q);
98 std::string polyglossia_name_;
100 std::string polyglossia_opts_;
102 std::string quote_style_;
104 std::string requires_;
106 std::string display_;
110 std::string encodingStr_;
112 Encoding const * encoding_;
116 std::string variety_;
118 std::string babel_postsettings_;
120 std::string babel_presettings_;
124 bool as_babel_options_;
128 TranslationMap layoutTranslations_;
132 inline bool operator<(Language const & p, Language const & q)
134 return q.lang() > p.lang();
142 typedef std::map<std::string, Language> LanguageList;
144 typedef LanguageList::const_iterator const_iterator;
146 typedef LanguageList::size_type size_type;
148 void read(support::FileName const & filename);
150 void readLayoutTranslations(support::FileName const & filename);
152 void readInstalledTranslations(support::FileName const & filename);
154 Language const * getLanguage(std::string const & language) const;
156 size_type size() const { return languagelist.size(); }
158 const_iterator begin() const { return languagelist.begin(); }
160 const_iterator end() const { return languagelist.end(); }
165 LanguageList languagelist;
168 /// Global singleton instance.
169 extern Languages languages;
170 /// Default language defined in LyXRC
171 extern Language const * default_language;
172 /// Used to indicate that the language should be left unchanged when
173 /// applying a font change.
174 extern Language const * ignore_language;
175 /// Default language defined in LyXRC
176 extern Language const * latex_language;
177 /// Used to indicate that the language should be reset to the Buffer
178 // language when applying a font change.
179 extern Language const * reset_language;