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"
19 #include "support/trivstring.h"
26 namespace support { class FileName; }
35 Language() : rightToLeft_(false), encoding_(0), internal_enc_(false),
36 as_babel_options_(false), has_gui_support_(false) {}
38 std::string const lang() const { return lang_; }
39 /// Babel language name
40 std::string const babel() const { return babel_; }
41 /// polyglossia language name
42 std::string const polyglossia() const { return polyglossia_name_; }
43 /// polyglossia language options
44 std::string const polyglossiaOpts() const { return polyglossia_opts_; }
45 /// Is this language only supported by polyglossia?
46 bool isPolyglossiaExclusive() const;
47 /// quotation marks style
48 std::string const quoteStyle() const { return quote_style_; }
49 /// requirement (package, function)
50 std::string const requires() const { return requires_; }
51 /// translatable GUI name
52 std::string const display() const { return display_; }
53 /// is this a RTL language?
54 bool rightToLeft() const { return rightToLeft_; }
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 /// fontenc encoding(s)
81 std::string const fontenc() const { return fontenc_; }
82 /// This language needs to be passed to babel itself (not the class)
83 bool asBabelOptions() const { return as_babel_options_; }
84 /// This language corresponds to a translation of the GUI
85 bool hasGuiSupport() const { return has_gui_support_; }
87 bool read(Lexer & lex);
89 bool readLanguage(Lexer & lex);
91 typedef std::map<trivstring, trivdocstring> TranslationMap;
93 void readLayoutTranslations(TranslationMap const & trans, bool replace);
94 // for the use in std::map
95 friend bool operator<(Language const & p, Language const & q);
102 trivstring polyglossia_name_;
104 trivstring polyglossia_opts_;
106 trivstring quote_style_;
108 trivstring requires_;
114 trivstring encodingStr_;
116 Encoding const * encoding_;
122 trivstring babel_postsettings_;
124 trivstring babel_presettings_;
130 bool as_babel_options_;
132 bool has_gui_support_;
134 TranslationMap layoutTranslations_;
138 inline bool operator<(Language const & p, Language const & q)
140 return q.lang() > p.lang();
148 typedef std::map<trivstring, Language> LanguageList;
150 typedef LanguageList::const_iterator const_iterator;
152 typedef LanguageList::size_type size_type;
154 void read(support::FileName const & filename);
156 void readLayoutTranslations(support::FileName const & filename);
158 Language const * getLanguage(std::string const & language) const;
160 size_type size() const { return languagelist.size(); }
162 const_iterator begin() const { return languagelist.begin(); }
164 const_iterator end() const { return languagelist.end(); }
168 LanguageList languagelist;
171 /// Global singleton instance.
172 extern Languages languages;
173 /// Default language defined in LyXRC
174 extern Language const * default_language;
175 /// Used to indicate that the language should be left unchanged when
176 /// applying a font change.
177 extern Language const * ignore_language;
178 /// Default language defined in LyXRC
179 extern Language const * latex_language;
180 /// Used to indicate that the language should be reset to the Buffer
181 // language when applying a font change.
182 extern Language const * reset_language;