From d9c52c7a3f06ec892cd2e36d0d20998bc99b2fd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Uwe=20St=C3=B6hr?= Date: Sat, 22 Oct 2016 15:33:59 +0200 Subject: [PATCH] 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 --- development/FORMAT | 7 ++++ lib/languages | 33 +++++++++++++++ lib/lyx2lyx/lyx_2_3.py | 91 +++++++++++++++++++++++++++++++++++++++- src/tex2lyx/Preamble.cpp | 20 ++++----- src/version.h | 4 +- 5 files changed, 141 insertions(+), 14 deletions(-) diff --git a/development/FORMAT b/development/FORMAT index 6f8bb598d9..86bc183af5 100644 --- a/development/FORMAT +++ b/development/FORMAT @@ -11,6 +11,13 @@ adjustments are made to tex2lyx and bugs are fixed in lyx2lyx. ----------------------- +2016-10-21 Uwe Stöhr + * Format incremented to 514: support for Amharic etc.: + \lang amharic + \lang asturian + \lang kannada + \lang khmer + 2016-10-16 Uwe Stöhr * Format incremented to 513: support for Piedmontese etc.: \lang bosnian diff --git a/lib/languages b/lib/languages index 08cf3314f0..f126e694c2 100644 --- a/lib/languages +++ b/lib/languages @@ -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 diff --git a/lib/lyx2lyx/lyx_2_3.py b/lib/lyx2lyx/lyx_2_3.py index 93bf0f6495..3a1b292cc2 100644 --- a/lib/lyx2lyx/lyx_2_3.py +++ b/lib/lyx2lyx/lyx_2_3.py @@ -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]], diff --git a/src/tex2lyx/Preamble.cpp b/src/tex2lyx/Preamble.cpp index 9d9d55c970..99052eb978 100644 --- a/src/tex2lyx/Preamble.cpp +++ b/src/tex2lyx/Preamble.cpp @@ -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 & 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 diff --git a/src/version.h b/src/version.h index a3b7ef12cf..69de0ab798 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 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