jlelse
/
Indieroad
Archived
1
Fork 0

Translation for speak / stop speak text

This commit is contained in:
Jan-Lukas Else 2020-04-22 12:25:00 +02:00
parent ec722fa11f
commit 358717f693
4 changed files with 18 additions and 5 deletions

View File

@ -11,13 +11,13 @@ function initSpeak() {
if (window.speechSynthesis) {
let speakBtn = document.querySelector('#speakBtn');
speakBtn.style.display = '';
speakBtn.innerHTML = "<a onclick=\"speak()\">Read to me, please.</a>";
speakBtn.innerHTML = "<a onclick=\"speak()\">" + speakText + "</a>";
}
}
function speak() {
console.log("Start speaking")
document.querySelector('#speakBtn').innerHTML = "<a onclick=\"stopSpeak()\">Stop speaking!</a>";
document.querySelector('#speakBtn').innerHTML = "<a onclick=\"stopSpeak()\">" + stopSpeakText + "</a>";
let textContent =
((document.querySelector('article .post-title')) ? document.querySelector('article .post-title').innerText + "\n\n" : "")
+ document.querySelector('article .content').innerText;
@ -31,7 +31,7 @@ function speak() {
function stopSpeak() {
console.log("Stop speaking")
window.speechSynthesis.cancel();
document.querySelector('#speakBtn').innerHTML = "<a onclick=\"speak()\">Read to me, please.</a>";
document.querySelector('#speakBtn').innerHTML = "<a onclick=\"speak()\">" + speakText + "</a>";
}
window.onbeforeunload = function () {

View File

@ -60,3 +60,9 @@
- id: oldcontent
translation: Dieser Eintrag ist bereits über ein Jahr alt. Er ist möglicherweise nicht mehr aktuell. Meinungen können sich geändert haben.
- id: speak
translation: Lies mir bitte vor.
- id: stopspeak
translation: Hör auf zu sprechen!

View File

@ -63,3 +63,9 @@
- id: oldcontent
translation: This entry is already over one year old. It may no longer be up to date. Opinions may have changed.
- id: speak
translation: Read to me, please.
- id: stopspeak
translation: Stop speaking!

View File

@ -11,6 +11,7 @@
{{ if (.Param "speak") }}
<div id="speakBtn" class="item" style="display: none;"></div>
{{ $speakScript := resources.Get "js/speak.js" | minify | fingerprint }}
<script>const speakText = "{{ T "speak" }}";const stopSpeakText = "{{ T "stopspeak" }}";</script>
<script defer src="{{ $speakScript.RelPermalink }}" integrity="{{ $speakScript.Data.Integrity }}"></script>
{{ end }}
</div>