mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-09 18:31:04 +00:00
Basic support for \babelprovide
This is the new(er) babel mechanism to load languages via babel *.ini files. Some languages (or varieties) are only supported this way, some work better with unicode engines this way (for the latter case, we have BabelProvide 2)
This commit is contained in:
parent
ac509f3b6e
commit
047dee5a3b
@ -8,6 +8,7 @@
|
|||||||
# GuiName "<Gui Name>"
|
# GuiName "<Gui Name>"
|
||||||
# HasGuiSupport <true|false>
|
# HasGuiSupport <true|false>
|
||||||
# BabelName <babelname>
|
# BabelName <babelname>
|
||||||
|
# BabelProvide <0|1|2>
|
||||||
# BabelOpts "<language-specific options>"
|
# BabelOpts "<language-specific options>"
|
||||||
# BabelOptFormat <format of option specification>
|
# BabelOptFormat <format of option specification>
|
||||||
# PolyglossiaName <polyglossianame>
|
# PolyglossiaName <polyglossianame>
|
||||||
@ -130,6 +131,9 @@
|
|||||||
# be de-activated in some contexts (such as - or =).
|
# be de-activated in some contexts (such as - or =).
|
||||||
# * XindyName holds the value to the (te)xindy -L option. We only give it
|
# * XindyName holds the value to the (te)xindy -L option. We only give it
|
||||||
# if a corresponding language module exists.
|
# if a corresponding language module exists.
|
||||||
|
# * BabelProvide determines if and when a language should be loaded from
|
||||||
|
# babel *.ini files with babel. Possible values:
|
||||||
|
# 0 (= never, default), 1 (always), 2 (with Unicode engines/non-TeX fonts)
|
||||||
# * BabelOpts are comma separated, no matter how they shall be represented
|
# * BabelOpts are comma separated, no matter how they shall be represented
|
||||||
# in the output.
|
# in the output.
|
||||||
# * BabelOptFormat specifies how the language-specific options shall be
|
# * BabelOptFormat specifies how the language-specific options shall be
|
||||||
|
@ -3503,6 +3503,7 @@ string BufferParams::babelCall(LaTeXFeatures const & features, string lang_opts,
|
|||||||
std::set<Language const *> langs = features.getLanguages();
|
std::set<Language const *> langs = features.getLanguages();
|
||||||
// add main language
|
// add main language
|
||||||
langs.insert(language);
|
langs.insert(language);
|
||||||
|
ostringstream os;
|
||||||
for (auto const & l : langs) {
|
for (auto const & l : langs) {
|
||||||
string blang = l->babel();
|
string blang = l->babel();
|
||||||
bool use_opt = langoptions;
|
bool use_opt = langoptions;
|
||||||
@ -3522,7 +3523,16 @@ string BufferParams::babelCall(LaTeXFeatures const & features, string lang_opts,
|
|||||||
use_opt = true;
|
use_opt = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (use_opt)
|
if (l->useBabelProvide() == 1 || (l->useBabelProvide() == 2 && useNonTeXFonts)) {
|
||||||
|
os << "\n\\babelprovide[import";
|
||||||
|
if (l == language)
|
||||||
|
os << ", main";
|
||||||
|
if (!babelLangOptions(l->lang()).empty())
|
||||||
|
os << ", " << babelLangOptions(l->lang());
|
||||||
|
os << "]{" << blang << "}";
|
||||||
|
have_mods = true;
|
||||||
|
}
|
||||||
|
else if (use_opt)
|
||||||
blangs.push_back(blang);
|
blangs.push_back(blang);
|
||||||
}
|
}
|
||||||
if (have_mods)
|
if (have_mods)
|
||||||
@ -3530,8 +3540,8 @@ string BufferParams::babelCall(LaTeXFeatures const & features, string lang_opts,
|
|||||||
// The prefs may require the languages to
|
// The prefs may require the languages to
|
||||||
// be submitted to babel itself (not the class).
|
// be submitted to babel itself (not the class).
|
||||||
if (langoptions || have_mods)
|
if (langoptions || have_mods)
|
||||||
return "\\usepackage[" + lang_opts + "]{babel}";
|
return "\\usepackage[" + lang_opts + "]{babel}" + os.str();
|
||||||
return "\\usepackage{babel}";
|
return "\\usepackage{babel}" + os.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1822,7 +1822,7 @@ docstring const LaTeXFeatures::getBabelPostsettings() const
|
|||||||
for (auto const & lang : langs) {
|
for (auto const & lang : langs) {
|
||||||
if (!lang->babel_postsettings().empty())
|
if (!lang->babel_postsettings().empty())
|
||||||
tmp << lang->babel_postsettings() << '\n';
|
tmp << lang->babel_postsettings() << '\n';
|
||||||
if (lang->babelOptFormat() != "modifier") {
|
if (lang->babelOptFormat() != "modifier" && lang->useBabelProvide() == 0) {
|
||||||
// user-set options
|
// user-set options
|
||||||
string const opts = bufferParams().babelLangOptions(lang->lang());
|
string const opts = bufferParams().babelLangOptions(lang->lang());
|
||||||
if (!opts.empty())
|
if (!opts.empty())
|
||||||
|
@ -133,6 +133,7 @@ bool Language::readLanguage(Lexer & lex)
|
|||||||
LA_BABELNAME = 1,
|
LA_BABELNAME = 1,
|
||||||
LA_BABELOPTFORMAT,
|
LA_BABELOPTFORMAT,
|
||||||
LA_BABELOPTS,
|
LA_BABELOPTS,
|
||||||
|
LA_BABELPROVIDE,
|
||||||
LA_DATEFORMATS,
|
LA_DATEFORMATS,
|
||||||
LA_ENCODING,
|
LA_ENCODING,
|
||||||
LA_END,
|
LA_END,
|
||||||
@ -161,6 +162,7 @@ bool Language::readLanguage(Lexer & lex)
|
|||||||
{ "babelname", LA_BABELNAME },
|
{ "babelname", LA_BABELNAME },
|
||||||
{ "babeloptformat", LA_BABELOPTFORMAT },
|
{ "babeloptformat", LA_BABELOPTFORMAT },
|
||||||
{ "babelopts", LA_BABELOPTS },
|
{ "babelopts", LA_BABELOPTS },
|
||||||
|
{ "babelprovide", LA_BABELPROVIDE },
|
||||||
{ "dateformats", LA_DATEFORMATS },
|
{ "dateformats", LA_DATEFORMATS },
|
||||||
{ "encoding", LA_ENCODING },
|
{ "encoding", LA_ENCODING },
|
||||||
{ "end", LA_END },
|
{ "end", LA_END },
|
||||||
@ -214,6 +216,9 @@ bool Language::readLanguage(Lexer & lex)
|
|||||||
case LA_BABELOPTS:
|
case LA_BABELOPTS:
|
||||||
lex >> babel_opts_;
|
lex >> babel_opts_;
|
||||||
break;
|
break;
|
||||||
|
case LA_BABELPROVIDE:
|
||||||
|
lex >> use_babel_provide_;
|
||||||
|
break;
|
||||||
case LA_POLYGLOSSIANAME:
|
case LA_POLYGLOSSIANAME:
|
||||||
lex >> polyglossia_name_;
|
lex >> polyglossia_name_;
|
||||||
break;
|
break;
|
||||||
|
@ -38,7 +38,8 @@ class Language {
|
|||||||
public:
|
public:
|
||||||
///
|
///
|
||||||
Language() : rightToLeft_(false), encoding_(0), internal_enc_(false),
|
Language() : rightToLeft_(false), encoding_(0), internal_enc_(false),
|
||||||
has_gui_support_(false), word_wrap_(true) {}
|
has_gui_support_(false), word_wrap_(true),
|
||||||
|
use_babel_provide_(0){}
|
||||||
/// LyX language name
|
/// LyX language name
|
||||||
std::string const lang() const { return lang_; }
|
std::string const lang() const { return lang_; }
|
||||||
/// Babel language name
|
/// Babel language name
|
||||||
@ -47,6 +48,8 @@ public:
|
|||||||
std::string const babelOpts() const { return babel_opts_; }
|
std::string const babelOpts() const { return babel_opts_; }
|
||||||
/// Babel option format
|
/// Babel option format
|
||||||
std::string const babelOptFormat() const { return babeloptformat_; }
|
std::string const babelOptFormat() const { return babeloptformat_; }
|
||||||
|
/// Use \babelprovide with babel?
|
||||||
|
int useBabelProvide() const { return use_babel_provide_; }
|
||||||
/// polyglossia language name
|
/// polyglossia language name
|
||||||
std::string const polyglossia() const { return polyglossia_name_; }
|
std::string const polyglossia() const { return polyglossia_name_; }
|
||||||
/// polyglossia language options
|
/// polyglossia language options
|
||||||
@ -165,6 +168,8 @@ private:
|
|||||||
bool word_wrap_;
|
bool word_wrap_;
|
||||||
///
|
///
|
||||||
TranslationMap layoutTranslations_;
|
TranslationMap layoutTranslations_;
|
||||||
|
///
|
||||||
|
int use_babel_provide_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ namespace {
|
|||||||
* please keep this in sync with known_coded_languages line by line!
|
* please keep this in sync with known_coded_languages line by line!
|
||||||
*/
|
*/
|
||||||
const char * const known_languages[] = {"acadian", "afrikaans", "albanian",
|
const char * const known_languages[] = {"acadian", "afrikaans", "albanian",
|
||||||
"american", "arabic", "arabtex", "australian", "austrian", "azerbaijani", "bahasa", "bahasai",
|
"american", "ancientgreek", "arabic", "arabtex", "australian", "austrian", "azerbaijani", "bahasa", "bahasai",
|
||||||
"bahasam", "basque", "belarusian", "bosnian", "brazil", "brazilian", "breton", "british",
|
"bahasam", "basque", "belarusian", "bosnian", "brazil", "brazilian", "breton", "british",
|
||||||
"bulgarian", "canadian", "canadien", "catalan", "croatian", "czech", "danish",
|
"bulgarian", "canadian", "canadien", "catalan", "croatian", "czech", "danish",
|
||||||
"dutch", "english", "esperanto", "estonian", "farsi", "finnish", "francais",
|
"dutch", "english", "esperanto", "estonian", "farsi", "finnish", "francais",
|
||||||
@ -58,7 +58,7 @@ const char * const known_languages[] = {"acadian", "afrikaans", "albanian",
|
|||||||
"georgian", "greek", "hebrew", "hungarian", "icelandic", "indon", "indonesian",
|
"georgian", "greek", "hebrew", "hungarian", "icelandic", "indon", "indonesian",
|
||||||
"interlingua", "irish", "italian", "japanese", "kazakh", "kurmanji", "latin",
|
"interlingua", "irish", "italian", "japanese", "kazakh", "kurmanji", "latin",
|
||||||
"latvian", "lithuanian", "lowersorbian", "lsorbian", "macedonian", "magyar", "malay", "meyalu",
|
"latvian", "lithuanian", "lowersorbian", "lsorbian", "macedonian", "magyar", "malay", "meyalu",
|
||||||
"mongolian", "naustrian", "newzealand", "ngerman", "ngermanb", "norsk", "nswissgerman",
|
"mexican", "mongolian", "naustrian", "newzealand", "ngerman", "ngermanb", "norsk", "nswissgerman",
|
||||||
"nynorsk", "piedmontese", "polutonikogreek", "polish", "portuges", "portuguese",
|
"nynorsk", "piedmontese", "polutonikogreek", "polish", "portuges", "portuguese",
|
||||||
"romanian", "romansh", "russian", "russianb", "samin", "scottish", "serbian", "serbian-latin",
|
"romanian", "romansh", "russian", "russianb", "samin", "scottish", "serbian", "serbian-latin",
|
||||||
"slovak", "slovene", "spanish", "swedish", "swissgerman", "thai", "turkish", "turkmen",
|
"slovak", "slovene", "spanish", "swedish", "swissgerman", "thai", "turkish", "turkmen",
|
||||||
@ -71,7 +71,7 @@ const char * const known_languages[] = {"acadian", "afrikaans", "albanian",
|
|||||||
* please keep this in sync with known_languages line by line!
|
* please keep this in sync with known_languages line by line!
|
||||||
*/
|
*/
|
||||||
const char * const known_coded_languages[] = {"french", "afrikaans", "albanian",
|
const char * const known_coded_languages[] = {"french", "afrikaans", "albanian",
|
||||||
"american", "arabic_arabi", "arabic_arabtex", "australian", "austrian", "azerbaijani", "bahasa", "bahasa",
|
"american", "ancientgreek", "arabic_arabi", "arabic_arabtex", "australian", "austrian", "azerbaijani", "bahasa", "bahasa",
|
||||||
"bahasam", "basque", "belarusian", "bosnian", "brazilian", "brazilian", "breton", "british",
|
"bahasam", "basque", "belarusian", "bosnian", "brazilian", "brazilian", "breton", "british",
|
||||||
"bulgarian", "canadian", "canadien", "catalan", "croatian", "czech", "danish",
|
"bulgarian", "canadian", "canadien", "catalan", "croatian", "czech", "danish",
|
||||||
"dutch", "english", "esperanto", "estonian", "farsi", "finnish", "french",
|
"dutch", "english", "esperanto", "estonian", "farsi", "finnish", "french",
|
||||||
@ -79,7 +79,7 @@ const char * const known_coded_languages[] = {"french", "afrikaans", "albanian",
|
|||||||
"georgian", "greek", "hebrew", "magyar", "icelandic", "bahasa", "bahasa",
|
"georgian", "greek", "hebrew", "magyar", "icelandic", "bahasa", "bahasa",
|
||||||
"interlingua", "irish", "italian", "japanese", "kazakh", "kurmanji", "latin",
|
"interlingua", "irish", "italian", "japanese", "kazakh", "kurmanji", "latin",
|
||||||
"latvian", "lithuanian", "lowersorbian", "lowersorbian", "macedonian", "magyar", "bahasam", "bahasam",
|
"latvian", "lithuanian", "lowersorbian", "lowersorbian", "macedonian", "magyar", "bahasam", "bahasam",
|
||||||
"mongolian", "naustrian", "newzealand", "ngerman", "ngerman", "norsk", "german-ch",
|
"spanish-mexico", "mongolian", "naustrian", "newzealand", "ngerman", "ngerman", "norsk", "german-ch",
|
||||||
"nynorsk", "piedmontese", "polutonikogreek", "polish", "portuguese", "portuguese",
|
"nynorsk", "piedmontese", "polutonikogreek", "polish", "portuguese", "portuguese",
|
||||||
"romanian", "romansh", "russian", "russian", "samin", "scottish", "serbian", "serbian-latin",
|
"romanian", "romansh", "russian", "russian", "samin", "scottish", "serbian", "serbian-latin",
|
||||||
"slovak", "slovene", "spanish", "swedish", "german-ch-old", "thai", "turkish", "turkmen",
|
"slovak", "slovene", "spanish", "swedish", "german-ch-old", "thai", "turkish", "turkmen",
|
||||||
|
Loading…
Reference in New Issue
Block a user