Re: Number of Japanese tests fails now
"Jürgen Spitzmüller" <[email protected]>
| Newsgroups | gmane.editors.lyx.devel |
|---|---|
| Message-ID | <[email protected]> |
Am Freitag, dem 24.04.2026 um 11:16 +0200 schrieb Jürgen Spitzmüller: > Attached an attempt to address this (file format and prefs format > change not yet included). Please use this one instead after d525f108a1a (which prepares the prefs with a change that was sensible anyway). This also includes the file format change. -- Jürgen -- lyx-devel mailing list [email protected] https://lists.lyx.org/mailman/listinfo/lyx-devel
plang2.diff
(text/x-patch, 9.7 KB)
diff --git a/lib/languages b/lib/languages
index 00eba40919..2fb7c20f06 100644
--- a/lib/languages
+++ b/lib/languages
@@ -13,6 +13,7 @@
# BabelOptFormat <format of option specification>
# PolyglossiaName <polyglossianame>
# PolyglossiaOpts "<language-specific options>"
+# PreferLangPack <string>
# XindyName <xindyname>
# ActiveChars <activated characters>
# QuoteStyle <british|danish|english|french|frenchin|
@@ -159,6 +160,9 @@
# requirement specified in "AltLangIfNot <requirement>" is not met.
# AltLanguage inherits the settings of the corresponding Language if the
# latter is defined first.
+# * PreferLangPack might be used to define a language package that is used
+# if this language is used alone and general language package setting is
+# "auto".
#
##########################################################################
@@ -1780,6 +1784,7 @@ Language japanese
BabelName japanese
BabelOptFormat \languageattribute{$lang$}{$opts$}
PolyglossiaName japanese
+ PreferLangPack none
Encoding jis-platex
WordWrap false
ImOffInMath true
diff --git a/lib/lyx2lyx/lyx_2_6.py b/lib/lyx2lyx/lyx_2_6.py
index 507086648f..9aacfb75bf 100644
--- a/lib/lyx2lyx/lyx_2_6.py
+++ b/lib/lyx2lyx/lyx_2_6.py
@@ -886,6 +886,13 @@ def revert_shorthands2(document):
i += 1
continue
+
+def revert_lp_polyglossia(document):
+ """Revert language package polyglossia to auto"""
+ i = find_token(document.header, "\\language_package polyglossia", 0)
+ if i != -1:
+ document.header[i] = "\\language_package auto"
+
##
# Conversion hub
#
@@ -897,11 +904,13 @@ convert = [
[646, []],
[647, [convert_textbreaks]],
[648, []],
- [649, []]
+ [649, []],
+ [650, []]
]
revert = [
+ [649, [revert_lp_polyglossia]],
[648, [revert_shorthands2]],
[647, [revert_hyphen_shorthands]],
[646, [revert_textbreaks]],
diff --git a/src/Font.cpp b/src/Font.cpp
index bb5543d58c..1001bde4a1 100644
--- a/src/Font.cpp
+++ b/src/Font.cpp
@@ -822,8 +822,8 @@ void Font::validate(LaTeXFeatures & features) const
// FIXME: Do something for background and soul package?
- if (((features.usePolyglossia() && lang_->polyglossia() != doc_language->polyglossia())
- || (features.useBabel() && lang_->babel() != doc_language->babel())
+ if (((features.usePolyglossia(true) && lang_->polyglossia() != doc_language->polyglossia())
+ || (features.useBabel(true) && lang_->babel() != doc_language->babel())
|| (doc_language->encoding()->package() == Encoding::CJK && lang_ != doc_language))
&& lang_ != ignore_language
&& lang_ != latex_language)
diff --git a/src/LaTeXFeatures.cpp b/src/LaTeXFeatures.cpp
index cc61cc5f59..acf50a28ed 100644
--- a/src/LaTeXFeatures.cpp
+++ b/src/LaTeXFeatures.cpp
@@ -577,14 +577,24 @@ LaTeXFeatures::LaTeXFeatures(Buffer const & b, BufferParams const & p,
{}
-LaTeXFeatures::LangPackage LaTeXFeatures::langPackage() const
-{
- string const local_lp = bufferParams().lang_package;
+LaTeXFeatures::LangPackage LaTeXFeatures::langPackage(bool const ignore_prefs) const
+{
+ // monolingual documents with PreferLangPack use that if the local
+ // or global setting is "auto"
+ string const local_lp = (!ignore_prefs
+ && (bufferParams().lang_package == "auto"
+ || (bufferParams().lang_package == "default"
+ && lyxrc.language_package_selection == "auto"))
+ && !hasLanguages()
+ && !params_.language->preferLangPack().empty())
+ ? params_.language->preferLangPack()
+ : bufferParams().lang_package;
// Locally, custom is just stored as a string
// in bufferParams().lang_package.
if (local_lp != "auto"
&& local_lp != "babel"
+ && local_lp != "polyglossia"
&& local_lp != "default"
&& local_lp != "none")
return LANG_PACK_CUSTOM;
@@ -592,7 +602,7 @@ LaTeXFeatures::LangPackage LaTeXFeatures::langPackage() const
if (local_lp == "none")
return LANG_PACK_NONE;
- /* If "auto" is selected, we load polyglossia with non-TeX fonts,
+ /* If "auto" or "polyglossia" is selected, we load polyglossia with non-TeX fonts,
* else we select babel.
* If babel is selected (either directly or via the "auto"
* mechanism), we really do only require it if we have
@@ -607,7 +617,7 @@ LaTeXFeatures::LangPackage LaTeXFeatures::langPackage() const
!bufferParams().language->babel().empty()
|| !this->getBabelLanguages().empty();
- if (local_lp == "auto") {
+ if (local_lp == "auto" || local_lp == "polyglossia") {
// polyglossia requirement has priority over babel
if (polyglossia_required)
return LANG_PACK_POLYGLOSSIA;
@@ -621,7 +631,8 @@ LaTeXFeatures::LangPackage LaTeXFeatures::langPackage() const
}
if (local_lp == "default") {
- if (lyxrc.language_package_selection == "auto") {
+ if (lyxrc.language_package_selection == "auto"
+ || lyxrc.language_package_selection == "polyglossia") {
// polyglossia requirement has priority over babel
if (polyglossia_required)
return LANG_PACK_POLYGLOSSIA;
diff --git a/src/LaTeXFeatures.h b/src/LaTeXFeatures.h
index 2e5b61db79..f794f76596 100644
--- a/src/LaTeXFeatures.h
+++ b/src/LaTeXFeatures.h
@@ -185,11 +185,11 @@ public:
/** Which language package do we require? \p englishbabel determines
* if we require babel even if English is the only language.
*/
- LangPackage langPackage() const;
+ LangPackage langPackage(bool const ignore_prefs = false) const;
/// Convenience function to test if we use babel
- bool useBabel() const { return langPackage() == LANG_PACK_BABEL; }
+ bool useBabel(bool const ignore_prefs = false) const { return langPackage(ignore_prefs) == LANG_PACK_BABEL; }
/// Convenience function to test if we use polyglossia
- bool usePolyglossia() const { return langPackage() == LANG_PACK_POLYGLOSSIA; }
+ bool usePolyglossia(bool const ignore_prefs = false) const { return langPackage(ignore_prefs) == LANG_PACK_POLYGLOSSIA; }
/// are we in a float?
bool inFloat() const { return in_float_; }
/// are we in a float?
diff --git a/src/Language.cpp b/src/Language.cpp
index 718031218b..68f2adb6bd 100644
--- a/src/Language.cpp
+++ b/src/Language.cpp
@@ -157,6 +157,7 @@ bool Language::readLanguage(Lexer & lex)
LA_LANG_VARIETY,
LA_POLYGLOSSIANAME,
LA_POLYGLOSSIAOPTS,
+ LA_PREFERLANGPACK,
LA_XINDYNAME,
LA_POSTBABELPREAMBLE,
LA_PREBABELPREAMBLE,
@@ -195,6 +196,7 @@ bool Language::readLanguage(Lexer & lex)
{ "polyglossiaopts", LA_POLYGLOSSIAOPTS },
{ "postbabelpreamble", LA_POSTBABELPREAMBLE },
{ "prebabelpreamble", LA_PREBABELPREAMBLE },
+ { "preferlangpack", LA_PREFERLANGPACK },
{ "provides", LA_PROVIDES },
{ "quotestyle", LA_QUOTESTYLE },
{ "requires", LA_REQUIRES },
@@ -246,6 +248,9 @@ bool Language::readLanguage(Lexer & lex)
case LA_POLYGLOSSIAOPTS:
lex >> polyglossia_opts_;
break;
+ case LA_PREFERLANGPACK:
+ lex >> prefer_lang_pack_;
+ break;
case LA_XINDYNAME:
lex >> xindy_;
break;
diff --git a/src/Language.h b/src/Language.h
index 80f56198db..203d326d2c 100644
--- a/src/Language.h
+++ b/src/Language.h
@@ -59,6 +59,8 @@ public:
/// polyglossia language options
std::string const polyglossiaOpts() const { return polyglossia_opts_; }
/// polyglossia language options
+ std::string const preferLangPack() const { return prefer_lang_pack_; }
+ /// polyglossia language options
std::string const xindy() const { return xindy_; }
/// Is this language only supported by polyglossia?
bool isPolyglossiaExclusive() const;
@@ -149,6 +151,8 @@ private:
///
trivstring polyglossia_opts_;
///
+ trivstring prefer_lang_pack_;
+ ///
trivstring xindy_;
///
trivstring quote_style_;
diff --git a/src/frontends/qt/GuiDocument.cpp b/src/frontends/qt/GuiDocument.cpp
index c4dcc782e2..ea19171bf3 100644
--- a/src/frontends/qt/GuiDocument.cpp
+++ b/src/frontends/qt/GuiDocument.cpp
@@ -1107,6 +1107,8 @@ GuiDocument::GuiDocument(GuiView & lv)
qt_("Automatic"), toqstr("auto"));
langModule->languagePackageCO->addItem(
qt_("Always Babel"), toqstr("babel"));
+ langModule->languagePackageCO->addItem(
+ qt_("Polyglossia if Possible"), toqstr("polyglossia"));
langModule->languagePackageCO->addItem(
qt_("Custom"), toqstr("custom"));
langModule->languagePackageCO->addItem(
@@ -4352,7 +4354,7 @@ void GuiDocument::paramsToDialog()
if (extern_babel)
p = langModule->languagePackageCO->findData(toqstr("babel"));
else if (extern_polyglossia)
- p = langModule->languagePackageCO->findData(toqstr("auto"));
+ p = langModule->languagePackageCO->findData(toqstr("polyglossia"));
else
p = langModule->languagePackageCO->findData(toqstr(bp_.lang_package));
diff --git a/src/frontends/qt/GuiPrefs.cpp b/src/frontends/qt/GuiPrefs.cpp
index f3dbcb827e..1290556215 100644
--- a/src/frontends/qt/GuiPrefs.cpp
+++ b/src/frontends/qt/GuiPrefs.cpp
@@ -3274,6 +3274,8 @@ PrefLanguage::PrefLanguage(GuiPreferences * form)
qt_("Automatic"), toqstr("auto"));
languagePackageCO->addItem(
qt_("Always Babel"), toqstr("babel"));
+ languagePackageCO->addItem(
+ qt_("Polyglossia if Possible"), toqstr("polyglossia"));
languagePackageCO->addItem(
qt_("Custom"), toqstr("custom"));
languagePackageCO->addItem(
diff --git a/src/version.h b/src/version.h
index a97dda20e0..1c0ba33986 100644
--- a/src/version.h
+++ b/src/version.h
@@ -32,8 +32,8 @@ extern char const * const lyx_version_info;
// Do not remove the comment below, so we get merge conflict in
// independent branches. Instead add your own.
-#define LYX_FORMAT_LYX 649 // spitz: more shorthands
-#define LYX_FORMAT_TEX2LYX 649
+#define LYX_FORMAT_LYX 650 // spitz: language package polyglossia
+#define LYX_FORMAT_TEX2LYX 650
#if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
#ifndef _MSC_VER