+ bool const maintext = text.isMainText();
+ bool const is_child = buf.masterBuffer() != &buf;
+
+ // Open a CJK environment at the beginning of the main buffer
+ // if the document's language is a CJK language
+ // (but not in child documents)
+ if (maintext && !is_child
+ && bparams.encoding().package() == Encoding::CJK) {
+ os << "\\begin{CJK}{" << from_ascii(bparams.encoding().latexName())
+ << "}{" << from_ascii(bparams.fontsCJK) << "}%\n";
+ texrow.newline();
+ open_encoding_ = CJK;
+ }
+ // if "auto begin" is switched off, explicitely switch the
+ // language on at start
+ if (maintext && !lyxrc.language_auto_begin &&
+ !bparams.language->babel().empty()) {
+ // FIXME UNICODE
+ os << from_utf8(subst(lyxrc.language_command_begin,
+ "$$lang",
+ bparams.language->babel()))
+ << '\n';
+ texrow.newline();
+ }
+
+ ParagraphList::const_iterator lastpar;