Support for the Malayalam language

Patch by Joice Joseph
This commit is contained in:
Juergen Spitzmueller 2019-03-10 10:21:59 +01:00
parent c041439c51
commit ebd7a1a22a
5 changed files with 105 additions and 4 deletions

View 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> 2018-10-29 Guy Rutenberg <guyrutenberg@gmail.com>
* format incremeneted to 566: Fix direction of Hebrew parentheses in the LyX file. * format incremeneted to 566: Fix direction of Hebrew parentheses in the LyX file.

View File

@ -1001,6 +1001,16 @@ Language macedonian
Provides textcyrillic Provides textcyrillic
End 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 # not supported by babel
Language marathi Language marathi
GuiName "Marathi" GuiName "Marathi"

View File

@ -83,10 +83,15 @@ insert_document_option(document, option):
remove_document_option(document, option): remove_document_option(document, option):
Remove _option_ as a 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 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 from unicode_symbols import unicode_reps
# This will accept either a list of lines or a single line. # 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 False
return True 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", "", "",
""]

View 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 # is_in_inset, set_bool_value
# find_tokens, find_token_exact, check_token # 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 # revert_font_attrs, insert_to_preamble, latex_length
# get_ert, lyx2latex, lyx2verbatim, length_in_bp, convert_info_insets # get_ert, lyx2latex, lyx2verbatim, length_in_bp, convert_info_insets
# revert_flex_inset, hex2ratio, str2bool # 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"], "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"], "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."], "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"], "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"], "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"], "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"], "lowersorbian" : ["%H:%M:%S %Z", "%H:%M"],
"macedonian" : ["%H:%M:%S %Z", "%H:%M"], "macedonian" : ["%H:%M:%S %Z", "%H:%M"],
"magyar" : ["%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"], "marathi" : ["%I:%M:%S %p %Z", "%I:%M %p"],
"mongolian" : ["%H:%M:%S %Z", "%H:%M"], "mongolian" : ["%H:%M:%S %Z", "%H:%M"],
"naustrian" : ["%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) 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 # Conversion hub
# #
@ -1433,9 +1441,11 @@ convert = [
[564, []], [564, []],
[565, [convert_AdobeFonts]], # Handle adobe fonts in GUI [565, [convert_AdobeFonts]], # Handle adobe fonts in GUI
[566, [convert_hebrew_parentheses]], [566, [convert_hebrew_parentheses]],
[567, []],
] ]
revert = [ revert = [
[566, [revert_malayalam]],
[565, [revert_hebrew_parentheses]], [565, [revert_hebrew_parentheses]],
[564, [revert_AdobeFonts]], [564, [revert_AdobeFonts]],
[563, [revert_lformatinfo]], [563, [revert_lformatinfo]],

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 // Do not remove the comment below, so we get merge conflict in
// independent branches. Instead add your own. // independent branches. Instead add your own.
#define LYX_FORMAT_LYX 566 // guyru: Fix parentheses in Hebrew #define LYX_FORMAT_LYX 567 // Joice : Added support for malayalam.
#define LYX_FORMAT_TEX2LYX 566 #define LYX_FORMAT_TEX2LYX 567
#if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX #if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
#ifndef _MSC_VER #ifndef _MSC_VER