feat: localize voice guidance
Some checks failed
TrafficCue CI / check (push) Failing after 1m8s
TrafficCue CI / build (push) Successful in 9m46s
TrafficCue CI / build-android (push) Successful in 25m15s

This commit is contained in:
2025-09-30 19:23:46 +02:00
parent 50429fd4a6
commit 03838bf714
5 changed files with 19 additions and 7 deletions

View File

@ -1,6 +1,11 @@
{ {
"$schema": "https://inlang.com/schema/inlang-message-format", "$schema": "https://inlang.com/schema/inlang-message-format",
"language": "Deutsch - German", "language": {
"name": "Deutsch - German",
"tts": "de",
"speechSynthesis": "de-DE",
"valhalla": "de"
},
"saved": { "saved": {
"home": "Heim", "home": "Heim",
"school": "Schule", "school": "Schule",

View File

@ -1,6 +1,11 @@
{ {
"$schema": "https://inlang.com/schema/inlang-message-format", "$schema": "https://inlang.com/schema/inlang-message-format",
"language": "English", "language": {
"name": "English",
"tts": "en",
"speechSynthesis": "en-US",
"valhalla": "en"
},
"save": "Save", "save": "Save",
"cancel": "Cancel", "cancel": "Cancel",
"loading": "Loading...", "loading": "Loading...",

View File

@ -13,10 +13,10 @@
<div id="languages"> <div id="languages">
{#each locales as locale, _index (locale)} {#each locales as locale, _index (locale)}
{#if locale == getLocale()} {#if locale == getLocale()}
<SettingsButton text={m.language()} icon={CheckIcon} disabled /> <SettingsButton text={m["language.name"]()} icon={CheckIcon} disabled />
{:else} {:else}
<SettingsButton <SettingsButton
text={m.language({}, { locale })} text={m["language.name"]({}, { locale })}
icon={LanguagesIcon} icon={LanguagesIcon}
onclick={() => { onclick={() => {
setLocale(locale); setLocale(locale);

View File

@ -1,5 +1,6 @@
import { duck, unduck } from "tauri-plugin-duck-api"; import { duck, unduck } from "tauri-plugin-duck-api";
import { invoke } from "@tauri-apps/api/core"; import { invoke } from "@tauri-apps/api/core";
import { m } from "$lang/messages";
export let tts: "tauri" | "web" | null = null; export let tts: "tauri" | "web" | null = null;
@ -23,14 +24,14 @@ export default async function say(text: string) {
duck(); duck();
if (tts !== "web") { if (tts !== "web") {
try { try {
await invoke("plugin:tts|speak", { text }); await invoke("plugin:tts|speak", { text, lang: m["language.tts"]() });
} catch (e) { } catch (e) {
console.error("Error speaking text", e); console.error("Error speaking text", e);
alert(e); alert(e);
} }
} else { } else {
const utterance = new SpeechSynthesisUtterance(text); const utterance = new SpeechSynthesisUtterance(text);
utterance.lang = "de-DE"; utterance.lang = m["language.speechSynthesis"]();
window.speechSynthesis.speak(utterance); window.speechSynthesis.speak(utterance);
} }
unduck(); unduck();

View File

@ -1,3 +1,4 @@
import { m } from "$lang/messages";
import type { import type {
ValhallaCosting, ValhallaCosting,
ValhallaCostingOptions, ValhallaCostingOptions,
@ -63,7 +64,7 @@ export function createValhallaRequest(
costing, costing,
units: "kilometers", units: "kilometers",
alternates: 2, alternates: 2,
language: "de-DE", language: m["language.valhalla"](),
costing_options: costingOptions, costing_options: costingOptions,
turn_lanes: true, turn_lanes: true,
}; };