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

Commit

Permalink
Fix certain HTML and JS strings not being exposed to .pot files
Browse files Browse the repository at this point in the history
  • Loading branch information
Rapptz committed Jun 5, 2022
1 parent db5a22d commit 8946450
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
6 changes: 3 additions & 3 deletions docs/_static/copy.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const copy = async (obj) => {
icon.textContent = COPIED;
setTimeout(() => (icon.textContent = COPY), 2500);
},
(r) => alert('Could not copy codeblock:\n' + r.toString())
(r) => alert(DPY_TRANSLATIONS.copy_code_error + '\n' + r.toString())
);
};

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

let copyIcon = document.createElement("span");
copyIcon.className = "material-icons";
Expand Down
16 changes: 13 additions & 3 deletions docs/_templates/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@
<link rel="stylesheet" href="{{ pathto('_static/icons.css', 1)|e }}" type="text/css" />
{%- block scripts %}
<script id="documentation_options" data-url_root="{{ pathto('', 1) }}" src="{{ pathto('_static/documentation_options.js', 1) }}"></script>
{#- In order to allow strings to be translated, they must be passed to gettext here #}
{#- Any user-facing string that is translated must be in this object #}
{#- Note that these can only be simple key-value translations #}
{#- If something better comes along this will be removed #}
<script type="text/javascript">
var DPY_TRANSLATIONS = {{ "{" }}
copy_code: "{{ _('Copy Code') }}",
copy_code_error: "{{ _('Could not copy codeblock:') }}",
{{ "}" }}
</script>
{%- for js in script_files %}
{{ js_tag(js) }}
{%- endfor %}
Expand Down Expand Up @@ -61,7 +71,7 @@
<a href="{{ pathto(master_doc)|e }}" class="main-heading">discord.py</a>
<a href="https://github.com/Rapptz/discord.py" title="GitHub"><span class="material-icons custom-icons">github</span></a>
<a href="{{ discord_invite }}" title="{{ _('Discord') }}"><span class="material-icons custom-icons">discord</span></a>
<a href="{{ pathto('faq') }}" title="FAQ"><span class="material-icons">help_center</span></a>
<a href="{{ pathto('faq') }}" title="{{ _('FAQ') }}"><span class="material-icons">help_center</span></a>
{#- If we have more links we can put them here #}
<a onclick="mobileSearch.open();" title="{{ _('Search') }}" id="open-search" class="mobile-only"><span class="material-icons">search</span></a>
<a onclick="mobileSearch.close();" title="{{ _('Close') }}" id="close-search" class="mobile-only" hidden><span class="material-icons">close</span></a>
Expand Down Expand Up @@ -157,7 +167,7 @@

<div id="settings" class="modal" onclick="if (event.target == this){ settingsModal.close(); }" hidden>
<div class="modal-content">
<span class="close" onclick="settingsModal.close();" title="Close">
<span class="close" onclick="settingsModal.close();" title="{{ _('Close') }}">
<span class="material-icons">close</span>
</span>
<h1>{{ _('Settings') }}</h1>
Expand Down Expand Up @@ -199,7 +209,7 @@ <h3>
</div>

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

</body>
Expand Down

0 comments on commit 8946450

Please sign in to comment.