Translation for speak / stop speak text
This commit is contained in:
parent
ec722fa11f
commit
358717f693
|
@ -11,13 +11,13 @@ function initSpeak() {
|
||||||
if (window.speechSynthesis) {
|
if (window.speechSynthesis) {
|
||||||
let speakBtn = document.querySelector('#speakBtn');
|
let speakBtn = document.querySelector('#speakBtn');
|
||||||
speakBtn.style.display = '';
|
speakBtn.style.display = '';
|
||||||
speakBtn.innerHTML = "<a onclick=\"speak()\">Read to me, please.</a>";
|
speakBtn.innerHTML = "<a onclick=\"speak()\">" + speakText + "</a>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function speak() {
|
function speak() {
|
||||||
console.log("Start speaking")
|
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 =
|
let textContent =
|
||||||
((document.querySelector('article .post-title')) ? document.querySelector('article .post-title').innerText + "\n\n" : "")
|
((document.querySelector('article .post-title')) ? document.querySelector('article .post-title').innerText + "\n\n" : "")
|
||||||
+ document.querySelector('article .content').innerText;
|
+ document.querySelector('article .content').innerText;
|
||||||
|
@ -31,7 +31,7 @@ function speak() {
|
||||||
function stopSpeak() {
|
function stopSpeak() {
|
||||||
console.log("Stop speaking")
|
console.log("Stop speaking")
|
||||||
window.speechSynthesis.cancel();
|
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 () {
|
window.onbeforeunload = function () {
|
||||||
|
|
|
@ -59,4 +59,10 @@
|
||||||
translation: Übersetzungen
|
translation: Übersetzungen
|
||||||
|
|
||||||
- id: oldcontent
|
- 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.
|
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!
|
|
@ -62,4 +62,10 @@
|
||||||
translation: Translations
|
translation: Translations
|
||||||
|
|
||||||
- id: oldcontent
|
- id: oldcontent
|
||||||
translation: This entry is already over one year old. It may no longer be up to date. Opinions may have changed.
|
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!
|
|
@ -11,6 +11,7 @@
|
||||||
{{ if (.Param "speak") }}
|
{{ if (.Param "speak") }}
|
||||||
<div id="speakBtn" class="item" style="display: none;"></div>
|
<div id="speakBtn" class="item" style="display: none;"></div>
|
||||||
{{ $speakScript := resources.Get "js/speak.js" | minify | fingerprint }}
|
{{ $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>
|
<script defer src="{{ $speakScript.RelPermalink }}" integrity="{{ $speakScript.Data.Integrity }}"></script>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</div>
|
</div>
|
||||||
|
|
Reference in New Issue