Skip to content
This repository was archived by the owner on Aug 28, 2019. It is now read-only.

Commit 8946450

Browse files
committed
Fix certain HTML and JS strings not being exposed to .pot files
1 parent db5a22d commit 8946450

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

docs/_static/copy.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const copy = async (obj) => {
99
icon.textContent = COPIED;
1010
setTimeout(() => (icon.textContent = COPY), 2500);
1111
},
12-
(r) => alert('Could not copy codeblock:\n' + r.toString())
12+
(r) => alert(DPY_TRANSLATIONS.copy_code_error + '\n' + r.toString())
1313
);
1414
};
1515

@@ -21,8 +21,8 @@ document.addEventListener("DOMContentLoaded", () => {
2121
let copyEl = document.createElement("span");
2222
copyEl.addEventListener('click', () => copy(codeblock));
2323
copyEl.className = "copy";
24-
copyEl.setAttribute("aria-label", "Copy Code");
25-
copyEl.setAttribute("title", "Copy Code");
24+
copyEl.setAttribute("aria-label", DPY_TRANSLATIONS.copy_code);
25+
copyEl.setAttribute("title", DPY_TRANSLATIONS.copy_code);
2626

2727
let copyIcon = document.createElement("span");
2828
copyIcon.className = "material-icons";

docs/_templates/layout.html

+13-3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,16 @@
2121
<link rel="stylesheet" href="{{ pathto('_static/icons.css', 1)|e }}" type="text/css" />
2222
{%- block scripts %}
2323
<script id="documentation_options" data-url_root="{{ pathto('', 1) }}" src="{{ pathto('_static/documentation_options.js', 1) }}"></script>
24+
{#- In order to allow strings to be translated, they must be passed to gettext here #}
25+
{#- Any user-facing string that is translated must be in this object #}
26+
{#- Note that these can only be simple key-value translations #}
27+
{#- If something better comes along this will be removed #}
28+
<script type="text/javascript">
29+
var DPY_TRANSLATIONS = {{ "{" }}
30+
copy_code: "{{ _('Copy Code') }}",
31+
copy_code_error: "{{ _('Could not copy codeblock:') }}",
32+
{{ "}" }}
33+
</script>
2434
{%- for js in script_files %}
2535
{{ js_tag(js) }}
2636
{%- endfor %}
@@ -61,7 +71,7 @@
6171
<a href="{{ pathto(master_doc)|e }}" class="main-heading">discord.py</a>
6272
<a href="https://github.com/Rapptz/discord.py" title="GitHub"><span class="material-icons custom-icons">github</span></a>
6373
<a href="{{ discord_invite }}" title="{{ _('Discord') }}"><span class="material-icons custom-icons">discord</span></a>
64-
<a href="{{ pathto('faq') }}" title="FAQ"><span class="material-icons">help_center</span></a>
74+
<a href="{{ pathto('faq') }}" title="{{ _('FAQ') }}"><span class="material-icons">help_center</span></a>
6575
{#- If we have more links we can put them here #}
6676
<a onclick="mobileSearch.open();" title="{{ _('Search') }}" id="open-search" class="mobile-only"><span class="material-icons">search</span></a>
6777
<a onclick="mobileSearch.close();" title="{{ _('Close') }}" id="close-search" class="mobile-only" hidden><span class="material-icons">close</span></a>
@@ -157,7 +167,7 @@
157167

158168
<div id="settings" class="modal" onclick="if (event.target == this){ settingsModal.close(); }" hidden>
159169
<div class="modal-content">
160-
<span class="close" onclick="settingsModal.close();" title="Close">
170+
<span class="close" onclick="settingsModal.close();" title="{{ _('Close') }}">
161171
<span class="material-icons">close</span>
162172
</span>
163173
<h1>{{ _('Settings') }}</h1>
@@ -199,7 +209,7 @@ <h3>
199209
</div>
200210

201211
<div id="to-top" onclick="scrollToTop()"{%- if READTHEDOCS %} class="is-rtd"{%- endif %} hidden>
202-
<span><span class="material-icons">arrow_upward</span> to top</span>
212+
<span><span class="material-icons">arrow_upward</span> {{ _('to top') }}</span>
203213
</div>
204214

205215
</body>

0 commit comments

Comments
 (0)