[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: l10n-kde4/sr/internal/scripts
From: Chusslove Illich <caslav.ilic () gmx ! net>
Date: 2008-02-20 11:01:38
Message-ID: 1203505298.898464.26207.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 777285 by ilic:
Also try GUI reference with resolved default XML entities.
M +21 -10 summit_hooks.py
--- trunk/l10n-kde4/sr/internal/scripts/summit_hooks.py #777284:777285
@@ -1,10 +1,10 @@
# -*- coding: UTF-8 -*-
from pology.l10n.sr.translit import sr_c2l
-from pology.misc.resolve import resolve_entities
+from pology.misc.resolve import resolve_entities, resolve_entities_simple
from pology.misc.resolve import resolve_alternatives_simple
from pology.misc.escape import escape
-from pology.sieve.check_xml_kde4 import html_tags, kuit_tags
+from pology.sieve.check_xml_kde4 import html_tags, kuit_tags, default_entities
from pology.misc.fsops import collect_catalogs
from pology.misc.comments import autoc_parse_list
from pology.file.catalog import Catalog
@@ -508,12 +508,12 @@
# NOTE: Do not skip fuzzy/untranslated messages, so that the user
# may be informed when the reference exists but isn't translated.
- # Remove accelerators.
+ # Remove accelerators, strip l/t whitespace.
# FIXME: What about &? Can also be an accelerator, but unlikely.
- msg.msgid = remove_accel(msg.msgid)
- msg.msgid_plural = remove_accel(msg.msgid_plural)
+ msg.msgid = remove_accel(msg.msgid).strip()
+ msg.msgid_plural = remove_accel(msg.msgid_plural).strip()
for i in range(len(msg.msgstr)):
- msg.msgstr[i] = remove_accel(msg.msgstr[i])
+ msg.msgstr[i] = remove_accel(msg.msgstr[i]).strip()
# If the message as modified is not already present in
# the normalized catalog, append it.
@@ -532,7 +532,15 @@
for pretext, tag, attr, text in tsplit:
fulltext += pretext
if tag:
- rtext = resolve_gui_ref_single(cat, msg, text, gui_cats)
+ rtext, trans = resolve_gui_ref_single(cat, msg, text, gui_cats)
+ # If no translation found, and the original text may contain some
+ # default XML entities, retry with these resolved.
+ if not trans and "&" in text:
+ text2 = resolve_entities_simple(text, default_entities, ())
+ if text2 != text:
+ rtext, trans = \
+ resolve_gui_ref_single(cat, msg, text2, gui_cats)
+
if postfilter:
rtext = postfilter(rtext)
fulltext += "<%s%s>%s</%s>" % (tag, attr, rtext, tag)
@@ -554,7 +562,7 @@
"guimenuitem",
]
gui_tag_split_rx = re.compile( r"(.*?)(?:<\s*(" + "|".join(db_guitags)
- + r")\b(.*?)>(.*?)<\s*/\s*\2.*?>|$)",
+ + r")\b(.*?)>([^<]*?)<\s*/\s*\2.*?>|$)",
re.I|re.S|re.U)
def split_by_gui_tags (text):
@@ -583,7 +591,7 @@
# Return verbatim if requested (starts with two delimiters).
if text.startswith(delim + delim):
- return text[2*ldelim:]
+ return text[2*ldelim:], True
# Split into msgctxt and msgid.
has_msgctxt = False
@@ -620,8 +628,10 @@
# otherwise use original and report.
if rmsg.translated:
rtext = rmsg.msgstr[0]
+ trans = True
else:
rtext = msgid
+ trans = False
print "%s:%d(%d): GUI reference '%s' found in %s, " \
"but not translated" \
% (cat.filename, msg.refline, msg.refentry,
@@ -631,6 +641,7 @@
# report and use the original text.
else:
rtext = msgid
+ trans = False
print "%s:%d(%d): GUI reference '%s' cannot be resolved " \
"unambiguously, suggestions (if any) follow" \
% (cat.filename, msg.refline, msg.refentry, text)
@@ -657,7 +668,7 @@
if "&" in rtext:
rtext = amp_to_entity_rx.sub("&", rtext)
- return rtext
+ return rtext, trans
# ----------------------------------------
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic