]> git.lyx.org Git - features.git/commitdiff
Support for the Malayalam language
authorJuergen Spitzmueller <spitz@lyx.org>
Sun, 10 Mar 2019 09:21:59 +0000 (10:21 +0100)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 18 Jun 2020 12:39:59 +0000 (14:39 +0200)
Patch by Joice Joseph

development/FORMAT
lib/languages
lib/lyx2lyx/lyx2lyx_tools.py
lib/lyx2lyx/lyx_2_4.py
src/version.h

index b87d395bc38f82daedf80335b2e9aa6de985a411..a568b44bc56fc445dea7883cc1ea1a4133752378 100644 (file)
@@ -7,6 +7,9 @@ changes happened in particular if possible. A good example would be
 
 -----------------------
 
+2019-02-21 Joice Joseph <josukutty@outlook.com>
+    * Format incremented to 567: Support for Malayalam:
+        \lang malayalam
 
 2018-10-29  Guy Rutenberg <guyrutenberg@gmail.com>
        * format incremeneted to 566: Fix direction of Hebrew parentheses in the LyX file.
index 42625846de7adf7c830a96af31c47d298c6d41ba..f8fbfd5ead15df19510a741694b1a5c077194966 100644 (file)
@@ -1001,6 +1001,16 @@ Language macedonian
        Provides         textcyrillic
 End
 
+# not yet supported by babel
+Language malayalam
+       GuiName          "Malayalam"
+       PolyglossiaName  malayalam
+       Encoding         utf8
+       QuoteStyle       english
+       DateFormats      "dd MMMM yyyy|d MMM yyyy|dd-MM-yyyy"
+       LangCode         ml_IN
+End
+
 # not supported by babel
 Language marathi
        GuiName          "Marathi"
index f8d30cd4706d74c27ff6ecc3d8b7c467981de0ca..099f62f29b22b0f99f1f922b3e709ce23c337ba5 100644 (file)
@@ -83,10 +83,15 @@ insert_document_option(document, option):
 
 remove_document_option(document, option):
   Remove _option_ as a document option.
+
+revert_language(document, lyxname, babelname, polyglossianame):
+  Reverts native language support to ERT
+  If babelname or polyglossianame is empty, it is assumed
+  this language package is not supported for the given language.
 '''
 
 import re
-from parser_tools import find_token, find_end_of_inset, get_containing_layout
+from parser_tools import find_token, find_end_of_inset, get_containing_layout, get_value, get_bool_value
 from unicode_symbols import unicode_reps
 
 # This will accept either a list of lines or a single line.
@@ -614,3 +619,76 @@ def is_document_option(document, option):
         return False
 
     return True
+
+
+def revert_language(document, lyxname, babelname, polyglossianame):
+    " Revert native language support "
+
+    # Are we using 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 == "default" or pack == "auto":
+                use_polyglossia = True
+
+    # Main language first
+    if document.language == lyxname:
+        document.language = "english"
+        i = find_token(document.header, "\\language %s" % lyxname, 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"
+        if use_polyglossia and polyglossianame != "":
+            add_to_preamble(document, ["\\AtBeginDocument{\setotherlanguage{%s}}" % polyglossianame])
+            document.body[2 : 2] = ["\\begin_layout Standard",
+                                    "\\begin_inset ERT", "status open", "",
+                                    "\\begin_layout Plain Layout", "", "",
+                                    "\\backslash",
+                                    "resetdefaultlanguage{%s}" % polyglossianame,
+                                    "\\end_layout", "", "\\end_inset", "", "",
+                                    "\\end_layout", ""]
+        elif babelname != "":
+            k = find_token(document.header, "\\options")
+            if k != -1:
+                document.header[k] = document.header[k].replace("\\options",
+                                    "\\options %s," % babelname)
+            else:
+                l = find_token(document.header, "\\use_default_options")
+                document.header.insert(l + 1, "\\options %s," % babelname)
+
+    # now inline switches
+    envname = babelname
+    if use_polyglossia:
+        envname = polyglossianame
+    i = 0
+    while True:
+        i = find_token(document.body, '\\lang', i)
+        if i == -1:
+            return
+        if document.body[i].startswith('\\lang %s' % lyxname):
+            if use_polyglossia and polyglossianame != "":
+                add_to_preamble(document, ["\\AtBeginDocument{\setotherlanguage{%s}}" % polyglossianame])
+            if (use_polyglossia and polyglossianame != "") or (use_polyglossia == False and babelname != ""):
+                parent = get_containing_layout(document.body, i)
+                document.body[parent[2] : parent[2]] = ["\\begin_layout Standard",
+                                        "\\begin_inset ERT", "status open", "",
+                                        "\\begin_layout Plain Layout", "", "",
+                                        "\\backslash",
+                                        "end{%s}" % envname,
+                                        "\\end_layout", "", "\\end_inset", "", "",
+                                        "\\end_layout", ""]
+            del document.body[i]
+            if (use_polyglossia and polyglossianame != "") or (use_polyglossia == False and babelname != ""):
+                document.body[i : i] = ["\\begin_inset ERT", "status open", "",
+                                        "\\begin_layout Plain Layout", "", "",
+                                        "\\backslash",
+                                        "begin{%s}" % envname,
+                                        "\\end_layout", "", "\\end_inset", "", "",
+                                        ""]
+
index 6c0b1c707f2993c6497dfb6423d305ab1e6f27ed..cf68d70a3470f8e0d645a8f37baa2465e2ec3d9f 100644 (file)
@@ -36,7 +36,7 @@ from parser_tools import (count_pars_in_inset, find_end_of_inset, find_end_of_la
 #    is_in_inset, set_bool_value
 #    find_tokens, find_token_exact, check_token
 
-from lyx2lyx_tools import (put_cmd_in_ert, add_to_preamble)
+from lyx2lyx_tools import (put_cmd_in_ert, add_to_preamble, revert_language)
 #  revert_font_attrs, insert_to_preamble, latex_length
 #  get_ert, lyx2latex, lyx2verbatim, length_in_bp, convert_info_insets
 #  revert_flex_inset, hex2ratio, str2bool
@@ -997,6 +997,7 @@ def revert_dateinfo(document):
         "lowersorbian" : ["%A, %d. %B %Y", "%d.%m.%y", "%d %B %Y", "%d %b %Y", "%d.%m.%Y"],
         "macedonian" : ["%A, %d %B %Y", "%d.%m.%y", "%d %B %Y", "%d %b %Y", "%d.%m.%Y"],
         "magyar" : ["%Y. %B %d., %A", "%Y. %m. %d.", "%Y. %B %d.", "%Y. %b %d.", "%Y.%m.%d."],
+        "malayalam" : ["%A, %d %B, %Y", "%d/%m/%y", "%d %B %Y", "%d %b %Y", "%d-%m-%Y"],
         "marathi" : ["%A, %d %B, %Y", "%d/%m/%y", "%d %B %Y", "%d %b %Y", "%d-%m-%Y"],
         "mongolian" : ["%A, %Y оны %m сарын %d", "%Y-%m-%d", "%Y оны %m сарын %d", "%d-%m-%Y", "%d-%m-%Y"],
         "naustrian" : ["%A, %d. %B %Y", "%d.%m.%y", "%d. %B %Y", "%d. %b %Y", "%d.%m.%Y"],
@@ -1179,6 +1180,7 @@ def revert_timeinfo(document):
         "lowersorbian" : ["%H:%M:%S %Z", "%H:%M"],
         "macedonian" : ["%H:%M:%S %Z", "%H:%M"],
         "magyar" : ["%H:%M:%S %Z", "%H:%M"],
+        "malayalam" : ["%p %I:%M:%S %Z", "%p %I:%M"],
         "marathi" : ["%I:%M:%S %p %Z", "%I:%M %p"],
         "mongolian" : ["%H:%M:%S %Z", "%H:%M"],
         "naustrian" : ["%H:%M:%S %Z", "%H:%M"],
@@ -1405,6 +1407,12 @@ def revert_hebrew_parentheses(document):
     convert_hebrew_parentheses(document)
 
 
+def revert_malayalam(document):
+    " Set the document language to English but assure Malayalam output "
+
+    revert_language(document, "malayalam", "", "malayalam")
+
+
 ##
 # Conversion hub
 #
@@ -1433,9 +1441,11 @@ convert = [
            [564, []],
            [565, [convert_AdobeFonts]], # Handle adobe fonts in GUI
            [566, [convert_hebrew_parentheses]],
+           [567, []],
           ]
 
 revert =  [
+           [566, [revert_malayalam]],
            [565, [revert_hebrew_parentheses]],
            [564, [revert_AdobeFonts]],
            [563, [revert_lformatinfo]],
index 09d0ddc487819c8d8bed754278d5f2686759e6cd..885b13fa403630f1edde0d5bbda7382b8615a541 100644 (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 566 // guyru: Fix parentheses in Hebrew
-#define LYX_FORMAT_TEX2LYX 566
+#define LYX_FORMAT_LYX 567 // Joice : Added support for malayalam.
+#define LYX_FORMAT_TEX2LYX 567
 
 #if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
 #ifndef _MSC_VER