summaryrefslogtreecommitdiff
path: root/l10ntools/scripts
diff options
context:
space:
mode:
authorZolnai Tamás <zolnaitamas2000@gmail.com>2012-08-29 09:54:30 +0200
committerAndras Timar <atimar@suse.com>2012-08-29 08:09:45 +0000
commit305ecb308a9b6f54263fd526cfdda9167fcaab56 (patch)
treec7ef04ff54882c2472302450aa01ec22b8dd0e48 /l10ntools/scripts
parent0319a1c8d1df4a86b847f5d6178966a29e7c24cb (diff)
Make renew working well
Change po2lo output: write out the untranslated sdf line too, write out translated sdf line only if there is translation to the komponent, write out fuzzy entries and indicate which entries are fuzzy. Change GenPoEntry to write out fuzzy flag Change renewpo to write out all type of entries not just text and to remove id duplicates which are made by xrmex Change-Id: Idc9b6062638d1d5fcbbae75e0396996b63e9a7a0 Reviewed-on: https://gerrit.libreoffice.org/508 Reviewed-by: Andras Timar <atimar@suse.com> Tested-by: Andras Timar <atimar@suse.com>
Diffstat (limited to 'l10ntools/scripts')
-rwxr-xr-xl10ntools/scripts/po2lo29
1 files changed, 19 insertions, 10 deletions
diff --git a/l10ntools/scripts/po2lo b/l10ntools/scripts/po2lo
index cdf8892fc950..579699102710 100755
--- a/l10ntools/scripts/po2lo
+++ b/l10ntools/scripts/po2lo
@@ -41,6 +41,7 @@ class Entry:
"""Represents a single line in an SDF file."""
def __init__(self, items):
+ self.has_translation = None;
self.items = items # list of 15 fields
path = self.items[1].split('\\')
self.po = "%s/%s/%s.po" % (options.input.replace('\\', '/'), self.items[0], "/".join(path[:-1]))
@@ -65,13 +66,20 @@ class Entry:
"""Translates text in the entry based on translations."""
self.items[9] = options.language
+ self.items[2] = ""
+ self.has_translation = False
for idx, key in self.keys:
try:
- self.items[idx] = translations.data[(self.po, key)]
+ if translations.data[(self.po, key)][1]:
+ self.items[2] += "1"
+ else:
+ self.items[2] += "0"
+ self.items[idx] = translations.data[(self.po, key)][0]
+ self.has_translation = True
self.items[14] = "2002-02-02 02:02:02"
except KeyError:
- pass
+ self.items[idx]=""
self.items[14] = self.items[14].strip()
def sdf2po(self, s):
@@ -95,8 +103,10 @@ class Template:
sock = xopen(options.output, "w", encoding='utf-8')
for line in self.lines:
+ sock.write("\t".join(line.items))
line.translate(translations)
- sock.write("\t".join(line.items)+"\r\n")
+ if line.has_translation:
+ sock.write("\t".join(line.items)+"\r\n")
sock.close()
class Translations:
@@ -120,10 +130,10 @@ class Translations:
elif line.startswith("msgstr "):
trans = line.strip()[8:-1]
if len(trans):
+ self.setdata(path, key, trans, fuzzy)
if fuzzy:
fuzzy = False
else:
- self.setdata(path, key, trans)
multiline = False
else:
buf = []
@@ -132,16 +142,15 @@ class Translations:
elif multiline and line.startswith('"'):
buf.append(line.strip()[1:-1])
elif multiline and not len(line.strip()) and len("".join(buf)):
+ self.setdata(path, key, "".join(buf),fuzzy)
if fuzzy:
fuzzy = False
- else:
- self.setdata(path, key, "".join(buf))
buf = []
multiline = False
- if multiline and len("".join(buf)) and not fuzzy:
- self.setdata(path, key, "".join(buf))
+ if multiline and len("".join(buf)):
+ self.setdata(path, key, "".join(buf),fuzzy)
- def setdata(self, path, key, s):
+ def setdata(self, path, key, s, fuzzy = False):
"""Sets the translation for a given path and key, handling (un)escaping
as well."""
if key:
@@ -151,7 +160,7 @@ class Translations:
s = self.escape_help_text(s)
else:
s = s.replace('\\\\', '\\')
- self.data[(path.replace('\\', '/'), key)] = s
+ self.data[(path.replace('\\', '/'), key)] = ( s , fuzzy )
def escape_help_text(self, text):
"""Escapes the help text as it would be in an SDF file."""