[tor-commits] [bridgedb/main] Make accesskeys easier to translate
meskio at torproject.org
meskio at torproject.org
Thu Jun 24 17:43:55 UTC 2021
commit 4d8f661566a981c442b045f02f671bbd1b289473
Author: meskio <meskio at torproject.org>
Date: Thu Jun 17 10:18:39 2021 +0200
Make accesskeys easier to translate
Signal accesskeys with '_' preceding the leter that will be surronded by
'<u>' and provide better feedback to translators on how to use them.
Fixes #12957
---
bridgedb/distributors/https/server.py | 10 ++++--
bridgedb/distributors/https/templates/index.html | 26 ++++++++++++---
bridgedb/distributors/https/templates/options.html | 37 +++++++++++++++-------
3 files changed, 55 insertions(+), 18 deletions(-)
diff --git a/bridgedb/distributors/https/server.py b/bridgedb/distributors/https/server.py
index 6310e75..818e2e0 100644
--- a/bridgedb/distributors/https/server.py
+++ b/bridgedb/distributors/https/server.py
@@ -411,16 +411,22 @@ class TranslatedTemplateResource(CustomErrorHandlingResource, CSPResource):
rtl=rtl,
lang=langs[0],
langOverride=translations.isLangOverridden(request),
- showFaq=self.showFaq)
+ showFaq=self.showFaq,
+ addAccessKeys=self._add_access_keys)
else:
rendered = template.render(strings,
getSortedLangList(),
- showFaq=self.showFaq)
+ showFaq=self.showFaq,
+ addAccessKeys=self._add_access_keys)
except Exception as err: # pragma: no cover
rendered = replaceErrorPage(request, err)
request.setHeader("Content-Type", "text/html; charset=utf-8")
return rendered
+ def _add_access_keys(self, string):
+ i = string.find("_")
+ return string[:i] + "<u>" + string[i + 1] + "</u>" + string[i + 2 :]
+
render_POST = render_GET
diff --git a/bridgedb/distributors/https/templates/index.html b/bridgedb/distributors/https/templates/index.html
index 2752c5b..d34167e 100644
--- a/bridgedb/distributors/https/templates/index.html
+++ b/bridgedb/distributors/https/templates/index.html
@@ -1,14 +1,20 @@
## -*- coding: utf-8 -*-
<%inherit file="base.html"/>
-<%page args="strings, langs, rtl=False, lang='en', langOverride=False, **kwargs"/>
+<%page args="strings, langs, rtl=False, lang='en', langOverride=False, addAccessKeys=None, **kwargs"/>
<div class="main-steps">
<div class="step row" id="step-1">
<div class="bdb_span7 step-text">
<span class="lead">
<span class="step-title">
- ${_("Step %s1%s") % ("""<u>""", """</u>""")}</span>
+## TRANSLATORS: '_' is used to insert HTML5 underlining tags, to mark accesskeys for disabled users.
+## Make sure the character preceded by '_' is unique in this file, the other strings that
+## contain accesskeys in this file are: "Step _2", "Step _3".
+## You can change the character preceded by '_' to pick any of the existing ones that will
+## fit better for your language, or if none you can keep the English accesskey by
+## adding a '(_1)' at the end of the string.
+ ${addAccessKeys(_("Step _1"))}</span>
<span class="step-text">
${_("Download %s Tor Browser %s") % \
("""<a href="https://www.torproject.org/projects/torbrowser.html"
@@ -22,7 +28,13 @@
<div class="bdb_span7 step-text">
<span class="lead">
<span class="step-title">
- ${_("Step %s2%s") % ("""<u>""", """</u>""")}</span>
+## TRANSLATORS: '_' is used to insert HTML5 underlining tags, to mark accesskeys for disabled users.
+## Make sure the character preceded by '_' is unique in this file, the other strings that
+## contain accesskeys in this file are: "Step _1", "Step _3".
+## You can change the character preceded by '_' to pick any of the existing ones that will
+## fit better for your language, or if none you can keep the English accesskey by
+## adding a '(_2)' at the end of the string.
+ ${addAccessKeys(_("Step _2"))}</span>
<span class="step-text">
% if langOverride:
${_("Get %s bridges %s") % ("""<a href="/options?lang="""+lang+"""" accesskey="2">""", "</a>")}</span>
@@ -37,7 +49,13 @@
<div class="bdb_span7 step-text">
<span class="lead">
<span class="step-title">
- ${_("Step %s3%s") % ("""<u>""", """</u>""")}</span>
+## TRANSLATORS: '_' is used to insert HTML5 underlining tags, to mark accesskeys for disabled users.
+## Make sure the character preceded by '_' is unique in this file, the other strings that
+## contain accesskeys in this file are: "Step _1", "Step _2".
+## You can change the character preceded by '_' to pick any of the existing ones that will
+## fit better for your language, or if none you can keep the English accesskey by
+## adding a '(_3)' at the end of the string.
+ ${addAccessKeys(_("Step _3"))}</span>
<span class="step-text">
% if langOverride:
${_("""Now %s add the bridges to Tor Browser %s""") % \
diff --git a/bridgedb/distributors/https/templates/options.html b/bridgedb/distributors/https/templates/options.html
index 653fc49..0f0bbd2 100644
--- a/bridgedb/distributors/https/templates/options.html
+++ b/bridgedb/distributors/https/templates/options.html
@@ -1,7 +1,7 @@
## -*- coding: utf-8 -*-
<%inherit file="base.html"/>
-<%page args="strings, langs, rtl=False, lang='en', langOverride=False, **kwargs"/>
+<%page args="strings, langs, rtl=False, lang='en', langOverride=False, addAccessKeys=None, **kwargs"/>
<div class="container-fluid container-fluid-outer-96">
<!--<div class="container-fluid step-semi-transparent">-->
@@ -35,11 +35,14 @@
id="just-give-me-bridges-btn"
type="button"
accesskey="j">
-## TRANSLATORS: Please make sure the '%s' surrounding single letters at the
-## beginning of words are present in your final translation. Thanks!
-## (These are used to insert HTML5 underlining tags, to mark accesskeys
-## for disabled users.)
- ${_("""%sJ%sust give me bridges!""") % ("""<u>""", """</u>""")}
+## TRANSLATORS: '_' is used to insert HTML5 underlining tags, to mark accesskeys for disabled users.
+## Make sure the character preceded by '_' is unique in this file, the other strings that
+## contain accesskeys in this file are: "Do you need a Pluggable _Transport?", "_Yes!",
+## "_Get Bridges".
+## You can change the character preceded by '_' to pick any of the existing ones that will
+## fit better for your language, or if none you can keep the English accesskey by
+## adding a '(_J)' at the end of the string.
+ ${addAccessKeys(_("""_Just give me bridges!"""))}
</button>
</a>
</p>
@@ -125,10 +128,15 @@
type="checkbox"
value="yes"
accesskey="y" />
-## TRANSLATORS: Please make sure the '%s' surrounding single letters at the
-## beginning of words are present in your final translation. Thanks!
+## TRANSLATORS: '_' is used to insert HTML5 underlining tags, to mark accesskeys for disabled users.
+## Make sure the character preceded by '_' is unique in this file, the other strings that
+## contain accesskeys in this file are: "Do you need a Pluggable _Transport?",
+## "_Just give me bridges!", "_Get Bridges".
+## You can change the character preceded by '_' to pick any of the existing ones that will
+## fit better for your language, or if none you can keep the English accesskey by
+## adding a '(_Y)' at the end of the string.
## TRANSLATORS: Translate "Yes!" as in "Yes! I do need IPv6 addresses."
- ${_("""%sY%ses!""") % ("<u>", "</u>")}
+ ${addAccessKeys(_("""_Yes!"""))}
</div>
</div>
</div>
@@ -148,10 +156,15 @@
<button class="btn btn-primary btn-lg btn-block"
id="get-bridges-btn"
accesskey="g">
-## TRANSLATORS: Please make sure the '%s' surrounding single letters at the
-## beginning of words are present in your final translation. Thanks!
+## TRANSLATORS: '_' is used to insert HTML5 underlining tags, to mark accesskeys for disabled users.
+## Make sure the character preceded by '_' is unique in this file, the other strings that
+## contain accesskeys in this file are: "Do you need a Pluggable _Transport?", "_Yes!",
+## "_Just give me bridges!".
+## You can change the character preceded by '_' to pick any of the existing ones that will
+## fit better for your language, or if none you can keep the English accesskey by
+## adding a '(_G)' at the end of the string.
## TRANSLATORS: Please do NOT translate the word "bridge"!
- ${_("""%sG%set Bridges""") % ("<u>", "</u>")}
+ ${addAccessKeys(_("""_Get Bridges"""))}
</button>
</div>
</div>
More information about the tor-commits
mailing list