+ case Lexer::LEX_UNDEF: // parse error
+ lex.printError("Unknown language tag `$$Token'");
+ error = true;
+ continue;
+
+ default:
+ break;
+ }
+ switch (static_cast<LanguageTags>(le)) {
+ case LA_END: // end of structure
+ finished = true;
+ break;
+ case LA_BABELNAME:
+ lex >> babel_;
+ break;
+ case LA_POLYGLOSSIANAME:
+ lex >> polyglossia_name_;
+ break;
+ case LA_POLYGLOSSIAOPTS:
+ lex >> polyglossia_opts_;
+ break;
+ case LA_QUOTESTYLE:
+ lex >> quote_style_;
+ break;
+ case LA_ENCODING:
+ lex >> encodingStr_;
+ break;
+ case LA_FONTENC: {
+ lex.eatLine();
+ vector<string> const fe =
+ getVectorFromString(lex.getString(true), "|");
+ fontenc_.insert(fontenc_.end(), fe.begin(), fe.end());
+ break;
+ }
+ case LA_DATEFORMATS: {
+ lex.eatLine();
+ vector<string> const df =
+ getVectorFromString(trim(lex.getString(true), "\""), "|");
+ dateformats_.insert(dateformats_.end(), df.begin(), df.end());
+ break;
+ }
+ case LA_GUINAME:
+ lex >> display_;
+ break;
+ case LA_HAS_GUI_SUPPORT:
+ lex >> has_gui_support_;
+ break;
+ case LA_INTERNAL_ENC:
+ lex >> internal_enc_;
+ break;
+ case LA_LANG_CODE:
+ lex >> code_;
+ break;
+ case LA_LANG_VARIETY:
+ lex >> variety_;
+ break;
+ case LA_POSTBABELPREAMBLE:
+ babel_postsettings_ =
+ lex.getLongString(from_ascii("EndPostBabelPreamble"));
+ break;
+ case LA_PREBABELPREAMBLE:
+ babel_presettings_ =
+ lex.getLongString(from_ascii("EndPreBabelPreamble"));
+ break;
+ case LA_REQUIRES:
+ lex >> requires_;
+ break;
+ case LA_PROVIDES:
+ lex >> provides_;
+ break;
+ case LA_RTL:
+ lex >> rightToLeft_;
+ break;
+ }
+ }
+ lex.popTable();
+ return finished && !error;
+}
+
+
+bool Language::read(Lexer & lex)
+{
+ encoding_ = 0;
+ internal_enc_ = 0;
+ rightToLeft_ = 0;
+
+ if (!lex.next()) {
+ lex.printError("No name given for language: `$$Token'.");
+ return false;
+ }
+
+ lang_ = lex.getString();
+ LYXERR(Debug::INFO, "Reading language " << lang_);
+ if (!readLanguage(lex)) {
+ LYXERR0("Error parsing language `" << lang_ << '\'');
+ return false;
+ }
+
+ encoding_ = encodings.fromLyXName(encodingStr_);
+ if (!encoding_ && !encodingStr_.empty()) {
+ encoding_ = encodings.fromLyXName("iso8859-1");
+ LYXERR0("Unknown encoding " << encodingStr_);
+ }
+ if (fontenc_.empty())
+ fontenc_.push_back("ASCII");
+ if (dateformats_.empty()) {
+ dateformats_.push_back("MMMM dd, yyyy");
+ dateformats_.push_back("MMM dd, yyyy");
+ dateformats_.push_back("M/d/yyyy");
+ }
+ return true;
+}
+
+
+void Language::readLayoutTranslations(Language::TranslationMap const & trans, bool replace)
+{
+ TranslationMap::const_iterator const end = trans.end();
+ for (TranslationMap::const_iterator it = trans.begin(); it != end; ++it) {
+ if (replace
+ || layoutTranslations_.find(it->first) == layoutTranslations_.end())
+ layoutTranslations_[it->first] = it->second;
+ }
+}
+
+
+void Languages::read(FileName const & filename)
+{
+ Lexer lex;