feat(i18n): language foundation with en and pt-BR

Nothing in the project was translatable — every string sat inline in English.

en.ts is the source dictionary and its type is derived from it, so a typo or a
missing key fails typecheck instead of rendering the raw key at runtime.
pt-BR.ts is deliberately Partial: translation proceeds one system per update
and anything absent falls back to English, so a half-migrated interface is
never broken, only partly English.

Locale is persisted, guessed from the browser on first run, and kept in sync
with <html lang> through a subscription — persisted state rehydrates after
first paint, so a one-off assignment would miss it.

Translates the voice input panel (including the mic test shipped earlier
today) and the profile card as this round's system. Language options are
labelled in the active language, so a wrong pick can always be undone.
This commit is contained in:
2026-08-31 12:24:50 -03:00
parent 89e13441c8
commit 688a1335cb
9 changed files with 298 additions and 33 deletions
@@ -3,12 +3,14 @@ import { useVoiceStore } from '../../../stores/voiceStore';
import { AudioManager } from '../../../audio/AudioManager';
import { useAudioDevices } from '../../../hooks/useAudioDevices';
import { SectionShell, DropdownItem } from './_shared/SettingsPickerPrimitives';
import { useT } from '../../../i18n';
export function AudioInputSection() {
const inputDeviceId = useVoiceStore((s) => s.inputDeviceId);
const setInputDevice = useVoiceStore((s) => s.setInputDevice);
const inputVolume = useVoiceStore((s) => s.inputVolume);
const setInputVolume = useVoiceStore((s) => s.setInputVolume);
const t = useT();
const { permState, inputs, inputLabels, requestPermission } = useAudioDevices();
const [listOpen, setListOpen] = useState(false);
@@ -96,7 +98,7 @@ export function AudioInputSection() {
setMicTestError('');
const ok = await am.startMicTest();
if (!ok) {
setMicTestError('Could not open the microphone. Check the device and its permission.');
setMicTestError(t('settings.voice.micTest.failed'));
return;
}
setMicTesting(true);
@@ -125,7 +127,7 @@ export function AudioInputSection() {
if (permState === 'unknown') {
return (
<SectionShell title="Input Device">
<SectionShell title={t('settings.voice.input.title')}>
<div className="text-sm text-txt-tertiary">Checking microphone access</div>
</SectionShell>
);
@@ -133,7 +135,7 @@ export function AudioInputSection() {
if (permState === 'denied') {
return (
<SectionShell title="Input Device">
<SectionShell title={t('settings.voice.input.title')}>
<div className="space-y-2">
<div className="text-sm text-txt-primary"> Microphone access denied</div>
<div className="text-xs text-txt-tertiary">
@@ -152,7 +154,7 @@ export function AudioInputSection() {
if (permState === 'prompt') {
return (
<SectionShell title="Input Device">
<SectionShell title={t('settings.voice.input.title')}>
<div className="space-y-3">
<div className="text-xs text-txt-tertiary">
Microphone permission needed to list and choose an input device.
@@ -186,7 +188,7 @@ export function AudioInputSection() {
const activeBars = Math.round(micLevel * micBars * (inputVolume / 100));
return (
<SectionShell title="Input Device">
<SectionShell title={t('settings.voice.input.title')}>
<div className="space-y-3">
<div ref={dropdownRef}>
<button
@@ -223,7 +225,7 @@ export function AudioInputSection() {
<div>
<div className="flex items-center justify-between mb-1.5">
<div className="text-[13px] font-medium text-txt-primary">Input Volume</div>
<div className="text-[13px] font-medium text-txt-primary">{t('settings.voice.input.volume')}</div>
<div className="text-xs text-txt-tertiary tabular-nums">{inputVolume}%</div>
</div>
<input
@@ -258,14 +260,14 @@ export function AudioInputSection() {
: 'bg-accent-primary text-white hover:brightness-110'
}`}
>
{micTesting ? 'Stop Testing' : "Let's Check"}
{micTesting ? t('settings.voice.micTest.stop') : t('settings.voice.micTest.start')}
</button>
<span className="text-xs text-txt-tertiary">
{micTesting
? 'Playing your mic back to you — say something.'
? t('settings.voice.micTest.playing')
: isLiveKitConnected
? 'The level meter is live while you are in a call.'
: 'Test your mic without joining a call.'}
? t('settings.voice.micTest.inCall')
: t('settings.voice.micTest.idle')}
</span>
</div>
{micTestError && (