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 /// This language needs to be passed to babel itself (not the class)
80 bool asBabelOptions() const { return as_babel_options_; }
82 bool read(Lexer & lex);
84 bool readLanguage(Lexer & lex);
86 typedef std::map<trivstring, trivdocstring> TranslationMap;
88 void readLayoutTranslations(TranslationMap const & trans, bool replace);
89 // for the use in std::map
90 friend bool operator<(Language const & p, Language const & q);
97 trivstring polyglossia_name_;
99 trivstring polyglossia_opts_;
101 trivstring quote_style_;
103 trivstring requires_;
109 trivstring encodingStr_;
111 Encoding const * encoding_;
117 trivstring babel_postsettings_;
119 trivstring babel_presettings_;
123 bool as_babel_options_;
125 TranslationMap layoutTranslations_;
129 inline bool operator<(Language const & p, Language const & q)
131 return q.lang() > p.lang();
139 typedef std::map<trivstring, Language> LanguageList;
141 typedef LanguageList::const_iterator const_iterator;
143 typedef LanguageList::size_type size_type;
145 void read(support::FileName const & filename);
147 void readLayoutTranslations(support::FileName const & filename);
149 Language const * getLanguage(std::string const & language) const;
151 size_type size() const { return languagelist.size(); }
153 const_iterator begin() const { return languagelist.begin(); }
155 const_iterator end() const { return languagelist.end(); }
160 LanguageList languagelist;
163 /// Global singleton instance.
164 extern Languages languages;
165 /// Default language defined in LyXRC
166 extern Language const * default_language;
167 /// Used to indicate that the language should be left unchanged when
168 /// applying a font change.
169 extern Language const * ignore_language;
170 /// Default language defined in LyXRC
171 extern Language const * latex_language;
172 /// Used to indicate that the language should be reset to the Buffer
173 // language when applying a font change.
174 extern Language const * reset_language;