[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: l10n-support/pology
From: Chusslove Illich <caslav.ilic () gmx ! net>
Date: 2016-11-28 8:47:49
Message-ID: E1cBHbJ-0002sn-1c () code ! kde ! org
[Download RAW message or body]
SVN commit 1475903 by ilic:
Make placeholder masking in UI references more general
M +8 -2 doc/user/lingo.docbook
M +27 -24 pology/uiref.py
--- trunk/l10n-support/pology/doc/user/lingo.docbook #1475902:1475903
@@ -265,9 +265,15 @@
<programlisting language="po">
#, kde-format
msgid "You can change this behavior under \"Configure Foobar...\"."
-msgstr "Ovo ponašanje možete promeniti pod \"~%/Configure %1...^%1:Foobar/\"."
+msgstr "Ovo ponašanje možete promeniti pod „~%/Configure %1...^%1:Foobar/"."
</programlisting>
-is not valid because the <varname>msgstr</varname> now contains the \
<literal>kde-format</literal>-specific <literal>%1</literal> directive, but the \
<varname>msgid</varname> does not.</para> +is not valid because the \
<varname>msgstr</varname> now contains the <literal>kde-format</literal>-specific \
<literal>%1</literal> directive, but the <varname>msgid</varname> does not. To fix \
this, UI reference resolving hooks can be given an alternative directive start string \
such as to mask it from <command>msgfmt</command>. In this example: +<programlisting \
language="po"> +#, kde-format
+msgid "You can change this behavior under \"Configure Foobar...\"."
+msgstr "Ovo ponašanje možete promeniti pod „~%/Configure %~1...^%~1:Foobar/"."
+</programlisting>
+the alternative directive start is <literal>%~</literal>, which makes it no longer \
appear as a <literal>kde-format</literal>-specific directive. Of course, before the \
reference is looked up in an UI catalog, internally the normal form of the directive \
will be recovered.</para>
<para>In general, but especially with implicit references, the text wrapped as \
reference may actually contain several references in form of UI path (<literal>"...go \
to Foo->Bar->Baz, and click on..."</literal>). To handle such cases, if it is not \
possible or it is not convenient to wrap each element of the UI path separately, UI \
reference resolving hooks can be given one or more UI path separators (e.g. \
<literal>-></literal>) to split and resolve the element references on their \
own.</para>
--- trunk/l10n-support/pology/pology/uiref.py #1475902:1475903
@@ -41,7 +41,7 @@
def resolve_ui (headrefs=default_headrefs, tagrefs=[], uipathseps=[],
uicpaths=None, uicpathenv=None, xmlescape=False, pfhook=None,
- mkeyw=None, invmkeyw=False, quiet=False, fdirsplit=None):
+ mkeyw=None, invmkeyw=False, quiet=False, fdiralt={}):
"""
Resolve general UI references in translations [hook factory].
@@ -66,9 +66,10 @@
and the UI reference is found in a message of the same format
(e.g. a tooltip referencing another part of UI), then using the argument
substitution syntax may make the message invalid for the C{msgfmt -c}
- check. In that case, a splitter string specified by C{fdirsplit} parameter
- can be inserted somewhere between the first and the last character of
- the formatting directive, thus masking it from C{msgfmt -c}.
+ check. In that case, an alternative directive start string can be given,
+ which will mask it from C{msgfmt -c}. This is specified by C{fdiralt}
+ parameter, as a dictionary of alternative (key) and normal (value)
+ start strings.
@param headrefs: heads for explicit UI references
@type headrefs: list of strings
@@ -92,8 +93,9 @@
@type invmkeyw: bool
@param quiet: whether to output warnings of failed resolutions
@type quiet: bool
- @param fdirsplit: splitter string for masking formatting directives
- @type fdirsplit: string
+ @param fdiralt: alternative and normal start strings for masking
+ formatting directives
+ @type fdiralt: {string: string}
@return: type F3C hook
@rtype: C{(msgstr, msg, cat) -> msgstr}
@@ -100,13 +102,13 @@
"""
return _resolve_ui_w(headrefs, tagrefs, uipathseps, uicpaths, uicpathenv,
- xmlescape, pfhook, mkeyw, invmkeyw, quiet, fdirsplit,
+ xmlescape, pfhook, mkeyw, invmkeyw, quiet, fdiralt,
modtext=True, spanrep=False)
def check_ui (headrefs=default_headrefs, tagrefs=[], uipathseps=[],
uicpaths=None, uicpathenv=None, xmlescape=False,
- mkeyw=None, invmkeyw=False, fdirsplit=None):
+ mkeyw=None, invmkeyw=False, fdiralt={}):
"""
Check general UI references in translations [hook factory].
@@ -119,7 +121,7 @@
pfhook = None
quiet = True
return _resolve_ui_w(headrefs, tagrefs, uipathseps, uicpaths, uicpathenv,
- xmlescape, pfhook, mkeyw, invmkeyw, quiet, fdirsplit,
+ xmlescape, pfhook, mkeyw, invmkeyw, quiet, fdiralt,
modtext=False, spanrep=True)
@@ -145,9 +147,9 @@
uipathseps = []
xmlescape = True
invmkeyw = False
- fdirsplit = None
+ fdiralt = {}
return _resolve_ui_w(headrefs, tagrefs, uipathseps, uicpaths, uicpathenv,
- xmlescape, pfhook, mkeyw, invmkeyw, quiet, fdirsplit,
+ xmlescape, pfhook, mkeyw, invmkeyw, quiet, fdiralt,
modtext=True, spanrep=False)
@@ -169,9 +171,9 @@
invmkeyw = False
pfhook = None
quiet = True
- fdirsplit = None
+ fdiralt = {}
return _resolve_ui_w(headrefs, tagrefs, uipathseps, uicpaths, uicpathenv,
- xmlescape, pfhook, mkeyw, invmkeyw, quiet, fdirsplit,
+ xmlescape, pfhook, mkeyw, invmkeyw, quiet, fdiralt,
modtext=False, spanrep=True)
@@ -191,7 +193,7 @@
If C{uipathseps} is C{None}, separators known to KUIT C{<interface>} tag
will be used automatically.
- C{fdirsplit} is set to C{"~"}.
+ C{fdiralt} is set to C{{"%~": "%"}}.
@return: type F3C hook
@rtype: C{(msgstr, msg, cat) -> msgstr}
@@ -202,9 +204,9 @@
uipathseps = ["->"]
xmlescape = True
invmkeyw = False
- fdirsplit = "~"
+ fdiralt = {"%~": "%"}
return _resolve_ui_w(headrefs, tagrefs, uipathseps, uicpaths, uicpathenv,
- xmlescape, pfhook, mkeyw, invmkeyw, quiet, fdirsplit,
+ xmlescape, pfhook, mkeyw, invmkeyw, quiet, fdiralt,
modtext=True, spanrep=False)
@@ -219,7 +221,7 @@
If C{uipathseps} is C{None}, separators known to KUIT C{<interface>} tag
will be used automatically.
- C{fdirsplit} is set to C{"~"}.
+ C{fdiralt} is set to C{{"%~": "%"}}.
@return: type V3C hook
@rtype: C{(msgstr, msg, cat) -> spans}
@@ -232,14 +234,14 @@
invmkeyw = False
pfhook = None
quiet = True
- fdirsplit = "~"
+ fdiralt = {"%~": "%"}
return _resolve_ui_w(headrefs, tagrefs, uipathseps, uicpaths, uicpathenv,
- xmlescape, pfhook, mkeyw, invmkeyw, quiet, fdirsplit,
+ xmlescape, pfhook, mkeyw, invmkeyw, quiet, fdiralt,
modtext=False, spanrep=True)
def _resolve_ui_w (headrefs, tagrefs, uipathseps, uicpaths, uicpathenv,
- xmlescape, pfhook, mkeyw, invmkeyw, quiet, fdirsplit,
+ xmlescape, pfhook, mkeyw, invmkeyw, quiet, fdiralt,
modtext, spanrep):
"""
Worker for resolver factories.
@@ -376,7 +378,7 @@
hookcl_v3c = lambda uiref: resolver_helper(uiref, msg, cat, False, True)
uiref_res, errmsgs = _resolve_single_uiref(uiref, normcats,
hookcl_f3c, hookcl_v3c,
- fdirsplit)
+ fdiralt)
uiref_res = pfhook(uiref_res)
return uiref_res, errmsgs
@@ -597,7 +599,7 @@
_ts_fence = "|/|"
-def _resolve_single_uiref (uitext, uicats, hookcl_f3c, hookcl_v3c, fdirsplit):
+def _resolve_single_uiref (uitext, uicats, hookcl_f3c, hookcl_v3c, fdiralt):
errmsgs = []
@@ -649,8 +651,9 @@
if alst[0].startswith(_uiref_argsrepl):
alst[0] = alst[0][1:]
single = True
- if fdirsplit and fdirsplit in alst[0]:
- plhold = alst[0].replace(fdirsplit, "", 1)
+ for fdalt, fdnorm in fdiralt.items():
+ if alst[0].startswith(fdalt):
+ plhold = alst[0].replace(fdalt, fdnorm, 1)
if single:
msgid = msgid.replace(alst[0], plhold, 1)
else:
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic