mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-25 19:07:45 +00:00
use revert_language in more cases
This commit is contained in:
parent
6d6eda3950
commit
4bd065f871
@ -30,7 +30,7 @@ from parser_tools import del_complete_lines, \
|
||||
|
||||
from lyx2lyx_tools import add_to_preamble, insert_to_preamble, \
|
||||
put_cmd_in_ert, lyx2latex, latex_length, revert_flex_inset, \
|
||||
revert_font_attrs, hex2ratio, str2bool
|
||||
revert_font_attrs, hex2ratio, str2bool, revert_language
|
||||
|
||||
####################################################################
|
||||
# Private helper functions
|
||||
@ -1281,19 +1281,7 @@ def revert_notefontcolor(document):
|
||||
def revert_turkmen(document):
|
||||
"Set language Turkmen to English"
|
||||
|
||||
if document.language == "turkmen":
|
||||
document.language = "english"
|
||||
i = find_token(document.header, "\\language", 0)
|
||||
if i != -1:
|
||||
document.header[i] = "\\language english"
|
||||
|
||||
j = 0
|
||||
while True:
|
||||
j = find_token(document.body, "\\lang turkmen", j)
|
||||
if j == -1:
|
||||
return
|
||||
document.body[j] = document.body[j].replace("\\lang turkmen", "\\lang english")
|
||||
j += 1
|
||||
revert_language(document, "turkmen", "turkmen", "turkmen")
|
||||
|
||||
|
||||
def revert_fontcolor(document):
|
||||
|
@ -34,7 +34,7 @@ from parser_tools import count_pars_in_inset, del_complete_lines, del_token, \
|
||||
#find_end_of_inset, find_end_of_layout, \
|
||||
#is_in_inset, del_token, check_token
|
||||
|
||||
from lyx2lyx_tools import add_to_preamble, put_cmd_in_ert, get_ert
|
||||
from lyx2lyx_tools import add_to_preamble, put_cmd_in_ert, get_ert, revert_language
|
||||
|
||||
#from lyx2lyx_tools import insert_to_preamble, \
|
||||
# lyx2latex, latex_length, revert_flex_inset, \
|
||||
@ -1169,24 +1169,16 @@ def revert_ancientgreek(document):
|
||||
def revert_languages(document):
|
||||
"Set the document language for new supported languages to English"
|
||||
|
||||
languages = [
|
||||
"coptic", "divehi", "hindi", "kurmanji", "lao", "marathi", "occitan", "sanskrit",
|
||||
"syriac", "tamil", "telugu", "urdu"
|
||||
]
|
||||
for n in range(len(languages)):
|
||||
if document.language == languages[n]:
|
||||
document.language = "english"
|
||||
i = find_token(document.header, "\\language", 0)
|
||||
if i != -1:
|
||||
document.header[i] = "\\language english"
|
||||
j = 0
|
||||
while j < len(document.body):
|
||||
j = find_token(document.body, "\\lang " + languages[n], j)
|
||||
if j != -1:
|
||||
document.body[j] = document.body[j].replace("\\lang " + languages[n], "\\lang english")
|
||||
j += 1
|
||||
else:
|
||||
j = len(document.body)
|
||||
# polyglossia-only
|
||||
polyglossia_languages = ["coptic", "divehi", "hindi", "lao", "marathi",
|
||||
"occitan", "sanskrit", "syriac", "tamil",
|
||||
"telugu", "urdu"]
|
||||
# babel-only
|
||||
babel_languages = ["kurmanji"]
|
||||
for lang in polyglossia_languages:
|
||||
revert_language(document, lang, "", lang)
|
||||
for lang in babel_languages:
|
||||
revert_language(document, lang, lang, "")
|
||||
|
||||
|
||||
def convert_armenian(document):
|
||||
@ -4561,19 +4553,7 @@ def revert_aa2(document):
|
||||
def revert_tibetan(document):
|
||||
"Set the document language for Tibetan to English"
|
||||
|
||||
if document.language == "tibetan":
|
||||
document.language = "english"
|
||||
i = find_token(document.header, "\\language", 0)
|
||||
if i != -1:
|
||||
document.header[i] = "\\language english"
|
||||
j = 0
|
||||
while j < len(document.body):
|
||||
j = find_token(document.body, "\\lang tibetan", j)
|
||||
if j != -1:
|
||||
document.body[j] = document.body[j].replace("\\lang tibetan", "\\lang english")
|
||||
j += 1
|
||||
else:
|
||||
j = len(document.body)
|
||||
revert_language(document, "tibetan", "", "tibetan")
|
||||
|
||||
|
||||
#############
|
||||
|
@ -25,7 +25,8 @@ import sys, os
|
||||
# Uncomment only what you need to import, please.
|
||||
|
||||
from lyx2lyx_tools import (add_to_preamble, put_cmd_in_ert, get_ert,
|
||||
lyx2latex, lyx2verbatim, length_in_bp, convert_info_insets, insert_document_option)
|
||||
lyx2latex, lyx2verbatim, length_in_bp, convert_info_insets, insert_document_option,
|
||||
revert_language)
|
||||
|
||||
from parser_tools import (check_token, del_complete_lines,
|
||||
find_end_of_inset, find_end_of_layout, find_nonempty_line, find_re,
|
||||
@ -852,15 +853,7 @@ def revert_specialchar(document):
|
||||
def revert_georgian(document):
|
||||
"Set the document language to English but assure Georgian output"
|
||||
|
||||
if document.language == "georgian":
|
||||
document.language = "english"
|
||||
i = find_token(document.header, "\\language georgian", 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 babel"
|
||||
insert_document_option(document, "georgian")
|
||||
revert_language(document, "georgian", "georgian", "")
|
||||
|
||||
|
||||
def revert_sigplan_doi(document):
|
||||
|
Loading…
Reference in New Issue
Block a user