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) {}
37 std::string const lang() const { return lang_; }
38 /// Babel language name
39 std::string const babel() const { return babel_; }
40 /// polyglossia language name
41 std::string const polyglossia() const { return polyglossia_name_; }
42 /// polyglossia language options
43 std::string const polyglossiaOpts() const { return polyglossia_opts_; }
44 /// Is this language only supported by polyglossia?
45 bool isPolyglossiaExclusive() const;
46 /// quotation marks style
47 std::string const quoteStyle() const { return quote_style_; }
48 /// requirement (package, function)
49 std::string const requires() const { return requires_; }
50 /// translatable GUI name
51 std::string const display() const { return display_; }
52 /// is this a RTL language?
53 bool rightToLeft() const { return rightToLeft_; }
55 * Translate a string from the layout files that appears in the output.
56 * It takes the translations from lib/layouttranslations instead of
57 * the .mo files. This should be used for every translation that
58 * appears in the exported document, since the output must not depend
59 * on installed locales. Non-ASCII keys are not translated. */
60 docstring const translateLayout(std::string const & msg) const;
62 Encoding const * encoding() const { return encoding_; }
64 std::string const encodingStr() const { return encodingStr_; }
66 std::string const code() const { return code_; }
67 /// set code (needed for rc.spellchecker_alt_lang)
68 void setCode(std::string const & c) { code_ = c; }
69 /// language variety (needed by aspell checker)
70 std::string const variety() const { return variety_; }
71 /// set variety (needed for rc.spellchecker_alt_lang)
72 void setVariety(std::string const & v) { variety_ = v; }
73 /// preamble settings after babel was called
74 std::string const babel_postsettings() const { return babel_postsettings_; }
75 /// preamble settings before babel is called
76 std::string const babel_presettings() const { return babel_presettings_; }
77 /// This language internally sets a font encoding
78 bool internalFontEncoding() const { return internal_enc_; }
79 /// fontenc encoding(s)
80 std::string const fontenc() const { return fontenc_; }
81 /// This language needs to be passed to babel itself (not the class)
82 bool asBabelOptions() const { return as_babel_options_; }
84 bool read(Lexer & lex);
86 bool readLanguage(Lexer & lex);
88 typedef std::map<trivstring, trivdocstring> TranslationMap;
90 void readLayoutTranslations(TranslationMap const & trans, bool replace);
91 // for the use in std::map
92 friend bool operator<(Language const & p, Language const & q);
99 trivstring polyglossia_name_;
101 trivstring polyglossia_opts_;
103 trivstring quote_style_;
105 trivstring requires_;
111 trivstring encodingStr_;
113 Encoding const * encoding_;
119 trivstring babel_postsettings_;
121 trivstring babel_presettings_;
127 bool as_babel_options_;
129 TranslationMap layoutTranslations_;
133 inline bool operator<(Language const & p, Language const & q)
135 return q.lang() > p.lang();
143 typedef std::map<trivstring, Language> LanguageList;
145 typedef LanguageList::const_iterator const_iterator;
147 typedef LanguageList::size_type size_type;
149 void read(support::FileName const & filename);
151 void readLayoutTranslations(support::FileName const & filename);
153 Language const * getLanguage(std::string const & language) const;
155 size_type size() const { return languagelist.size(); }
157 const_iterator begin() const { return languagelist.begin(); }
159 const_iterator end() const { return languagelist.end(); }
164 LanguageList languagelist;
167 /// Global singleton instance.
168 extern Languages languages;
169 /// Default language defined in LyXRC
170 extern Language const * default_language;
171 /// Used to indicate that the language should be left unchanged when
172 /// applying a font change.
173 extern Language const * ignore_language;
174 /// Default language defined in LyXRC
175 extern Language const * latex_language;
176 /// Used to indicate that the language should be reset to the Buffer
177 // language when applying a font change.
178 extern Language const * reset_language;