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"
40 Language() : rightToLeft_(false), encoding_(0), internal_enc_(false),
41 has_gui_support_(false), word_wrap_(true) {}
43 std::string const lang() const { return lang_; }
44 /// Babel language name
45 std::string const babel() const { return babel_; }
46 /// polyglossia language name
47 std::string const polyglossia() const { return polyglossia_name_; }
48 /// polyglossia language options
49 std::string const polyglossiaOpts() const { return polyglossia_opts_; }
50 /// polyglossia language options
51 std::string const xindy() const { return xindy_; }
52 /// Is this language only supported by polyglossia?
53 bool isPolyglossiaExclusive() const;
54 /// Is this language only supported by babel?
55 bool isBabelExclusive() const;
56 /// quotation marks style
57 std::string const quoteStyle() const { return quote_style_; }
59 std::string const activeChars() const { return active_chars_; }
60 /// requirement (package, function)
61 std::string const required() const { return required_; }
63 std::string const provides() const { return provides_; }
64 /// translatable GUI name
65 std::string const display() const { return display_; }
66 /// is this a RTL language?
67 bool rightToLeft() const { return rightToLeft_; }
68 /// shall text be wrapped at word boundary ?
69 bool wordWrap() const { return word_wrap_; }
71 * Translate a string from the layout files that appears in the output.
72 * It takes the translations from lib/layouttranslations instead of
73 * the .mo files. This should be used for every translation that
74 * appears in the exported document, since the output must not depend
75 * on installed locales. Non-ASCII keys are not translated. */
76 docstring const translateLayout(std::string const & msg) const;
78 Encoding const * encoding() const { return encoding_; }
80 std::string const encodingStr() const { return encodingStr_; }
82 std::string const code() const { return code_; }
83 /// set code (needed for rc.spellchecker_alt_lang)
84 void setCode(std::string const & c) { code_ = c; }
85 /// language variety (needed by aspell checker)
86 std::string const variety() const { return variety_; }
87 /// set variety (needed for rc.spellchecker_alt_lang)
88 void setVariety(std::string const & v) { variety_ = v; }
89 /// preamble settings after babel was called
90 docstring babel_postsettings() const { return babel_postsettings_; }
91 /// preamble settings before babel is called
92 docstring babel_presettings() const { return babel_presettings_; }
93 /// This language internally sets a font encoding
94 bool internalFontEncoding() const { return internal_enc_; }
95 /// The most suitable font encoding(s) for the selected document font
96 std::string fontenc(BufferParams const &) const;
97 /// Return the localized date formats (long, medium, short format)
98 std::string dateFormat(size_t i) const;
99 /// Return the localized decimal separator
100 docstring decimalSeparator() const;
101 /// This language corresponds to a translation of the GUI
102 bool hasGuiSupport() const { return has_gui_support_; }
104 bool read(support::Lexer & lex);
106 bool readLanguage(support::Lexer & lex);
108 typedef std::map<trivstring, trivdocstring> TranslationMap;
110 void readLayoutTranslations(TranslationMap const & trans, bool replace);
111 // for the use in std::map
112 friend bool operator<(Language const & p, Language const & q);
119 trivstring polyglossia_name_;
121 trivstring polyglossia_opts_;
125 trivstring quote_style_;
127 trivstring active_chars_;
129 trivstring required_;
131 trivstring provides_;
137 trivstring encodingStr_;
139 Encoding const * encoding_;
145 trivdocstring babel_postsettings_;
147 trivdocstring babel_presettings_;
149 std::vector<std::string> fontenc_;
151 std::vector<std::string> dateformats_;
155 bool has_gui_support_;
159 TranslationMap layoutTranslations_;
163 inline bool operator<(Language const & p, Language const & q)
165 return q.lang() > p.lang();
173 typedef std::map<trivstring, Language> LanguageList;
175 typedef LanguageList::const_iterator const_iterator;
177 typedef LanguageList::size_type size_type;
179 void read(support::FileName const & filename);
181 Language const * getFromCode(std::string const & code) const;
183 Language const * getFromCode(std::string const & code,
184 std::set<Language const *> const & tryfirst) const;
186 void readLayoutTranslations(support::FileName const & filename);
188 Language const * getLanguage(std::string const & language) const;
190 size_type size() const { return languagelist_.size(); }
192 const_iterator begin() const { return languagelist_.begin(); }
194 const_iterator end() const { return languagelist_.end(); }
198 LanguageList languagelist_;
201 /// Global singleton instance.
202 extern Languages languages;
203 /// Default language defined in LyXRC
204 extern Language const * default_language;
205 /// Used to indicate that the language should be left unchanged when
206 /// applying a font change.
207 extern Language const * ignore_language;
208 /// Default language defined in LyXRC
209 extern Language const * latex_language;
210 /// Used to indicate that the language should be reset to the Buffer
211 // language when applying a font change.
212 extern Language const * reset_language;