diff --git a/.gitignore b/.gitignore index 8b13789..5669308 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ - +i18n diff --git a/static/i18n/en.yaml b/static/i18n/en.yaml deleted file mode 100644 index 889bf2e..0000000 --- a/static/i18n/en.yaml +++ /dev/null @@ -1,33 +0,0 @@ -title: - repeater: Repeater - mode: Mode - notes: Notes - knobs: Knobs -key: - key: Key - dit: Dit - dah: Dah -keyer: - cootie: Straight Key / Cootie - bug: Bug - elbug: Electronic Bug - singledot: Single Dot - ultimatic: Ultimatic - iambic: Iambic (plain) - iambica: Iambic A - iambicb: Iambic B - keyahead: Keyahea -label: - wpm: WPM - ms: ms - wiki: Help - rx-delay: receive delay - telegraph-sounds: Telegraph sounds -title: - discord: Text/Voice chat on Discord - wiki: Vail Wiki -description: - ck: Send CK (check) to the repeater, and play when it comes back. - reset: Reset all Vail preferences to default. - notes: Enter your own notes here. - diff --git a/static/i18n/fr.yaml b/static/i18n/fr.yaml deleted file mode 100644 index fd03be6..0000000 --- a/static/i18n/fr.yaml +++ /dev/null @@ -1,32 +0,0 @@ -title: - repeater: Répéteur - mode: Mode - notes: Remarques - knobs: Réglages -key: - key: Key - dit: Dit - dah: Dah -keyer: - cootie: Straight Key / Cootie - bug: Bug - elbug: Electronic Bug - singledot: Single Dot - ultimatic: Ultimatic - iambic: Iambic (plain) - iambica: Iambic A - iambicb: Iambic B - keyahead: Keyahead -label: - wpm: WPM - ms: ms - wiki: Help - rx-delay: retard de réception - telegraph-sounds: Sons télégraphiques -title: - discord: Text/Voice chat on Discord - wiki: Vail Wiki -description: - ck: Transmettre CK (check) au répéteur, et le jouer quand il arrive. - reset: Réinitialiser les paramètres par défaut. - notes: Écrivez vos nôtes ici. diff --git a/static/index.html b/static/index.html index 83cbb1d..bc2fa34 100644 --- a/static/index.html +++ b/static/index.html @@ -40,7 +40,7 @@
-

Repeater

+

Repeater

@@ -123,22 +123,22 @@
- +
@@ -149,9 +149,10 @@
@@ -175,12 +176,12 @@
-

Notes

- +

+
@@ -188,24 +189,24 @@
-

Knobs

+

Knobs

-
+
Send CK (check) to the repeater, and play when it comes back.
-
-
+
Reset all Vail preferences to default.
@@ -215,7 +216,7 @@
@@ -250,7 +251,7 @@

diff --git a/static/scripts/i18n.mjs b/static/scripts/i18n.mjs new file mode 100644 index 0000000..f4685ec --- /dev/null +++ b/static/scripts/i18n.mjs @@ -0,0 +1,47 @@ +import {Xlat} from "./xlat.mjs" + +class I18n { + constructor() { + for (let lang of navigator.languages) { + this.table = Xlat[lang] + if (this.table) { + break + } + } + } + + Fill() { + if (!this.table) { + return + } + + for (let e of document.querySelectorAll("[data-i18n]")) { + e.innerHTML = this.lookup(e.dataset.i18n, e.innerHTML) + } + + for (let e of document.querySelectorAll("[data-i18n-placeholder]")) { + e.placeholder = this.lookup(e.dataset.i18nPlaceholder, e.placeholder) + } + + for (let e of document.querySelectorAll("[data-i18n-title")) { + e.title = this.lookup(e.dataset.i18nTitle, e.title) + } + } + + lookup(key, dfl=null) { + let obj = this.table + for (let k of key.split(".")) { + obj = obj[k] + } + return obj || dfl + } +} + +async function Setup() { + let i = new I18n() + i.Fill() +} + +export { + Setup, +} \ No newline at end of file diff --git a/static/scripts/vail.mjs b/static/scripts/vail.mjs index 0a7bd75..6d996da 100644 --- a/static/scripts/vail.mjs +++ b/static/scripts/vail.mjs @@ -3,6 +3,7 @@ import * as Outputs from "./outputs.mjs" import * as Inputs from "./inputs.mjs" import * as Repeaters from "./repeaters.mjs" import * as Chart from "./chart.mjs" +import * as I18n from "./i18n.mjs" const DefaultRepeater = "General" const Millisecond = 1 @@ -453,6 +454,7 @@ function init() { if (navigator.serviceWorker) { navigator.serviceWorker.register("sw.js") } + I18n.Setup() try { window.app = new VailClient() } catch (err) { diff --git a/static/scripts/xlat.mjs b/static/scripts/xlat.mjs new file mode 100644 index 0000000..cfab71c --- /dev/null +++ b/static/scripts/xlat.mjs @@ -0,0 +1,122 @@ +export const Xlat = { + "fr": { + "heading": { + "repeater": "Répéteur", + "mode": "Mode", + "notes": "Remarques", + "knobs": "Réglages" + }, + "key": { + "key": "Key", + "dit": "Dit", + "dah": "Dah" + }, + "keyer": { + "cootie": "Straight Key / Cootie", + "bug": "Bug", + "elbug": "Electronic Bug", + "singledot": "Single Dot", + "ultimatic": "Ultimatic", + "iambic": "Iambic (plain)", + "iambica": "Iambic A", + "iambicb": "Iambic B", + "keyahead": "Keyahead" + }, + "label": { + "wpm": "WPM", + "ms": "ms", + "wiki": "Aide", + "rx-delay": "retard de réception", + "telegraph-sounds": "Sons télégraphiques" + }, + "title": { + "discord": "Chat textuel et du voix, sur Discord", + "wiki": "Vail Wiki" + }, + "description": { + "ck": "Transmettre CK (check) au répéteur, et sonner le réponse.", + "reset": "Réinitialiser les paramètres par défaut.", + "notes": "Écrivez vos nôtes ici." + } + }, + "en": { + "heading": { + "repeater": "Repeater eater", + "mode": "Mode", + "notes": "Notes", + "knobs": "Knobs" + }, + "key": { + "key": "Key", + "dit": "Dit", + "dah": "Dah" + }, + "keyer": { + "cootie": "Straight Key / Cootie", + "bug": "Bug", + "elbug": "Electronic Bug", + "singledot": "Single Dot", + "ultimatic": "Ultimatic", + "iambic": "Iambic (plain)", + "iambica": "Iambic A", + "iambicb": "Iambic B", + "keyahead": "Keyahea" + }, + "label": { + "wpm": "WPM", + "ms": "ms", + "wiki": "Help", + "rx-delay": "receive delay", + "telegraph-sounds": "Telegraph sounds" + }, + "title": { + "discord": "Text/Voice chat on Discord", + "wiki": "Vail Wiki" + }, + "description": { + "ck": "Send CK (check) to the repeater, and play when it comes back.", + "reset": "Reset all Vail preferences to default.", + "notes": "Enter your own notes here." + } + }, + "se": { + "heading": { + "repeater": "Repeater", + "mode": "Läge", + "notes": "Anteckningar", + "knobs": "Rattar" + }, + "key": { + "key": "Nyckel", + "dit": "Dit", + "dah": "Dah" + }, + "keyer": { + "cootie": "Handpump / Cootie", + "bug": "Bug", + "elbug": "Elektronisk Bug", + "singledot": "Enkelpunktig", + "ultimatic": "Ultimatisk", + "iambic": "Iambic (normal)", + "iambica": "Iambic-läge A", + "iambicb": "Iambic-läge B", + "keyahead": "Förtelegrafera" + }, + "label": { + "wpm": "Ord per minut", + "ms": "Millisekunder", + "wiki": "Hjälp", + "rx-delay": "Mottagningsfördröjning", + "telegraph-sounds": "Telegrafljud" + }, + "title": { + "discord": "Text- eller röstkommunicera på Discord", + "wiki": "Vail Wiki" + }, + "description": { + "ck": "Sänd CK (kontroll) till repeater:en, och få uppspelat vid återkomst.", + "reset": "Återställ till standardinställningarna.", + "notes": "Angiv Dina egna anteckningar här." + } + } +}