+Language const * ignore_language = 0;
+Language const * default_language = 0;
+Language const * latex_language = 0;
+Language const * reset_language = 0;
+
+
+bool Language::isPolyglossiaExclusive() const
+{
+ return babel().empty() && !polyglossia().empty() && requires().empty();
+}
+
+
+bool Language::isBabelExclusive() const
+{
+ return !babel().empty() && polyglossia().empty() && requires().empty();
+}
+
+
+docstring const Language::translateLayout(string const & m) const
+{
+ if (m.empty())
+ return docstring();
+
+ if (!isAscii(m)) {
+ lyxerr << "Warning: not translating `" << m
+ << "' because it is not pure ASCII.\n";
+ return from_utf8(m);
+ }
+
+ TranslationMap::const_iterator it = layoutTranslations_.find(m);
+ if (it != layoutTranslations_.end())
+ return it->second;
+
+ docstring t = from_ascii(m);
+ cleanTranslation(t);
+ return t;
+}
+
+
+string Language::fontenc(BufferParams const & params) const
+{
+ // Don't use LaTeX fonts, so just return the language's preferred
+ // (although this is not used with nonTeXFonts anyway).
+ if (params.useNonTeXFonts)
+ return fontenc_.front() == "ASCII" ? "T1" : fontenc_.front();
+
+ // Determine optimal font encoding
+ // We check whether the used rm font supports an encoding our language supports
+ LaTeXFont const & lf =
+ theLaTeXFonts().getLaTeXFont(from_ascii(params.fontsRoman()));
+ vector<string> const lfe = lf.fontencs();
+ for (auto & fe : fontenc_) {
+ // ASCII means: support all T* encodings plus OT1
+ if (fe == "ASCII") {
+ for (auto & afe : lfe) {
+ if (afe == "OT1" || prefixIs(afe, "T"))
+ // we found a suitable one; return that.
+ return afe;
+ }
+ }
+ // For other encodings, just check whether the font supports it
+ if (lf.hasFontenc(fe))
+ return fe;
+ }
+ // We did not find a suitable one; just take the first in the list,
+ // the priorized one (which is "T1" for ASCII).
+ return fontenc_.front() == "ASCII" ? "T1" : fontenc_.front();
+}
+
+
+string Language::dateFormat(size_t i) const
+{
+ if (i > dateformats_.size())
+ return string();
+ return dateformats_.at(i);
+}
+
+
+bool Language::readLanguage(Lexer & lex)
+{
+ enum LanguageTags {
+ LA_BABELNAME = 1,
+ LA_DATEFORMATS,
+ LA_ENCODING,
+ LA_END,
+ LA_FONTENC,
+ LA_GUINAME,
+ LA_HAS_GUI_SUPPORT,
+ LA_INTERNAL_ENC,
+ LA_LANG_CODE,
+ LA_LANG_VARIETY,
+ LA_POLYGLOSSIANAME,
+ LA_POLYGLOSSIAOPTS,
+ LA_POSTBABELPREAMBLE,
+ LA_PREBABELPREAMBLE,
+ LA_PROVIDES,
+ LA_REQUIRES,
+ LA_QUOTESTYLE,
+ LA_RTL
+ };
+
+ // Keep these sorted alphabetically!
+ LexerKeyword languageTags[] = {
+ { "babelname", LA_BABELNAME },
+ { "dateformats", LA_DATEFORMATS },
+ { "encoding", LA_ENCODING },
+ { "end", LA_END },
+ { "fontencoding", LA_FONTENC },
+ { "guiname", LA_GUINAME },
+ { "hasguisupport", LA_HAS_GUI_SUPPORT },
+ { "internalencoding", LA_INTERNAL_ENC },
+ { "langcode", LA_LANG_CODE },
+ { "langvariety", LA_LANG_VARIETY },
+ { "polyglossianame", LA_POLYGLOSSIANAME },
+ { "polyglossiaopts", LA_POLYGLOSSIAOPTS },
+ { "postbabelpreamble", LA_POSTBABELPREAMBLE },
+ { "prebabelpreamble", LA_PREBABELPREAMBLE },
+ { "provides", LA_PROVIDES },
+ { "quotestyle", LA_QUOTESTYLE },
+ { "requires", LA_REQUIRES },
+ { "rtl", LA_RTL }
+ };