mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-30 05:12:40 +00:00
Fix missing language option for CJKutf8.tex
This commit is contained in:
parent
248c6ded33
commit
4061e5bbdb
@ -442,8 +442,8 @@ string remove_braces(string const & value)
|
||||
} // anonymous namespace
|
||||
|
||||
|
||||
Preamble::Preamble() : one_language(true), title_layout_found(false),
|
||||
h_font_cjk_set(false)
|
||||
Preamble::Preamble() : one_language(true), explicit_babel(false),
|
||||
title_layout_found(false), h_font_cjk_set(false)
|
||||
{
|
||||
//h_backgroundcolor;
|
||||
//h_boxbgcolor;
|
||||
@ -819,9 +819,10 @@ void Preamble::handle_package(Parser &p, string const & name,
|
||||
h_preamble << "\\usepackage[" << opts << "]{babel}\n";
|
||||
}
|
||||
delete_opt(options, known_languages);
|
||||
}
|
||||
else
|
||||
} else {
|
||||
h_preamble << "\\usepackage{babel}\n";
|
||||
explicit_babel = true;
|
||||
}
|
||||
}
|
||||
|
||||
else if (name == "polyglossia") {
|
||||
@ -1884,6 +1885,21 @@ void Preamble::parse(Parser & p, string const & forceclass,
|
||||
p.pushPosition();
|
||||
h_language = guessLanguage(p, default_language);
|
||||
p.popPosition();
|
||||
if (explicit_babel && h_language != default_language) {
|
||||
// We set the document language to a CJK language,
|
||||
// but babel is explicitly called in the user preamble
|
||||
// without options. LyX will not add the default
|
||||
// language to the document options if it is either
|
||||
// english, or no text is set as default language.
|
||||
// Therefore we need to add a language option explicitly.
|
||||
// FIXME: It would be better to remove all babel calls
|
||||
// from the user preamble, but this is difficult
|
||||
// without re-introducing bug 7861.
|
||||
if (h_options.empty())
|
||||
h_options = lyx2babel(default_language);
|
||||
else
|
||||
h_options += ',' + lyx2babel(default_language);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1897,6 +1913,15 @@ string babel2lyx(string const & language)
|
||||
}
|
||||
|
||||
|
||||
string lyx2babel(string const & language)
|
||||
{
|
||||
char const * const * where = is_known(language, known_coded_languages);
|
||||
if (where)
|
||||
return known_languages[where - known_coded_languages];
|
||||
return language;
|
||||
}
|
||||
|
||||
|
||||
string Preamble::polyglossia2lyx(string const & language)
|
||||
{
|
||||
char const * const * where = is_known(language, polyglossia_languages);
|
||||
|
@ -105,6 +105,8 @@ private:
|
||||
bool one_language;
|
||||
/// the main non-CJK language
|
||||
std::string default_language;
|
||||
/// Was babel called explicitly?
|
||||
bool explicit_babel;
|
||||
|
||||
/// was at least one title layout found?
|
||||
bool title_layout_found;
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
|
||||
\end_preamble
|
||||
\options english
|
||||
\use_default_options false
|
||||
\maintain_unincluded_children false
|
||||
\language japanese-cjk
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
|
||||
\end_preamble
|
||||
\options english
|
||||
\use_default_options false
|
||||
\maintain_unincluded_children false
|
||||
\language chinese-traditional
|
||||
|
@ -45,6 +45,8 @@ public:
|
||||
|
||||
/// Translate babel language name to LyX language name
|
||||
extern std::string babel2lyx(std::string const & language);
|
||||
/// Translate LyX language name to babel language name
|
||||
extern std::string lyx2babel(std::string const & language);
|
||||
/// Translate polyglossia language name to LyX language name
|
||||
extern std::string polyglossia2lyx(std::string const & language);
|
||||
/// Translate basic color name or RGB color in LaTeX syntax to LyX color code
|
||||
|
Loading…
Reference in New Issue
Block a user