commit ebd7a1a22a758336c6fa56ee12b988e6c1cd0736
Author: Juergen Spitzmueller <[email protected]>
Date: Sun Mar 10 10:21:59 2019 +0100
Support for the Malayalam language
Patch by Joice Joseph
---
development/FORMAT | 3 ++
lib/languages | 10 +++++
lib/lyx2lyx/lyx2lyx_tools.py | 80 +++++++++++++++++++++++++++++++++++++++++-
lib/lyx2lyx/lyx_2_4.py | 12 ++++++-
src/version.h | 4 +-
5 files changed, 105 insertions(+), 4 deletions(-)
diff --git a/development/FORMAT b/development/FORMAT
index b87d395..a568b44 100644
--- a/development/FORMAT
+++ b/development/FORMAT
@@ -7,6 +7,9 @@ changes happened in particular if possible. A good example
would be
-----------------------
+2019-02-21 Joice Joseph <[email protected]>
+ * Format incremented to 567: Support for Malayalam:
+ \lang malayalam
2018-10-29 Guy Rutenberg <[email protected]>
* format incremeneted to 566: Fix direction of Hebrew parentheses in
the LyX file.
diff --git a/lib/languages b/lib/languages
index 4262584..f8fbfd5 100644
--- a/lib/languages
+++ b/lib/languages
@@ -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"
diff --git a/lib/lyx2lyx/lyx2lyx_tools.py b/lib/lyx2lyx/lyx2lyx_tools.py
index f8d30cd..099f62f 100644
--- a/lib/lyx2lyx/lyx2lyx_tools.py
+++ b/lib/lyx2lyx/lyx2lyx_tools.py
@@ -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", "",
"",
+ ""]
+
diff --git a/lib/lyx2lyx/lyx_2_4.py b/lib/lyx2lyx/lyx_2_4.py
index 6c0b1c7..cf68d70 100644
--- a/lib/lyx2lyx/lyx_2_4.py
+++ b/lib/lyx2lyx/lyx_2_4.py
@@ -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]],
diff --git a/src/version.h b/src/version.h
index 09d0ddc..885b13f 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 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