LyX supports already many languages which are not supported by babel but polyglossia (Telugu, Tamil etc.). 2 such languages are however not yet supported by LyX. The attached patch changes this and adds support for Amharic and Asturian.
This is of course a fileformat change.

regards Uwe
 development/FORMAT       |  5 +++++
 lib/languages            | 18 ++++++++++++++++++
 lib/lyx2lyx/lyx_2_3.py   | 49 ++++++++++++++++++++++++++++++++++++++++++++++--
 src/tex2lyx/Preamble.cpp |  8 ++++----
 src/version.h            |  4 ++--
 5 files changed, 76 insertions(+), 8 deletions(-)

diff --git a/development/FORMAT b/development/FORMAT
index 6f8bb59..fa2f202 100644
--- a/development/FORMAT
+++ b/development/FORMAT
@@ -11,6 +11,11 @@ adjustments are made to tex2lyx and bugs are fixed in 
lyx2lyx.
 
 -----------------------
 
+2016-10-21 Uwe Stöhr <uwesto...@web.de>
+       * Format incremented to 514: support for Amharic and Asturian:
+         \lang amharic
+         \lang asturian
+
 2016-10-16 Uwe Stöhr <uwesto...@web.de>
        * Format incremented to 513: support for Piedmontese etc.:
          \lang bosnian
diff --git a/lib/languages b/lib/languages
index 08cf331..093d737 100644
--- a/lib/languages
+++ b/lib/languages
@@ -129,6 +129,15 @@ Language american
        LangCode         en_US
 End
 
+# not supported by babel
+Language amharic
+       GuiName          "Amharic"
+       PolyglossiaName  amharic
+       QuoteStyle       english
+       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 +189,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
diff --git a/lib/lyx2lyx/lyx_2_3.py b/lib/lyx2lyx/lyx_2_3.py
index 93bf0f6..2b24679 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,48 @@ 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", ""]
+
+
 ##
 # Conversion hub
 #
@@ -366,10 +409,12 @@ convert = [
            [510, [convert_dateinset]],
            [511, [convert_ibranches]],
            [512, [convert_beamer_article_styles]],
-           [513, []]
+           [513, []],
+           [514, []]
           ]
 
 revert =  [
+           [513, [revert_amharic, revert_asturian]],
            [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 9d9d55c..2710fc4 100644
--- a/src/tex2lyx/Preamble.cpp
+++ b/src/tex2lyx/Preamble.cpp
@@ -297,7 +297,7 @@ 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",
@@ -309,14 +309,14 @@ const char * const Preamble::polyglossia_languages[] = {
 "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: "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",
@@ -328,7 +328,7 @@ const char * const Preamble::coded_polyglossia_languages[] 
= {
 "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: "syriac", "urdu"
 
 
 bool Preamble::usePolyglossia() const
diff --git a/src/version.h b/src/version.h
index a3b7ef1..602fdef 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 and Asturian
+#define LYX_FORMAT_TEX2LYX 514
 
 #if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
 #ifndef _MSC_VER

Reply via email to