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",
"language": "Deutsch - German",
"language": {
"name": "Deutsch - German",
"tts": "de",
"speechSynthesis": "de-DE",
"valhalla": "de"
},
"saved": {
"home": "Heim",
"school": "Schule",

View File

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

View File

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

View File

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

View File

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