Kaydet (Commit) a108f4b1 authored tarafından László Németh's avatar László Németh

LibreLogo: fixes for the Slovenian and other localizations

Change-Id: I52f8526f91b93420e2da6ad69e86ddbf70ad01bd
üst 542ad7f1
2012-12-17 László Németh:
* handle possible translation problems (strip terminating bars)
* keep double compilation of the commands
* trace loading problems (with PYUNO_LOGLEVEL environmental variable)
2012-11-24 László Németh: 2012-11-24 László Németh:
* zero turtle width in hideturtle mode to draw at the left border of the page * zero turtle width in hideturtle mode to draw at the left border of the page
......
...@@ -50,6 +50,7 @@ __COLORS__ = ['BLACK', 0x000000], ['SILVER', 0xc0c0c0], ['GRAY', 0x808080], \ ...@@ -50,6 +50,7 @@ __COLORS__ = ['BLACK', 0x000000], ['SILVER', 0xc0c0c0], ['GRAY', 0x808080], \
['ORANGE', 0xffa500], ['GOLD', 0xffd700], ['VIOLET', 0x9400d3], \ ['ORANGE', 0xffa500], ['GOLD', 0xffd700], ['VIOLET', 0x9400d3], \
['SKYBLUE', 0x87ceeb], ['CHOCOLATE', 0xd2691e], ['BROWN', 0xa52a2a], \ ['SKYBLUE', 0x87ceeb], ['CHOCOLATE', 0xd2691e], ['BROWN', 0xa52a2a], \
['INVISIBLE', 0xff000000] ['INVISIBLE', 0xff000000]
__STRCONST__ = [i[0] for i in __COLORS__] + ['NONE', 'BEVEL', 'MITER', 'ROUNDED', 'SOLID', 'DASH', 'DOTTED', 'BOLD', 'ITALIC', 'UPRIGHT', 'NORMAL', "HOUR", "PT", "INCH", "MM", "CM"]
__SLEEP_SLICE_IN_MILLISECONDS__ = 500 __SLEEP_SLICE_IN_MILLISECONDS__ = 500
__PT_TO_TWIP__ = 20 __PT_TO_TWIP__ = 20
__MM_TO_PT__ = 1/(25.4/72) __MM_TO_PT__ = 1/(25.4/72)
...@@ -137,9 +138,10 @@ def __l12n__(lng): ...@@ -137,9 +138,10 @@ def __l12n__(lng):
return __lng__[lng] return __lng__[lng]
except: except:
try: try:
__lng__[lng] = dict([[i.decode("unicode-escape").split("=")[0].strip(), i.decode("unicode-escape").split("=")[1].strip()] for i in open(__lngpath__ + "LibreLogo_" + lng + ".properties", 'rb').readlines() if b"=" in i]) __lng__[lng] = dict([[i.decode("unicode-escape").split("=")[0].strip(), i.decode("unicode-escape").split("=")[1].strip().strip("|")] for i in open(__lngpath__ + "LibreLogo_" + lng + ".properties", 'rb').readlines() if b"=" in i])
return __lng__[lng] return __lng__[lng]
except: except Exception:
__trace__()
return None return None
# dot for dotted line (implemented as an array of dot-headed arrows, because PostScript dot isn't supported by Writer) # dot for dotted line (implemented as an array of dot-headed arrows, because PostScript dot isn't supported by Writer)
...@@ -220,7 +222,7 @@ def Input(s): ...@@ -220,7 +222,7 @@ def Input(s):
# dispose the dialog # dispose the dialog
controlContainer.dispose() controlContainer.dispose()
return inputtext return inputtext
except Exception as e: except Exception:
__trace__() __trace__()
def __string__(s, decimal = None): # convert decimal sign, localized BOOL and SET def __string__(s, decimal = None): # convert decimal sign, localized BOOL and SET
...@@ -337,8 +339,8 @@ def __translate__(arg = None): ...@@ -337,8 +339,8 @@ def __translate__(arg = None):
# decode strings # decode strings
quoted = u"(?ui)(?<=%s)(%%s)(?=%s)" % (__l12n__(_.lng)['LEFTSTRING'][0], __l12n__(_.lng)['RIGHTSTRING'][0]) quoted = u"(?ui)(?<=%s)(%%s)(?=%s)" % (__l12n__(_.lng)['LEFTSTRING'][0], __l12n__(_.lng)['RIGHTSTRING'][0])
text = re.sub(__DECODE_STRING_REGEX__, __decodestring2__, text) text = re.sub(__DECODE_STRING_REGEX__, __decodestring2__, text)
for i in __COLORS__ + (['NONE'], ['BEVEL'], ['MITER'], ['ROUNDED'], ['SOLID'], ['DASH'], ['DOTTED'], ['BOLD'], ['ITALIC'], ['UPRIGHT'], ['NORMAL']): for i in __STRCONST__:
text = re.sub(quoted % lang[i[0]], __l12n__(_.lng)[i[0]].split("|")[0].upper(), text) text = re.sub(quoted % lang[i], __l12n__(_.lng)[i].split("|")[0].upper(), text)
_.doc.getText().setString(text) _.doc.getText().setString(text)
# convert to paragraphs # convert to paragraphs
__dispatcher__(".uno:ExecuteSearch", (__getprop__("SearchItem.SearchString", r"\n"), __getprop__("SearchItem.ReplaceString", r"\n"), \ __dispatcher__(".uno:ExecuteSearch", (__getprop__("SearchItem.SearchString", r"\n"), __getprop__("SearchItem.ReplaceString", r"\n"), \
...@@ -986,7 +988,6 @@ def __color__(c): ...@@ -986,7 +988,6 @@ def __color__(c):
return c return c
if type(c) == unicode: if type(c) == unicode:
if c == u'any': if c == u'any':
# return __COLORS__[int(random.random() * 24)][1]
return int(random.random() * 2**31) # max. 50% transparency return int(random.random() * 2**31) # max. 50% transparency
if c[0:1] == '~': if c[0:1] == '~':
c = __componentcolor__(__colors__[_.lng][c[1:].lower()]) c = __componentcolor__(__colors__[_.lng][c[1:].lower()])
...@@ -1159,13 +1160,15 @@ def __loadlang__(lang, a): ...@@ -1159,13 +1160,15 @@ def __loadlang__(lang, a):
for i in __COLORS__: for i in __COLORS__:
for j in a[i[0]].split("|"): for j in a[i[0]].split("|"):
__colors__[lang][j] = i[1] __colors__[lang][j] = i[1]
for i in a:
if not i[0:3] in ["LIB", "ERR", "PT", "INC", "MM", "CM", "HOU", "DEG"] and not i in __STRCONST__: # uppercase native commands
a[i] = a[i].upper()
repcount = a['REPCOUNT'].split('|')[0] repcount = a['REPCOUNT'].split('|')[0]
loopi = itertools.count() loopi = itertools.count()
loop = lambda r: "%(i)s = 1\n%(orig)s%(j)s = %(i)s\n%(i)s += 1\n" % \ loop = lambda r: "%(i)s = 1\n%(orig)s%(j)s = %(i)s\n%(i)s += 1\n" % \
{ "i": repcount + str(next(loopi)), "j": repcount, "orig": re.sub( r"(?ui)(?<!:)\b%s\b" % repcount, repcount + str(next(loopi)-1), r.group(0)) } { "i": repcount + str(next(loopi)), "j": repcount, "orig": re.sub( r"(?ui)(?<!:)\b%s\b" % repcount, repcount + str(next(loopi)-1), r.group(0)) }
__comp__[lang] = [ __comp__[lang] = [
[r"(?i)(?<!:)(\b|(?=[-:]))(?:%s)\b" % "|".join([a[i].lower() for i in a if i[0:3] != "ERR"]), lambda s: s.group().upper()], # uppercase all native commands in the source code
[r"(?<!:)\b(?:%s) [[]" % a['GROUP'], "\n__groupstart__()\nfor __groupindex__ in range(2):\n[\nif __groupindex__ == 1:\n[\n__groupend__()\nbreak\n]\n"], [r"(?<!:)\b(?:%s) [[]" % a['GROUP'], "\n__groupstart__()\nfor __groupindex__ in range(2):\n[\nif __groupindex__ == 1:\n[\n__groupend__()\nbreak\n]\n"],
[r"(?<!:)\b(?:%s)\b" % a['GROUP'], "\n__removeshape__(__ACTUAL__)\n"], [r"(?<!:)\b(?:%s)\b" % a['GROUP'], "\n__removeshape__(__ACTUAL__)\n"],
[r"(\n| )][ \n]*\[(\n| )", "\n]\nelse:\n[\n"], # if/else block [r"(\n| )][ \n]*\[(\n| )", "\n]\nelse:\n[\n"], # if/else block
...@@ -1350,8 +1353,7 @@ def __compil__(s): ...@@ -1350,8 +1353,7 @@ def __compil__(s):
# compile native Logo # compile native Logo
for i in __comp__[_.lng]: for i in __comp__[_.lng]:
s = re.sub(u"(?iu)" + i[0], i[1], s) s = re.sub(u"(?u)" + i[0], i[1], s)
indent = 0 indent = 0
result = "" result = ""
func = re.compile("(?iu)(def (\w+))(\(.*\):)") func = re.compile("(?iu)(def (\w+))(\(.*\):)")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment