mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-17 00:32:21 +00:00
fix(voice): Gemini voice messages follow a language change
The Gemini session translated each status and error message once, when it happened, so after a language change the voice control kept showing it in the old language. The state event now also carries the English catalog text as sourceDetail, and the control words it when shown. The local server's known token errors stay catalog text until then instead of being translated on arrival.
This commit is contained in:
1 parent
962f7293c6
commit
b1c5de0ed1
5 files changed
+77
-8
No files matched your search
@@ -7,7 +7,7 @@ import { createVoiceSession, isStoppable } from './session.js';
|
||||
import { VoiceCardControls } from './voiceCard.js';
|
||||
import { PointerReticle } from './pointerReticle.js';
|
||||
import { VOICE_PROVIDERS } from './providerCapabilities.js';
|
||||
import { t } from '../i18n/index.js';
|
||||
import { t, translateKnown } from '../i18n/index.js';
|
||||
|
||||
function createDefaultReticle(pointer) {
|
||||
const element = pointer?.element;
|
||||
@@ -114,11 +114,18 @@ export function createVoiceCommands({
|
||||
// States are machine values; only the label is translated.
|
||||
ui.update('status', { text: () => voiceStatusLabel(event.state) });
|
||||
// The portable session reports 'Voice off' in English: show the idle
|
||||
// label instead. Other details are provider messages, shown as they come.
|
||||
// label instead. Other details are provider messages; one that keeps its
|
||||
// English catalog text is worded again in the current language.
|
||||
const idle = event.state === 'idle';
|
||||
const detail = event.detail === 'Voice off' ? '' : event.detail;
|
||||
const source = event.sourceDetail ?? event.detail;
|
||||
const detail = () =>
|
||||
source === 'Voice off'
|
||||
? ''
|
||||
: event.sourceDetail
|
||||
? translateKnown(event.sourceDetail)
|
||||
: event.detail;
|
||||
ui.update('detail', {
|
||||
text: () => detail || (idle ? t('Voice off') : t('Voice active')),
|
||||
text: () => detail() || (idle ? t('Voice off') : t('Voice active')),
|
||||
});
|
||||
// A typed chat session is not the microphone.
|
||||
ui.update('button', {
|
||||
@@ -127,7 +134,7 @@ export function createVoiceCommands({
|
||||
ui.update('error', {
|
||||
text: () =>
|
||||
event.state === 'error'
|
||||
? event.detail || t('Voice could not be started.')
|
||||
? detail() || t('Voice could not be started.')
|
||||
: '',
|
||||
// "Check microphone permission" is wrong advice for a missing key.
|
||||
hint: () => !(event.state === 'error' && event.missingKey === true),
|
||||
|
||||
Reference in new issue
Block a user