support for Amharic, Asturian, Kannada and Khmer

- fileformat change
- I could not update the tex2lyx test files because of bug #10440
- maybe the lyx2lyx routine could be improved but since a document can also begin with another layout than "Standard" I could not use the lyx2lyx function put_cmd_in_ert
This commit is contained in:
Uwe Stöhr 2016-10-22 15:33:59 +02:00
parent 9235b09fd8
commit d9c52c7a3f
5 changed files with 141 additions and 14 deletions

View File

@ -11,6 +11,13 @@ adjustments are made to tex2lyx and bugs are fixed in lyx2lyx.
-----------------------
2016-10-21 Uwe Stöhr <uwestoehr@web.de>
* Format incremented to 514: support for Amharic etc.:
\lang amharic
\lang asturian
\lang kannada
\lang khmer
2016-10-16 Uwe Stöhr <uwestoehr@web.de>
* Format incremented to 513: support for Piedmontese etc.:
\lang bosnian

View File

@ -129,6 +129,14 @@ Language american
LangCode en_US
End
# not supported by babel
Language amharic
GuiName "Amharic"
PolyglossiaName amharic
Encoding utf8
LangCode am_ET
End
# In Babel, this is supported since v. 1.8a of babel-greek (2013-12-03)
# We introduce it with LyX 2.2 to give the support time to settle.
Language ancientgreek
@ -180,6 +188,15 @@ Language armenian
LangCode hy_AM
End
# not supported by babel
Language asturian
GuiName "Asturian"
PolyglossiaName asturian
QuoteStyle french
Encoding iso8859-15
LangCode ast_ES
End
Language australian
GuiName "English (Australia)"
BabelName australian
@ -695,6 +712,14 @@ Language japanese-cjk
Requires CJK
End
# not supported by babel
Language kannada
GuiName "Kannada"
PolyglossiaName kannada
Encoding utf8
LangCode kn_IN
End
# not yet supported by polyglossia
# not supported by babel
Language kazakh
@ -707,6 +732,14 @@ Language kazakh
EndPostBabelPreamble
End
# not supported by babel
Language khmer
GuiName "Khmer"
PolyglossiaName khmer
Encoding utf8
LangCode km_KH
End
Language korean
GuiName "Korean"
Encoding euc-kr

View File

@ -33,7 +33,8 @@ from parser_tools import find_end_of#, find_token, find_tokens, \
from parser_tools import find_token, find_end_of_inset, get_value, \
get_bool_value
#from lyx2lyx_tools import add_to_preamble, put_cmd_in_ert, get_ert, lyx2latex, \
from lyx2lyx_tools import add_to_preamble, put_cmd_in_ert
# get_ert, lyx2latex, \
# lyx2verbatim, length_in_bp, convert_info_insets
# insert_to_preamble, latex_length, revert_flex_inset, \
# revert_font_attrs, hex2ratio, str2bool
@ -356,6 +357,90 @@ def revert_romansh(document):
document.header.insert(l + 1, "\\options romansh")
def revert_amharic(document):
"Set the document language to English but assure Amharic output"
if document.language == "amharic":
document.language = "english"
i = find_token(document.header, "\\language amharic", 0)
if i != -1:
document.header[i] = "\\language english"
j = find_token(document.header, "\\language_package default", 0)
if j != -1:
document.header[j] = "\\language_package default"
add_to_preamble(document, ["\\AtBeginDocument{\setotherlanguage{amharic}}"])
document.body[2 : 2] = ["\\begin_layout Standard",
"\\begin_inset ERT", "status open", "",
"\\begin_layout Plain Layout", "", "",
"\\backslash",
"resetdefaultlanguage{amharic}",
"\\end_layout", "", "\\end_inset", "", "",
"\\end_layout", ""]
def revert_asturian(document):
"Set the document language to English but assure Asturian output"
if document.language == "asturian":
document.language = "english"
i = find_token(document.header, "\\language asturian", 0)
if i != -1:
document.header[i] = "\\language english"
j = find_token(document.header, "\\language_package default", 0)
if j != -1:
document.header[j] = "\\language_package default"
add_to_preamble(document, ["\\AtBeginDocument{\setotherlanguage{asturian}}"])
document.body[2 : 2] = ["\\begin_layout Standard",
"\\begin_inset ERT", "status open", "",
"\\begin_layout Plain Layout", "", "",
"\\backslash",
"resetdefaultlanguage{asturian}",
"\\end_layout", "", "\\end_inset", "", "",
"\\end_layout", ""]
def revert_kannada(document):
"Set the document language to English but assure Kannada output"
if document.language == "kannada":
document.language = "english"
i = find_token(document.header, "\\language kannada", 0)
if i != -1:
document.header[i] = "\\language english"
j = find_token(document.header, "\\language_package default", 0)
if j != -1:
document.header[j] = "\\language_package default"
add_to_preamble(document, ["\\AtBeginDocument{\setotherlanguage{kannada}}"])
document.body[2 : 2] = ["\\begin_layout Standard",
"\\begin_inset ERT", "status open", "",
"\\begin_layout Plain Layout", "", "",
"\\backslash",
"resetdefaultlanguage{kannada}",
"\\end_layout", "", "\\end_inset", "", "",
"\\end_layout", ""]
def revert_khmer(document):
"Set the document language to English but assure Khmer output"
if document.language == "khmer":
document.language = "english"
i = find_token(document.header, "\\language khmer", 0)
if i != -1:
document.header[i] = "\\language english"
j = find_token(document.header, "\\language_package default", 0)
if j != -1:
document.header[j] = "\\language_package default"
add_to_preamble(document, ["\\AtBeginDocument{\setotherlanguage{khmer}}"])
document.body[2 : 2] = ["\\begin_layout Standard",
"\\begin_inset ERT", "status open", "",
"\\begin_layout Plain Layout", "", "",
"\\backslash",
"resetdefaultlanguage{khmer}",
"\\end_layout", "", "\\end_inset", "", "",
"\\end_layout", ""]
##
# Conversion hub
#
@ -366,10 +451,12 @@ convert = [
[510, [convert_dateinset]],
[511, [convert_ibranches]],
[512, [convert_beamer_article_styles]],
[513, []]
[513, []],
[514, []]
]
revert = [
[513, [revert_amharic, revert_asturian, revert_kannada, revert_khmer]],
[512, [revert_bosnian, revert_friulan, revert_macedonian, revert_piedmontese, revert_romansh]],
[511, [revert_beamer_article_styles]],
[510, [revert_ibranches]],

View File

@ -99,10 +99,10 @@ const char * const known_english_quotes_languages[] = {"american", "australian",
/// languages with french quotes (.lyx names)
const char * const known_french_quotes_languages[] = {"albanian",
"arabic_arabi", "arabic_arabtex", "basque", "canadien", "catalan", "french", "friulan",
"galician", "greek", "italian", "norsk", "nynorsk", "piedmontese", "polutonikogreek",
"russian", "spanish", "spanish-mexico", "turkish", "turkmen", "ukrainian",
"vietnamese", 0};
"arabic_arabi", "arabic_arabtex", "asturian", "basque", "canadien", "catalan",
"french", "friulan", "galician", "greek", "italian", "norsk", "nynorsk",
"piedmontese", "polutonikogreek", "russian", "spanish", "spanish-mexico",
"turkish", "turkmen", "ukrainian", "vietnamese", 0};
/// languages with german quotes (.lyx names)
const char * const known_german_quotes_languages[] = {"austrian", "bulgarian",
@ -297,38 +297,38 @@ string process_keyval_opt(vector<string> & options, string name)
* FIXME: support spelling=old for german variants (german vs. ngerman LyX names etc)
*/
const char * const Preamble::polyglossia_languages[] = {
"albanian", "american", "ancient", "arabic", "armenian", "australian",
"albanian", "american", "amharic", "ancient", "arabic", "armenian", "asturian", "australian",
"bahasai", "bahasam", "basque", "bengali", "brazil", "brazilian", "breton", "british", "bulgarian",
"catalan", "coptic", "croatian", "czech", "danish", "divehi", "dutch",
"english", "esperanto", "estonian", "farsi", "finnish", "french", "friulan",
"galician", "greek", "monotonic", "hebrew", "hindi",
"icelandic", "interlingua", "irish", "italian",
"icelandic", "interlingua", "irish", "italian", "kannada", "khmer",
"lao", "latin", "latvian", "lithuanian", "lsorbian", "magyar", "malayalam", "marathi",
"austrian", "newzealand", "german", "norsk", "nynorsk", "occitan",
"piedmontese", "polish", "polytonic", "portuges", "romanian", "romansh", "russian",
"samin", "sanskrit", "scottish", "serbian", "slovak", "slovenian", "spanish", "swedish",
"tamil", "telugu", "thai", "tibetan", "turkish", "turkmen",
"ukrainian", "usorbian", "vietnamese", "welsh", 0};
// not yet supported by LyX: "amharic", "asturian", "syriac", "urdu"
// not yet supported by LyX: "korean", "nko", "syriac", "urdu"
/**
* the same as polyglossia_languages with .lyx names
* please keep this in sync with polyglossia_languages line by line!
*/
const char * const Preamble::coded_polyglossia_languages[] = {
"albanian", "american", "ancientgreek", "arabic_arabi", "armenian", "australian",
"albanian", "american", "amharic", "ancientgreek", "arabic_arabi", "armenian", "asturian", "australian",
"bahasa", "bahasam", "basque", "bengali", "brazilian", "brazilian", "breton", "british", "bulgarian",
"catalan", "coptic", "croatian", "czech", "danish", "divehi", "dutch",
"english", "esperanto", "estonian", "farsi", "finnish", "french", "friulan",
"galician", "greek", "greek", "hebrew", "hindi",
"icelandic", "interlingua", "irish", "italian",
"icelandic", "interlingua", "irish", "italian", "kannada", "khmer",
"lao", "latin", "latvian", "lithuanian", "lowersorbian", "magyar", "malayalam", "marathi",
"naustrian","newzealand", "ngerman", "norsk", "nynorsk", "occitan",
"piedmontese", "polish", "polutonikogreek", "portuges", "romanian", "romansh", "russian",
"samin", "sanskrit", "scottish", "serbian", "slovak", "slovene", "spanish", "swedish",
"tamil", "telugu", "thai", "tibetan", "turkish", "turkmen",
"ukrainian", "uppersorbian", "vietnamese", "welsh", 0};
// not yet supported by LyX: "amharic", "asturian", "syriac", "urdu"
// not yet supported by LyX: "korean-polyglossia", "nko", "syriac", "urdu"
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
// independent branches. Instead add your own.
#define LYX_FORMAT_LYX 513 // uwestoehr: support for Bosnian, Friulan, Piedmontese, Romansh and Macedonian
#define LYX_FORMAT_TEX2LYX 513
#define LYX_FORMAT_LYX 514 // uwestoehr: support for Amharic etc.
#define LYX_FORMAT_TEX2LYX 514
#if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
#ifndef _MSC_VER