Add support for the following languages

Polyglossia:
Chinese (Simplified), Chinese (Traditional), Japanese, Kurdish (Sorani),
Latin (Classic), Latin (Ecclesiastic), Latin (Medieval), N'ko, Odia,
Punjabi, and Uyghur

Babel:
Amharic, Armenian, Asturian, Bengali, Church Slavonic, Coptic, Divehi,
Kannada, Kazakh, Khmer, Kurdish (Sorani), Lao, Latin (Classic),
Latin (Ecclesiastic), Latin (Medieval), Malayalam, Marathi, N'ko,
Occitan, Odia, Punjabi, Russian (Petrine orthography), Sanskrit, Syriac,
Tamil, Telugu, Tibetan, Urdu, and Uyghur
This commit is contained in:
Juergen Spitzmueller 2024-08-25 13:22:07 +02:00
parent d06a034578
commit b625138be6
6 changed files with 363 additions and 174 deletions

View File

@ -7,6 +7,17 @@ changes happened in particular if possible. A good example would be
----------------------- -----------------------
2024-08-25 Jürgen Spitzmüller <spitz@lyx.org>
* Format incremented to 630: Add support for a number of languages in
babel and polyglossia:
Polyglossia: Chinese (Simplified), Chinese (Traditional), Japanese, Kurdish (Sorani),
Latin (Classic), Latin (Ecclesiastic), Latin (Medieval), N'ko, Odia, Punjabi, and Uyghur
Babel: Amharic, Armenian, Asturian, Bengali, Church Slavonic, Coptic, Divehi,
Kannada, Kazakh, Khmer, Kurdish (Sorani), Lao, Latin (Classic), Latin (Ecclesiastic),
Latin (Medieval), Malayalam, Marathi, N'ko, Occitan, Odia, Punjabi,
Russian (Petrine orthography), Sanskrit, Syriac, Tamil, Telugu, Tibetan, Urdu,
and Uyghur
2024-08-23 Jürgen Spitzmüller <spitz@lyx.org> 2024-08-23 Jürgen Spitzmüller <spitz@lyx.org>
* Format incremented to 629: Add support for language options * Format incremented to 629: Add support for language options
New buffer params \language_options_babel and New buffer params \language_options_babel and

View File

@ -211,12 +211,10 @@ Language american
LangCode en_US LangCode en_US
End End
# not supported by babel
Language amharic Language amharic
GuiName "Amharic" GuiName "Amharic"
# TODO: BabelName amharic
# BabelName amharic BabelProvide 1
# BabelProvide 1
PolyglossiaName amharic PolyglossiaName amharic
Encoding utf8 Encoding utf8
DateFormats "dd MMMM yyyy|dd MMM yyyy|dd/MM/yyyy" DateFormats "dd MMMM yyyy|dd MMM yyyy|dd/MM/yyyy"
@ -289,12 +287,10 @@ Language arabic_arabi
LangCode ar_SA LangCode ar_SA
End End
# not supported by babel
Language armenian Language armenian
GuiName "Armenian" GuiName "Armenian"
# TODO: BabelName armenian
# BabelName armenian BabelProvide 1
# BabelProvide 1
PolyglossiaName armenian PolyglossiaName armenian
QuoteStyle swiss QuoteStyle swiss
Encoding utf8 Encoding utf8
@ -302,12 +298,10 @@ Language armenian
LangCode hy_AM LangCode hy_AM
End End
# not supported by babel
Language asturian Language asturian
GuiName "Asturian" GuiName "Asturian"
# TODO: BabelName asturian
# BabelName asturian BabelProvide 1
# BabelProvide 1
PolyglossiaName asturian PolyglossiaName asturian
QuoteStyle french QuoteStyle french
Encoding iso8859-15 Encoding iso8859-15
@ -434,9 +428,8 @@ End
# supported by polyglossia but not babel: # supported by polyglossia but not babel:
Language bengali Language bengali
GuiName "Bengali" GuiName "Bengali"
# TODO: BabelName bengali
# BabelName bengali BabelProvide 1
# BabelProvide 1
PolyglossiaName bengali PolyglossiaName bengali
QuoteStyle english QuoteStyle english
Encoding utf8 Encoding utf8
@ -554,9 +547,8 @@ End
Language chinese-simplified Language chinese-simplified
GuiName "Chinese (simplified)" GuiName "Chinese (simplified)"
HasGuiSupport true HasGuiSupport true
# TODO PolyglossiaName chinese
# PolyglossiaName chinese PolyglossiaOpts "variant=simplified"
# PolyglossiaOpts "variant=simplified"
Encoding euc-cn Encoding euc-cn
QuoteStyle english QuoteStyle english
WordWrap false WordWrap false
@ -569,9 +561,8 @@ End
Language chinese-traditional Language chinese-traditional
GuiName "Chinese (traditional)" GuiName "Chinese (traditional)"
HasGuiSupport true HasGuiSupport true
# TODO PolyglossiaName chinese
# PolyglossiaName chinese PolyglossiaOpts "variant=traditional"
# PolyglossiaOpts "variant=traditional"
QuoteStyle cjk QuoteStyle cjk
Encoding utf8-cjk Encoding utf8-cjk
WordWrap false WordWrap false
@ -580,12 +571,10 @@ Language chinese-traditional
Requires CJK Requires CJK
End End
# not supported by babel
Language churchslavonic Language churchslavonic
GuiName "Church Slavonic" GuiName "Church Slavonic"
# TODO: BabelName churchslavic
# BabelName churchslavic BabelProvide 1
# BabelProvide 1
PolyglossiaName churchslavonic PolyglossiaName churchslavonic
QuoteStyle swiss QuoteStyle swiss
Encoding utf8 Encoding utf8
@ -595,13 +584,11 @@ Language churchslavonic
Provides textcyrillic Provides textcyrillic
End End
# not supported by babel
# FIXME DateFormats # FIXME DateFormats
Language coptic Language coptic
GuiName "Coptic" GuiName "Coptic"
# TODO: BabelName coptic
# BabelName coptic BabelProvide 1
# BabelProvide 1
PolyglossiaName coptic PolyglossiaName coptic
Encoding utf8 Encoding utf8
LangCode cop_EG LangCode cop_EG
@ -650,9 +637,8 @@ End
# babel only provides a "bare minimum locale" # babel only provides a "bare minimum locale"
Language divehi Language divehi
GuiName "Divehi (Maldivian)" GuiName "Divehi (Maldivian)"
# TODO: BabelName divehi
# BabelName divehi BabelProvide 1
# BabelProvide 1
PolyglossiaName divehi PolyglossiaName divehi
Encoding utf8 Encoding utf8
DateFormats "yyyy MMMM dd|yyyy MMM dd|dd/MM/yyyy" DateFormats "yyyy MMMM dd|yyyy MMM dd|dd/MM/yyyy"
@ -917,30 +903,16 @@ Language hebrew
LangCode he_IL LangCode he_IL
End End
# not supported by babel
Language hindi Language hindi
GuiName "Hindi" GuiName "Hindi"
# TODO: BabelName hindi
# BabelName hindi BabelProvide 1
# BabelProvide 1
PolyglossiaName hindi PolyglossiaName hindi
Encoding utf8 Encoding utf8
DateFormats "dd MMMM yyyy|dd MMM yyyy|dd-MM-yyyy" DateFormats "dd MMMM yyyy|dd MMM yyyy|dd-MM-yyyy"
LangCode hi_IN LangCode hi_IN
End End
# Currently not supported (file format change!)
# "hungarian" is a synonym for the "magyar" babel language option
# "hungarian" might be used for special purposes,
# see http://www.math.bme.hu/latex/magyar_pre_tug2004.pdf
#Language hungarian
# GuiName "Hungarian"
# BabelName hungarian
# Encoding iso8859-2
# LangCode hu_HU
# QuoteStyle polish
#End
# FontEncoding: OT1 misses ð and Þ # FontEncoding: OT1 misses ð and Þ
Language icelandic Language icelandic
GuiName "Icelandic" GuiName "Icelandic"
@ -1001,8 +973,7 @@ Language japanese
HasGuiSupport true HasGuiSupport true
BabelName japanese BabelName japanese
BabelOptFormat \languageattribute{$lang$}{$opts$} BabelOptFormat \languageattribute{$lang$}{$opts$}
# TODO PolyglossiaName japanese
# PolyglossiaName japanese
Encoding jis-platex Encoding jis-platex
WordWrap false WordWrap false
LangCode ja_JP LangCode ja_JP
@ -1023,12 +994,10 @@ Language japanese-cjk
QuoteStyle cjk QuoteStyle cjk
End End
# not supported by babel
Language kannada Language kannada
GuiName "Kannada" GuiName "Kannada"
# TODO: BabelName kannada
# BabelName kannada BabelProvide 1
# BabelProvide 1
PolyglossiaName kannada PolyglossiaName kannada
Encoding utf8 Encoding utf8
DateFormats "dd MMMM yyyy|dd MMMM yyyy|dd-MM-yyyy" DateFormats "dd MMMM yyyy|dd MMMM yyyy|dd-MM-yyyy"
@ -1036,21 +1005,20 @@ Language kannada
End End
# not yet supported by polyglossia # not yet supported by polyglossia
# not supported by babel
Language kazakh Language kazakh
GuiName "Kazakh" GuiName "Kazakh"
BabelName kazakh
BabelProvide 1
Encoding ascii Encoding ascii
# FontEncoding T2A # not set (no Babel support) # FontEncoding T2A # not set (no Babel support)
DateFormats "dd MMMM yyyy|dd MMMM yyyy|yyyy-dd-MM" DateFormats "dd MMMM yyyy|dd MMMM yyyy|yyyy-dd-MM"
LangCode kk_KZ LangCode kk_KZ
End End
# not supported by babel
Language khmer Language khmer
GuiName "Khmer" GuiName "Khmer"
# TODO: BabelName khmer
# BabelName khmer BabelProvide 1
# BabelProvide 1
PolyglossiaName khmer PolyglossiaName khmer
Encoding utf8 Encoding utf8
DateFormats "d MMMM yyyy|d MMMM yyyy|dd/MM/yyyy" DateFormats "d MMMM yyyy|d MMMM yyyy|dd/MM/yyyy"
@ -1091,14 +1059,25 @@ Language kurmanji
LangCode kmr LangCode kmr
End End
# TODO: kurdish, variant=sorani
# not supported by babel Language sorani
GuiName "Kurdish (Sorani)"
BabelName sorani
BabelProvide 1
PolyglossiaName kurdish
PolyglossiaOpts "variant=sorani"
XindyName kurdish-bedirxan
Encoding utf8
FontEncoding T1|OT1
DateFormats "d. MMMM yyyy|d. M. yyyy|yyyy-MM-dd"
LangCode ckb
End
Language lao Language lao
GuiName "Lao" GuiName "Lao"
# TODO: BabelName lao
# BabelName lao BabelProvide 1
# BabelProvide 1
PolyglossiaName lao PolyglossiaName lao
Encoding utf8 Encoding utf8
DateFormats "dd MMMM yyyy|dd MMMM yyyy|dd/MM/yyyy" DateFormats "dd MMMM yyyy|dd MMMM yyyy|dd/MM/yyyy"
@ -1109,7 +1088,7 @@ End
# We therefore use the name of its hunspell dictionary. # We therefore use the name of its hunspell dictionary.
# FIXME DateFormats # FIXME DateFormats
Language latin Language latin
GuiName "Latin" GuiName "Latin (Modern)"
BabelName latin BabelName latin
BabelOptFormat modifier BabelOptFormat modifier
PolyglossiaName latin PolyglossiaName latin
@ -1118,10 +1097,48 @@ Language latin
ActiveChars ^= ActiveChars ^=
Encoding iso8859-15 Encoding iso8859-15
FontEncoding T1|OT1 FontEncoding T1|OT1
LangCode la_LA LangCode la
End
Language latin-classic
GuiName "Latin (Classic)"
BabelName classiclatin
BabelOptFormat modifier
PolyglossiaName latin
PolyglossiaOpts "variant=classic"
XindyName latin
ActiveChars ^=
Encoding iso8859-15
FontEncoding T1|OT1
LangCode la-x-classic
End
Language latin-ecclesiastic
GuiName "Latin (Eccesiastic)"
BabelName ecclesiasticlatin
BabelOptFormat modifier
PolyglossiaName latin
PolyglossiaOpts "variant=ecclesiastic"
XindyName latin
ActiveChars ^=
Encoding iso8859-15
FontEncoding T1|OT1
LangCode la-x-ecclesia
End
Language latin-medieval
GuiName "Latin (Medieval)"
BabelName medievallatin
BabelOptFormat modifier
PolyglossiaName latin
PolyglossiaOpts "variant=medieval"
XindyName latin
ActiveChars ^=
Encoding iso8859-15
FontEncoding T1|OT1
LangCode la-x-medieval
End End
# TODO: support Latin varieties (classic, medieval, eccelesiastic)
# latvian must be loaded locally with babel options, # latvian must be loaded locally with babel options,
# not globally via class options # not globally via class options
@ -1213,12 +1230,10 @@ Language macedonian
Provides textcyrillic Provides textcyrillic
End End
# not supported by babel
Language malayalam Language malayalam
GuiName "Malayalam" GuiName "Malayalam"
# TODO: BabelName malayalam
# BabelName malayalam BabelProvide 1
# BabelProvide 1
PolyglossiaName malayalam PolyglossiaName malayalam
Encoding utf8 Encoding utf8
QuoteStyle english QuoteStyle english
@ -1226,12 +1241,10 @@ Language malayalam
LangCode ml_IN LangCode ml_IN
End End
# not supported by babel
Language marathi Language marathi
GuiName "Marathi" GuiName "Marathi"
# TODO: BabelName marathi
# BabelName marathi BabelProvide 1
# BabelProvide 1
PolyglossiaName marathi PolyglossiaName marathi
Encoding utf8 Encoding utf8
DateFormats "dd MMMM yyyy|d MMM yyyy|dd-MM-yyyy" DateFormats "dd MMMM yyyy|d MMM yyyy|dd-MM-yyyy"
@ -1265,23 +1278,18 @@ Language newzealand
LangCode en_NZ LangCode en_NZ
End End
# TODO: Language nko
# Language nko GuiName "NKo"
# GuiName "NKo" BabelName nko
# BabelName nko BabelProvide 1
# BabelProvide 1 PolyglossiaName nko
# PolyglossiaName nko QuoteStyle swiss
# QuoteStyle swiss Encoding utf8
# Encoding utf8
# FIXME: DateFormats "d MMMM، yyyy|dd/MM/yyyy|d/M/yyyy" # FIXME: DateFormats "d MMMM، yyyy|dd/MM/yyyy|d/M/yyyy"
# gloss-nko.ldf says: # see gloss-nko.ldf
# In n'ko, this is an example of date : RTL true
# ߂߀߁߃ ߞߏ߲ߞߏߜߍ ߕߟߋ߬ ߁߈ (RTL) LangCode nqo
# ( 18 February 2013 ) End
# The word "ߕߟߋ߬" is mandatory between month name and day number.
# RTL true
# LangCode nqo
# End
Language norsk Language norsk
GuiName "Norwegian (Bokmaal)" GuiName "Norwegian (Bokmaal)"
@ -1311,11 +1319,9 @@ Language nynorsk
LangCode nn_NO LangCode nn_NO
End End
# not supported by babel
Language occitan Language occitan
GuiName "Occitan" GuiName "Occitan"
# TODO BabelName occitan
# BabelName occitan
PolyglossiaName occitan PolyglossiaName occitan
QuoteStyle french QuoteStyle french
Encoding utf8 Encoding utf8
@ -1323,20 +1329,29 @@ Language occitan
LangCode oc_FR LangCode oc_FR
End End
# TODO: odia (polyglossia) Language odia
GuiName "Odia"
BabelName odia
BabelProvide 1
PolyglossiaName odia
Encoding utf8
DateFormats "dd MMMM yyyy|d MMM yyyy|dd-MM-yyyy"
LangCode or
End
# Russian orthography from the Petrine orthographic reforms of # Russian orthography from the Petrine orthographic reforms of
# 1708 to the 1917 orthographic reform # 1708 to the 1917 orthographic reform
Language oldrussian Language oldrussian
GuiName "Russian (Petrine orthography)" GuiName "Russian (Petrine orthography)"
# TODO BabelName russian
# BabelName russian BabelOpts ancient
# BabelOpts ancient BabelOptFormat modifier
# BabelOptFormat modifier
PolyglossiaName russian PolyglossiaName russian
PolyglossiaOpts "spelling=old" PolyglossiaOpts "spelling=old"
XindyName russian XindyName russian
QuoteStyle russian QuoteStyle russian
Encoding koi8-r
FontEncoding T2A
LangCode ru_petr1708 LangCode ru_petr1708
End End
@ -1380,7 +1395,15 @@ Language portuguese
LangCode pt_PT LangCode pt_PT
End End
# TODO: punjabi (polyglossia) Language punjabi
GuiName "Punjabi"
BabelName punjabi
BabelProvide 1
PolyglossiaName punjabi
Encoding utf8
DateFormats "dd MMMM yyyy|dd MMMM yyyy|dd-MM-yyyy"
LangCode pa
End
Language romanian Language romanian
GuiName "Romanian" GuiName "Romanian"
@ -1434,13 +1457,11 @@ Language samin
LangCode se_NO LangCode se_NO
End End
# not supported by babel
Language sanskrit Language sanskrit
GuiName "Sanskrit" GuiName "Sanskrit"
PolyglossiaName sanskrit PolyglossiaName sanskrit
# TODO: BabelName sanskrit
# BabelName sanskrit BabelProvide 1
# BabelProvide 1
Encoding utf8 Encoding utf8
DateFormats "dd MMMM yyyy|d MMM yyyy|dd-MM-yyyy" DateFormats "dd MMMM yyyy|d MMM yyyy|dd-MM-yyyy"
LangCode sa_IN LangCode sa_IN
@ -1568,12 +1589,10 @@ Language swedish
LangCode sv_SE LangCode sv_SE
End End
# not supported by babel
Language syriac Language syriac
GuiName "Syriac" GuiName "Syriac"
# TODO: BabelName syriac
# BabelName syriac BabelProvide 1
# BabelProvide 1
PolyglossiaName syriac PolyglossiaName syriac
Encoding utf8 Encoding utf8
RTL true RTL true
@ -1581,24 +1600,20 @@ Language syriac
LangCode syr_SY LangCode syr_SY
End End
# not supported by babel
Language tamil Language tamil
GuiName "Tamil" GuiName "Tamil"
# TODO: BabelName tamil
# BabelName tamil BabelProvide 1
# BabelProvide 1
PolyglossiaName tamil PolyglossiaName tamil
Encoding utf8 Encoding utf8
DateFormats "dd MMMM yyyy|d MMM yyyy|dd-MM-yyyy" DateFormats "dd MMMM yyyy|d MMM yyyy|dd-MM-yyyy"
LangCode ta_IN LangCode ta_IN
End End
# not supported by babel
Language telugu Language telugu
GuiName "Telugu" GuiName "Telugu"
# TODO: BabelName telugu
# BabelName telugu BabelProvide 1
# BabelProvide 1
PolyglossiaName telugu PolyglossiaName telugu
Encoding utf8 Encoding utf8
DateFormats "dd MMMM yyyy|d MMM yyyy|dd-MM-yyyy" DateFormats "dd MMMM yyyy|d MMM yyyy|dd-MM-yyyy"
@ -1649,13 +1664,11 @@ Language thai
EndPostBabelPreamble EndPostBabelPreamble
End End
# not supported by babel
#FIXME DateFormats #FIXME DateFormats
Language tibetan Language tibetan
GuiName "Tibetan" GuiName "Tibetan"
# TODO: BabelName tibetan
# BabelName tibetan BabelProvide 1
# BabelProvide 1
PolyglossiaName tibetan PolyglossiaName tibetan
Encoding utf8 Encoding utf8
LangCode bo_CN LangCode bo_CN
@ -1715,12 +1728,10 @@ Language uppersorbian
LangCode hsb_DE LangCode hsb_DE
End End
# not supported by babel
Language urdu Language urdu
GuiName "Urdu" GuiName "Urdu"
# TODO: BabelName urdu
# BabelName urdu BabelProvide 1
# BabelProvide 1
PolyglossiaName urdu PolyglossiaName urdu
Encoding utf8 Encoding utf8
DateFormats "d MMMM, yyyy|d MMM yyyy|dd/MM/yyyy" DateFormats "d MMMM, yyyy|d MMM yyyy|dd/MM/yyyy"
@ -1728,7 +1739,18 @@ Language urdu
LangCode ur_PK LangCode ur_PK
End End
# TODO: uyghur (polyglossia) Language uyghur
GuiName "Uyghur"
BabelName uyghur
BabelProvide 1
PolyglossiaName uyghur
Encoding utf8
FontEncoding LAE,LFE
DateFormats "d MMMM yyyy-يىلى|d MMM yyyy-يىلى|yyyy/M/d"
RTL true
LangCode ug
QuoteStyle english
End
Language vietnamese Language vietnamese
GuiName "Vietnamese" GuiName "Vietnamese"

View File

@ -666,7 +666,7 @@ singlepar_insets = [
# print(singlepar_insets) # print(singlepar_insets)
def revert_language(document, lyxname, babelname="", polyglossianame=""): def revert_language(document, lyxname, babelname="", polyglossianame="", polyglossiaopts="", babelprovide=False):
"Revert native language support" "Revert native language support"
# Does the document use polyglossia? # Does the document use polyglossia?
@ -791,15 +791,18 @@ def revert_language(document, lyxname, babelname="", polyglossianame=""):
i -= 1 i -= 1
continue continue
if polyglossiaopts != "":
polyglossiaopts = "[" + polyglossiaopts + "]"
if singlepar: if singlepar:
if with_polyglossia: if with_polyglossia:
begin_cmd = "\\text%s{" % texname begin_cmd = "\\text%s%s{" % (texname, polyglossiaopts)
elif with_babel: elif with_babel:
begin_cmd = "\\foreignlanguage{%s}{" % texname begin_cmd = "\\foreignlanguage{%s}{" % texname
end_cmd = "}" end_cmd = "}"
else: else:
if with_polyglossia: if with_polyglossia:
begin_cmd = "\\begin{%s}" % texname begin_cmd = "\\begin%s{%s}" % (polyglossiaopts, texname)
end_cmd = "\\end{%s}" % texname end_cmd = "\\end{%s}" % texname
elif with_babel: elif with_babel:
begin_cmd = "\\begin{otherlanguage}{%s}" % texname begin_cmd = "\\begin{otherlanguage}{%s}" % texname
@ -822,6 +825,16 @@ def revert_language(document, lyxname, babelname="", polyglossianame=""):
if with_babel: if with_babel:
# add as global option # add as global option
insert_document_option(document, babelname) insert_document_option(document, babelname)
# babelprovide
if babelprovide:
babelprovide = "\\babelprovide[import"
if primary:
babelprovide += ", main"
babelprovide += "]{%s}" % babelname
add_to_preamble(
document,
["\\AddToHook{package/babel/after}{%s}" % babelprovide],
)
# Since user options are appended to the document options, # Since user options are appended to the document options,
# Babel will treat `babelname` as primary language. # Babel will treat `babelname` as primary language.
if not primary: if not primary:

View File

@ -23,19 +23,20 @@ import re
# convert_info_insets, get_ert, hex2ratio, insert_to_preamble, # convert_info_insets, get_ert, hex2ratio, insert_to_preamble,
# length_in_bp, lyx2verbatim, # length_in_bp, lyx2verbatim,
# revert_flex_inset, revert_flex_inset, revert_font_attrs, # revert_flex_inset, revert_flex_inset, revert_font_attrs,
# revert_language, str2bool # str2bool
from lyx2lyx_tools import ( from lyx2lyx_tools import (
add_to_preamble, add_to_preamble,
latex_length, latex_length,
lyx2latex, lyx2latex,
put_cmd_in_ert put_cmd_in_ert,
revert_language
) )
# Uncomment only what you need to import, please (parser_tools): # Uncomment only what you need to import, please (parser_tools):
# check_token, count_pars_in_inset, del_complete_lines, # check_token, count_pars_in_inset, del_complete_lines,
# del_value, find_complete_lines, find_end_of, # del_value, find_complete_lines, find_end_of,
# find_re, find_token_backwards, find_token_exact, # find_re, find_token_backwards, find_token_exact,
# find_tokens, get_bool_value, # find_tokens,
# get_containing_layout, get_option_value, # get_containing_layout, get_option_value,
# is_in_inset, set_bool_value # is_in_inset, set_bool_value
from parser_tools import ( from parser_tools import (
@ -46,6 +47,7 @@ from parser_tools import (
find_substring, find_substring,
find_token, find_token,
get_containing_inset, get_containing_inset,
get_bool_value,
get_quoted_value, get_quoted_value,
get_value get_value
) )
@ -872,6 +874,142 @@ def revert_langopts(document):
# remove header # remove header
del document.header[i] del document.header[i]
def revert_new_polyglossia_languages(document):
"""Emulate support for Simplified Chinese, Traditional Chinese, Japanese, Sorani Kurdish,
Classic, Ecclesiastic and Medieval Latin, N'ko, Odia, Punjabi, and Uyghur with polyglossia."""
# Does the document use polyglossia?
use_polyglossia = False
if get_bool_value(document.header, "\\use_non_tex_fonts"):
i = find_token(document.header, "\\language_package")
if i == -1:
document.warning("Malformed document! Missing \\language_package")
else:
pack = get_value(document.header, "\\language_package", i)
if pack in ("default", "auto"):
use_polyglossia = True
if not use_polyglossia:
return
# lyxname: (babelname, polyglossianame, polyglossiaopts)
new_languages = {
"chinese-simplified": ("", "chinese", "variant=simplified"),
"chinese-traditional": ("", "chinese", "variant=traditional"),
"japanese": ("", "japanese", ""),
"sorani": ("", "kurdish", "variant=sorani"),
"latin-classic": ("", "latin", "variant=classic"),
"latin-ecclesiastic": ("", "latin", "variant=ecclesiastic"),
"latin-medieval": ("", "latin", "variant=medieval"),
"nko": ("", "nko", ""),
"odia": ("", "odia", ""),
"punjabi": ("", "punjabi", ""),
"uyghur": ("", "uyghur", ""),
}
if document.language in new_languages:
used_languages = {document.language}
else:
used_languages = set()
i = 0
while True:
i = find_token(document.body, "\\lang", i + 1)
if i == -1:
break
val = get_value(document.body, "\\lang", i)
if val in new_languages:
used_languages.add(val)
for lang in used_languages:
revert_language(document, lang, *new_languages[lang])
def revert_new_babel_languages(document):
"""Emulate support for Amharic, Armenian, Asturian, Bengali, Church Slavonic,
Coptic, Divehi, Kannada, Kazakh, Khmer, Kurdish (Sorani), Lao, Latin (Classic),
Latin (Ecclesiastic), Latin (Medieval), Malayalam, Marathi, N'ko, Occitan, Odia,
Punjabi, Russian (Petrine orthography), Sanskrit, Syriac, Tamil, Telugu, Tibetan,
Urdu, and Uyghur with babel."""
# Does the document use polyglossia?
use_polyglossia = False
if get_bool_value(document.header, "\\use_non_tex_fonts"):
i = find_token(document.header, "\\language_package")
if i == -1:
document.warning("Malformed document! Missing \\language_package")
else:
pack = get_value(document.header, "\\language_package", i)
if pack in ("default", "auto"):
use_polyglossia = True
if use_polyglossia:
return
# lyxname: (babelname, polyglossianame, polyglossiaopts, babelprovide)
new_languages = {
"amharic": ("amharic", "", "", True),
"armenian": ("armenian", "", "", True),
"asturian": ("asturian", "", "", True),
"bengali": ("bengali", "", "", True),
"churchslavonic": ("churchslavic", "", "", True),
"coptic": ("coptic", "", "", True),
"divehi": ("divehi", "", "", True),
"hindi": ("hindi", "", "", True),
"kannada": ("kannada", "", "", True),
"kazakh": ("kazakh", "", "", True),
"khmer": ("khmer", "", "", True),
"lao": ("lao", "", "", True),
"latin-classic": ("classiclatin", "", "", False),
"latin-ecclesiastic": ("ecclesiasticlatin", "", "", False),
"latin-medieval": ("medievallatin", "", "", False),
"malayalam": ("malayalam", "", "", True),
"marathi": ("marathi", "", "", True),
"nko": ("nko", "", "", True),
"occitan": ("occitan", "", "", False),
"odia": ("odia", "", "", True),
"punjabi": ("punjabi", "", "", True),
"sanskrit": ("sanskrit", "", "", True),
"sorani": ("sorani", "", "", True),
"syriac": ("syriac", "", "", True),
"tamil": ("tamil", "", "", True),
"telugu": ("telugu", "", "", True),
"tibetan": ("tibetan", "", "", True),
"urdu": ("urdu", "", "", True),
"uyghur": ("uyghur", "", "", True),
}
if document.language in new_languages:
used_languages = {document.language}
else:
used_languages = set()
i = 0
while True:
i = find_token(document.body, "\\lang", i + 1)
if i == -1:
break
val = get_value(document.body, "\\lang", i)
if val in new_languages:
used_languages.add(val)
for lang in used_languages:
revert_language(document, lang, *new_languages[lang])
# revert oldrussian to russian
have_oldrussian = False
if document.language == "oldrussian":
document.language = "russian"
have_oldrussian = True
i = 0
while True:
i = find_token(document.body, "\\lang oldrussian", i + 1)
if i == -1:
break
have_oldrussian = True
document.body[i] = "\\lang russian"
if have_oldrussian:
add_to_preamble(document, ["\\AddToHook{package/babel/after}{\\languageattribute{russian}{ancient}}"])
## ##
# Conversion hub # Conversion hub
# #
@ -886,11 +1024,13 @@ convert = [
[626, []], [626, []],
[627, [convert_nomencl, convert_index_sc]], [627, [convert_nomencl, convert_index_sc]],
[628, []], [628, []],
[629, []] [629, []],
[630, []]
] ]
revert = [ revert = [
[629, [revert_new_polyglossia_languages, revert_new_babel_languages]],
[628, [revert_langopts]], [628, [revert_langopts]],
[627, [revert_nomentbl]], [627, [revert_nomentbl]],
[626, [revert_nomencl, revert_index_sc]], [626, [revert_nomencl, revert_index_sc]],

View File

@ -50,19 +50,21 @@ 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", "ancientgreek", "arabic", "arabtex", "australian", "austrian", "azerbaijani", "bahasa", "bahasai", "american", "amharic", "ancientgreek", "arabic", "arabtex", "armenian", "asturian",
"bahasam", "basque", "belarusian", "bosnian", "brazil", "brazilian", "breton", "british", "australian", "austrian", "azerbaijani", "bahasa", "bahasai", "bahasam", "basque",
"bulgarian", "canadian", "canadien", "catalan", "croatian", "czech", "danish", "belarusian", "bengali", "bosnian", "brazil", "brazilian", "breton", "british",
"dutch", "english", "esperanto", "estonian", "farsi", "finnish", "francais", "bulgarian", "canadian", "canadien", "catalan", "churchslavic", "classiclatin", "coptic",
"french", "frenchb", "frenchle", "frenchpro", "friulan", "galician", "german", "germanb", "croatian", "czech", "danish", "divehi", "dutch", "ecclesiasticlatin", "english", "esperanto",
"georgian", "greek", "hebrew", "hungarian", "icelandic", "indon", "indonesian", "estonian", "farsi", "finnish", "francais", "french", "frenchb", "frenchle", "frenchpro", "friulan",
"interlingua", "irish", "italian", "japanese", "kazakh", "kurmanji", "latin", "galician", "german", "germanb", "georgian", "greek", "hebrew", "hindi", "hungarian", "icelandic",
"latvian", "lithuanian", "lowersorbian", "lsorbian", "macedonian", "magyar", "malay", "meyalu", "indon", "indonesian", "interlingua", "irish", "italian", "japanese", "kannada", "kazakh", "khmer",
"mexican", "mongolian", "naustrian", "newzealand", "ngerman", "ngermanb", "norsk", "nswissgerman", "kurmanji", "lao", "latin", "latvian", "lithuanian", "lowersorbian", "lsorbian", "macedonian", "magyar",
"nynorsk", "piedmontese", "polutonikogreek", "polish", "portuges", "portuguese", "malay", "malayalam", "marathi", "medievallatin", "meyalu", "mexican", "mongolian", "naustrian", "newzealand",
"romanian", "romansh", "russian", "russianb", "samin", "scottish", "serbian", "serbian-latin", "ngerman", "ngermanb", "nko", "norsk", "nswissgerman", "nynorsk", "occitan", "odia", "piedmontese",
"slovak", "slovene", "spanish", "swedish", "swissgerman", "thai", "turkish", "turkmen", "polutonikogreek", "polish", "portuges", "portuguese", "romanian", "romansh", "russian", "russianb",
"ukraineb", "ukrainian", "uppersorbian", "UKenglish", "USenglish", "usorbian", "samin", "scottish", "serbian", "serbian-latin", "punjabi", "sanskrit", "slovak", "slovene", "sorani",
"spanish", "swedish", "swissgerman", "syriac", "tamil", "telugu", "thai", "tibetan", "turkish", "turkmen",
"ukraineb", "ukrainian", "uppersorbian", "UKenglish", "urdu", "USenglish", "usorbian", "uyghur",
"vietnam", "welsh", "vietnam", "welsh",
0}; 0};
@ -71,19 +73,21 @@ 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", "ancientgreek", "arabic_arabi", "arabic_arabtex", "australian", "austrian", "azerbaijani", "bahasa", "bahasa", "american", "amharic", "ancientgreek", "arabic_arabi", "arabic_arabtex", "armenian", "asturian",
"bahasam", "basque", "belarusian", "bosnian", "brazilian", "brazilian", "breton", "british", "australian", "austrian", "azerbaijani", "bahasa", "bahasa", "bahasam", "basque",
"bulgarian", "canadian", "canadien", "catalan", "croatian", "czech", "danish", "belarusian", "bengali", "bosnian", "brazilian", "brazilian", "breton", "british",
"dutch", "english", "esperanto", "estonian", "farsi", "finnish", "french", "bulgarian", "canadian", "canadien", "catalan", "churchslavonic", "latin-classic", "coptic",
"french", "french", "french", "french", "friulan", "galician", "german", "german", "croatian", "czech", "danish", "divehi", "dutch", "latin-ecclesiastic", "english", "esperanto",
"georgian", "greek", "hebrew", "magyar", "icelandic", "bahasa", "bahasa", "estonian", "farsi", "finnish", "french", "french", "french", "french", "french", "friulan",
"interlingua", "irish", "italian", "japanese", "kazakh", "kurmanji", "latin", "galician", "german", "german", "georgian", "greek", "hebrew", "hindi", "magyar", "icelandic",
"latvian", "lithuanian", "lowersorbian", "lowersorbian", "macedonian", "magyar", "bahasam", "bahasam", "bahasa", "bahasa", "interlingua", "irish", "italian", "japanese", "kannada", "kazakh", "khmer",
"spanish-mexico", "mongolian", "naustrian", "newzealand", "ngerman", "ngerman", "norsk", "german-ch", "kurmanji", "lao", "latin", "latvian", "lithuanian", "lowersorbian", "lowersorbian", "macedonian", "magyar",
"nynorsk", "piedmontese", "polutonikogreek", "polish", "portuguese", "portuguese", "bahasam", "malayalam", "marathi", "latin-medieval", "bahasam", "spanish-mexico", "mongolian", "naustrian", "newzealand",
"romanian", "romansh", "russian", "russian", "samin", "scottish", "serbian", "serbian-latin", "ngerman", "ngerman", "nko", "norsk", "german-ch", "nynorsk", "occitan", "odia", "piedmontese",
"slovak", "slovene", "spanish", "swedish", "german-ch-old", "thai", "turkish", "turkmen", "polutonikogreek", "polish", "portuguese", "portuguese", "romanian", "romansh", "russian", "russian",
"ukrainian", "ukrainian", "uppersorbian", "english", "english", "uppersorbian", "samin", "scottish", "serbian", "serbian-latin", "punjabi", "sanskrit", "slovak", "slovene", "sorani",
"spanish", "swedish", "german-ch-old", "syriac", "tamil", "telugu", "thai", "tibetan", "turkish", "turkmen",
"ukrainian", "ukrainian", "uppersorbian", "english", "urdu", "english", "uppersorbian", "uyghur",
"vietnamese", "welsh", "vietnamese", "welsh",
0}; 0};
@ -326,17 +330,16 @@ string process_keyval_opt(vector<string> & options, string const & name)
const char * const Preamble::polyglossia_languages[] = { const char * const Preamble::polyglossia_languages[] = {
"albanian", "american", "amharic", "ancient", "arabic", "armenian", "asturian", "australian", "albanian", "american", "amharic", "ancient", "arabic", "armenian", "asturian", "australian",
"bahasai", "bahasam", "basque", "bengali", "brazil", "brazilian", "breton", "british", "bulgarian", "bahasai", "bahasam", "basque", "bengali", "brazil", "brazilian", "breton", "british", "bulgarian",
"catalan", "churchslavonic", "coptic", "croatian", "czech", "danish", "divehi", "dutch", "catalan", "chinese", "chinese", "churchslavonic", "coptic", "croatian", "czech", "danish", "divehi", "dutch",
"english", "esperanto", "estonian", "farsi", "finnish", "french", "friulan", "english", "esperanto", "estonian", "farsi", "finnish", "french", "friulan",
"galician", "greek", "monotonic", "hebrew", "hindi", "galician", "greek", "monotonic", "hebrew", "hindi",
"icelandic", "interlingua", "irish", "italian", "kannada", "khmer", "korean", "icelandic", "interlingua", "irish", "italian", "japanese", "kannada", "khmer", "korean",
"lao", "latin", "latvian", "lithuanian", "lsorbian", "magyar", "malayalam", "marathi", "kurdish", "kurmanji", "lao", "latin", "latvian", "lithuanian", "lsorbian", "magyar", "malayalam", "marathi",
"austrian", "newzealand", "german", "norsk", "nynorsk", "occitan", "oldrussian", "austrian", "newzealand", "german", "nko", "norsk", "nynorsk", "occitan", "odia", "oldrussian",
"piedmontese", "polish", "polytonic", "portuges", "romanian", "romansh", "russian", "piedmontese", "polish", "polytonic", "portuguese", "punjabi", "romanian", "romansh", "russian",
"samin", "sanskrit", "scottish", "serbian", "slovak", "slovenian", "spanish", "swedish", "syriac", "samin", "sanskrit", "scottish", "serbian", "slovak", "slovenian", "spanish", "swedish", "syriac",
"tamil", "telugu", "thai", "tibetan", "turkish", "turkmen", "tamil", "telugu", "thai", "tibetan", "turkish", "turkmen",
"ukrainian", "urdu", "usorbian", "vietnamese", "welsh", 0}; "ukrainian", "urdu", "usorbian", "uyghur", "vietnamese", "welsh", 0};
// not yet supported by LyX: "korean", "nko"
/** /**
* the same as polyglossia_languages with .lyx names * the same as polyglossia_languages with .lyx names
@ -345,17 +348,17 @@ const char * const Preamble::polyglossia_languages[] = {
const char * const Preamble::coded_polyglossia_languages[] = { const char * const Preamble::coded_polyglossia_languages[] = {
"albanian", "american", "amharic", "ancientgreek", "arabic_arabi", "armenian", "asturian", "australian", "albanian", "american", "amharic", "ancientgreek", "arabic_arabi", "armenian", "asturian", "australian",
"bahasa", "bahasam", "basque", "bengali", "brazilian", "brazilian", "breton", "british", "bulgarian", "bahasa", "bahasam", "basque", "bengali", "brazilian", "brazilian", "breton", "british", "bulgarian",
"catalan", "churchslavonic", "coptic", "croatian", "czech", "danish", "divehi", "dutch", "catalan", "chinese-simplified", "chinese-traditional", "churchslavonic", "coptic", "croatian", "czech",
"danish", "divehi", "dutch",
"english", "esperanto", "estonian", "farsi", "finnish", "french", "friulan", "english", "esperanto", "estonian", "farsi", "finnish", "french", "friulan",
"galician", "greek", "greek", "hebrew", "hindi", "galician", "greek", "greek", "hebrew", "hindi",
"icelandic", "interlingua", "irish", "italian", "kannada", "khmer", "korean", "icelandic", "interlingua", "irish", "italian", "japanese", "kannada", "khmer", "korean",
"lao", "latin", "latvian", "lithuanian", "lowersorbian", "magyar", "malayalam", "marathi", "sorani", "kurmanji", "lao", "latin", "latvian", "lithuanian", "lowersorbian", "magyar", "malayalam", "marathi",
"naustrian","newzealand", "ngerman", "norsk", "nynorsk", "occitan", "oldrussian", "naustrian","newzealand", "ngerman", "nko", "norsk", "nynorsk", "occitan", "odia", "oldrussian",
"piedmontese", "polish", "polutonikogreek", "portuges", "romanian", "romansh", "russian", "piedmontese", "polish", "polutonikogreek", "portuges", "punjabi", "romanian", "romansh", "russian",
"samin", "sanskrit", "scottish", "serbian", "slovak", "slovene", "spanish", "swedish", "syriac", "samin", "sanskrit", "scottish", "serbian", "slovak", "slovene", "spanish", "swedish", "syriac",
"tamil", "telugu", "thai", "tibetan", "turkish", "turkmen", "tamil", "telugu", "thai", "tibetan", "turkish", "turkmen",
"ukrainian", "urdu", "uppersorbian", "vietnamese", "welsh", 0}; "ukrainian", "urdu", "uppersorbian", "uyghur", "vietnamese", "welsh", 0};
// not yet supported by LyX: "korean-polyglossia", "nko"
bool Preamble::usePolyglossia() const bool Preamble::usePolyglossia() const

View File

@ -32,8 +32,8 @@ extern char const * const lyx_version_info;
// Do not remove the comment below, so we get merge conflict in // Do not remove the comment below, so we get merge conflict in
// independent branches. Instead add your own. // independent branches. Instead add your own.
#define LYX_FORMAT_LYX 629 // spitz: language options #define LYX_FORMAT_LYX 630 // spitz: language updates
#define LYX_FORMAT_TEX2LYX 629 #define LYX_FORMAT_TEX2LYX 630
#if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX #if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
#ifndef _MSC_VER #ifndef _MSC_VER