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.
24 namespace support { class FileName; }
33 Language() : rightToLeft_(false), translated_(false) {}
35 std::string const & lang() const { return lang_; }
36 /// Babel language name
37 std::string const & babel() const { return babel_; }
38 /// polyglossia language name
39 std::string const & polyglossia() const { return polyglossia_name_; }
40 /// polyglossia language options
41 std::string const & polyglossiaOpts() const { return polyglossia_opts_; }
42 /// translatable GUI name
43 std::string const & display() const { return display_; }
44 /// is this a RTL language?
45 bool rightToLeft() const { return rightToLeft_; }
46 /// Is an (at least partial) translation of this language available?
47 bool translated() const { return translated_; }
49 Encoding const * encoding() const { return encoding_; }
51 std::string const & encodingStr() const { return encodingStr_; }
53 std::string const & code() const { return code_; }
54 /// set code (needed for rc.spellchecker_alt_lang)
55 void setCode(std::string const c) { code_ = c; }
56 /// language variety (needed by aspell checker)
57 std::string const & variety() const { return variety_; }
58 /// set variety (needed for rc.spellchecker_alt_lang)
59 void setVariety(std::string const v) { variety_ = v; }
60 /// preamble settings after babel was called
61 std::string const & babel_postsettings() const { return babel_postsettings_; }
62 /// preamble settings before babel is called
63 std::string const & babel_presettings() const { return babel_presettings_; }
64 /// This language internally sets a font encoding
65 bool internalFontEncoding() const { return internal_enc_; }
66 /// This language needs to be passed to babel itself (not the class)
67 bool asBabelOptions() const { return as_babel_options_; }
69 bool read(Lexer & lex);
71 bool readLanguage(Lexer & lex);
72 // for the use in std::map
73 friend bool operator<(Language const & p, Language const & q);
80 std::string polyglossia_name_;
82 std::string polyglossia_opts_;
88 std::string encodingStr_;
90 Encoding const * encoding_;
96 std::string babel_postsettings_;
98 std::string babel_presettings_;
102 bool as_babel_options_;
108 inline bool operator<(Language const & p, Language const & q)
110 return q.lang() > p.lang();
118 typedef std::map<std::string, Language> LanguageList;
120 typedef LanguageList::const_iterator const_iterator;
122 typedef LanguageList::size_type size_type;
124 void read(support::FileName const & filename);
126 Language const * getLanguage(std::string const & language) const;
128 size_type size() const { return languagelist.size(); }
130 const_iterator begin() const { return languagelist.begin(); }
132 const_iterator end() const { return languagelist.end(); }
137 LanguageList languagelist;
140 /// Global singleton instance.
141 extern Languages languages;
142 /// Default language defined in LyXRC
143 extern Language const * default_language;
144 /// Used to indicate that the language should be left unchanged when
145 /// applying a font change.
146 extern Language const * ignore_language;
147 /// Default language defined in LyXRC
148 extern Language const * latex_language;
149 /// Used to indicate that the language should be reset to the Buffer
150 // language when applying a font change.
151 extern Language const * reset_language;