Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
fix(home): put every reader-facing string in connect and the floorplan in the catalog
nirholasdba5cffe5f2b
diff --git a/src/home/connect.js b/src/home/connect.jsindex ac2f99d2f..0775f1c65 100644--- a/src/home/connect.js+++ b/src/home/connect.js@@ -30,6 +30,11 @@ import { isPrivateHost, normalizeBaseUrl } from '@three-ws/home-bridge/url';import { disclosurePanel } from './disclosure-panel.js';import { isDegraded, renderManage } from './manage.js';+// Every string a person reads on this page goes through here. Their own words+// (the name they gave their house, the address they typed, a message their own+// Home Assistant returned) are interpolated as values, never baked into a+// source string. See i18n-home.js.+import { plural, t } from './i18n-home.js';/** The eleven states. Each one has a designed treatment; none falls through. */export const STATE = Object.freeze({@@ -112,7 +117,7 @@ async function boot() {} catch (err) {// The list failing is not the connect flow failing: offer the connect card// with the reason attached, so a stranger is never staring at a dead page.- render(STATE.EMPTY, { notice: { tone: 'error', title: 'We could not load your homes.', body: messageOf(err) } });+ render(STATE.EMPTY, { notice: { tone: 'error', title: t('home_connect.list_failed', 'We could not load your homes.'), body: messageOf(err) } });}}@@ -197,24 +202,24 @@ function render(state, data = {}) {function signedOut() {const panel = el('section', 'hm-panel');panel.append(- el('h2', 'hm-panel-title', 'Sign in to connect a home'),- el('p', 'hm-panel-sub', 'Your homes are tied to your three.ws account, because the credential that opens your house is stored encrypted against it and never in this browser.'),+ el('h2', 'hm-panel-title', t('home_connect.signed_out_title', 'Sign in to connect a home')),+ el('p', 'hm-panel-sub', t('home_connect.signed_out_sub', 'Your homes are tied to your three.ws account, because the credential that opens your house is stored encrypted against it and never in this browser.')),);const list = el('ul', 'hm-ol');list.style.listStyle = 'disc';for (const line of [- 'Your agent reads every room, light, lock and sensor your instance exposes.',- 'It runs the scenes and scripts you already built, by name.',- 'Locking up, closing and arming never prompt. Unlocking, opening and disarming always do.',+ t('home_connect.signed_out_point_1', 'Your agent reads every room, light, lock and sensor your instance exposes.'),+ t('home_connect.signed_out_point_2', 'It runs the scenes and scripts you already built, by name.'),+ t('home_connect.signed_out_point_3', 'Locking up, closing and arming never prompt. Unlocking, opening and disarming always do.'),]) list.append(el('li', '', line));panel.append(list);const actions = el('div', 'hm-actions');actions.style.marginTop = 'var(--space-md)';- const signIn = el('a', 'hm-btn hm-btn-primary', 'Sign in');+ const signIn = el('a', 'hm-btn hm-btn-primary', t('home_connect.sign_in', 'Sign in'));signIn.href = `/login?next=${encodeURIComponent('/smart-home')}`;- const learn = el('a', 'hm-btn hm-btn-ghost', 'How it works');+ const learn = el('a', 'hm-btn hm-btn-ghost', t('home_connect.how_it_works', 'How it works'));learn.href = '/docs/smart-home';actions.append(signIn, learn);panel.append(actions);@@ -233,8 +238,8 @@ function connectCard({ notice, values = {}, focus } = {}) {const head = el('div', 'hm-panel-head');const heading = el('div');heading.append(- el('h2', 'hm-panel-title', 'Connect a Home Assistant'),- el('p', 'hm-panel-sub', 'Everything runs against your own instance. What we store, and what we never store, is spelled out below before you connect.'),+ el('h2', 'hm-panel-title', t('home_connect.card_title', 'Connect a Home Assistant')),+ el('p', 'hm-panel-sub', t('home_connect.card_sub', 'Everything runs against your own instance. What we store, and what we never store, is spelled out below before you connect.')),);head.append(heading);panel.append(head);@@ -246,16 +251,16 @@ function connectCard({ notice, values = {}, focus } = {}) {const label = field({id: 'hm-label',- label: 'What do you call it?',- hint: 'Shown in your agent and in the action log. "Home", "The office", anything.',+ label: t('home_connect.label_label', 'What do you call it?'),+ hint: t('home_connect.label_hint', 'Shown in your agent and in the action log. "Home", "The office", anything.'),value: values.label || '',- attrs: { type: 'text', maxlength: '120', autocomplete: 'off', placeholder: 'Home' },+ attrs: { type: 'text', maxlength: '120', autocomplete: 'off', placeholder: t('home_connect.label_placeholder', 'Home') },});const url = field({id: 'hm-url',- label: 'Your Home Assistant address',- hint: 'The https URL you use from outside the house: Home Assistant Cloud, or your own reverse proxy.',+ label: t('home_connect.url_label', 'Your Home Assistant address'),+ hint: t('home_connect.url_hint', 'The https URL you use from outside the house: Home Assistant Cloud, or your own reverse proxy.'),value: values.baseUrl || '',attrs: { type: 'url', inputmode: 'url', autocomplete: 'off', spellcheck: 'false', placeholder: 'https://your-home.ui.nabu.casa' },});@@ -265,7 +270,7 @@ function connectCard({ notice, values = {}, focus } = {}) {form.append(label.wrap, url.wrap, token.wrap);const actions = el('div', 'hm-actions');- const submit = el('button', 'hm-btn hm-btn-primary', 'Connect this home');+ const submit = el('button', 'hm-btn hm-btn-primary', t('home_connect.submit', 'Connect this home'));submit.type = 'submit';actions.append(submit);form.append(actions);@@ -320,14 +325,14 @@ function notFoundCard({ homes = [] } = {}) {const panel = el('section', 'hm-panel');const wrap = el('div', 'hm-empty');wrap.append(- el('p', 'hm-empty-title', 'That home is not on this account'),+ el('p', 'hm-empty-title', t('home_connect.not_yours_title', 'That home is not on this account')),el('p', 'hm-empty-body', homes.length- ? 'It may have been disconnected, or the link may belong to a different account. Your own homes are below.'- : 'It may have been disconnected, or the link may belong to a different account. You have no homes connected yet.'),+ ? t('home_connect.not_yours_body_some', 'It may have been disconnected, or the link may belong to a different account. Your own homes are below.')+ : t('home_connect.not_yours_body_none', 'It may have been disconnected, or the link may belong to a different account. You have no homes connected yet.')),);const actions = el('div', 'hm-actions');actions.style.justifyContent = 'center';- const all = el('a', 'hm-btn hm-btn-primary', homes.length ? 'See your homes' : 'Connect a home');+ const all = el('a', 'hm-btn hm-btn-primary', homes.length ? t('home_connect.see_your_homes', 'See your homes') : t('home_connect.connect_a_home', 'Connect a home'));all.href = '/smart-home';actions.append(all);wrap.append(actions);@@ -342,13 +347,13 @@ function notFoundCard({ homes = [] } = {}) {*/function quotaCard({ notice, upgrade } = {}) {const panel = el('section', 'hm-panel');- panel.append(el('h2', 'hm-panel-title', 'This account is at its home limit'));+ panel.append(el('h2', 'hm-panel-title', t('home_connect.quota_title', 'This account is at its home limit')));if (notice) panel.append(noticeEl(notice));const actions = el('div', 'hm-actions');- const up = el('a', 'hm-btn hm-btn-primary', 'See the plans');+ const up = el('a', 'hm-btn hm-btn-primary', t('home_connect.see_the_plans', 'See the plans'));up.href = typeof upgrade === 'string' && upgrade.startsWith('/') ? upgrade : '/pricing';- const back = el('button', 'hm-btn hm-btn-ghost', 'Back to my homes');+ const back = el('button', 'hm-btn hm-btn-ghost', t('home_connect.back_to_homes', 'Back to my homes'));back.type = 'button';back.addEventListener('click', () => boot());actions.append(up, back);@@ -362,21 +367,21 @@ function tokenHelp() {const wrap = el('details', 'hm-panel hm-details');wrap.style.marginTop = 'var(--space-md)';wrap.style.background = 'transparent';- const summary = el('summary', '', 'Where do I get an access token?');+ const summary = el('summary', '', t('home_connect.token_help_summary', 'Where do I get an access token?'));summary.style.cursor = 'pointer';summary.style.fontWeight = 'var(--weight-medium)';wrap.append(summary);const steps = el('ol', 'hm-ol');for (const step of [- 'Open your Home Assistant and click your user name at the bottom of the sidebar.',- 'Go to the Security tab.',- 'Scroll to Long-lived access tokens and choose Create token.',- 'Name it "three.ws" and copy the token. Home Assistant shows it once.',+ t('home_connect.token_step_1', 'Open your Home Assistant and click your user name at the bottom of the sidebar.'),+ t('home_connect.token_step_2', 'Go to the Security tab.'),+ t('home_connect.token_step_3', 'Scroll to Long-lived access tokens and choose Create token.'),+ t('home_connect.token_step_4', 'Name it "three.ws" and copy the token. Home Assistant shows it once.'),]) steps.append(el('li', '', step));wrap.append(steps);- const note = el('p', 'hm-hint', 'The token is encrypted before it is stored and is never sent back to this page. Deleting it in Home Assistant revokes our access immediately, whatever we hold.');+ const note = el('p', 'hm-hint', t('home_connect.token_help_note', 'The token is encrypted before it is stored and is never sent back to this page. Deleting it in Home Assistant revokes our access immediately, whatever we hold.'));note.style.marginTop = 'var(--space-sm)';wrap.append(note);return wrap;@@ -392,8 +397,8 @@ function tokenHelp() {function verifying({ steps = [], onCancel } = {}) {const panel = el('section', 'hm-panel');panel.append(- el('h2', 'hm-panel-title', 'Opening a connection to your home'),- el('p', 'hm-panel-sub', 'This runs against your instance directly. It usually takes a second or two.'),+ el('h2', 'hm-panel-title', t('home_connect.verifying_title', 'Opening a connection to your home')),+ el('p', 'hm-panel-sub', t('home_connect.verifying_sub', 'This runs against your instance directly. It usually takes a second or two.')),);const list = el('ul', 'hm-steps');@@ -409,7 +414,7 @@ function verifying({ steps = [], onCancel } = {}) {const actions = el('div', 'hm-actions');actions.style.marginTop = 'var(--space-md)';- const cancel = el('button', 'hm-btn hm-btn-ghost', 'Cancel');+ const cancel = el('button', 'hm-btn hm-btn-ghost', t('home_connect.cancel', 'Cancel'));cancel.type = 'button';cancel.addEventListener('click', () => onCancel && onCancel());actions.append(cancel);@@ -456,14 +461,25 @@ async function submitConnect({ form, label, url, token, submit }) {return render(STATE.EMPTY, {values: { label: values.label },focus: 'url',- notice: { tone: 'error', title: 'Add your Home Assistant address.', body: 'It is the https URL you use to reach your house from outside it.' },+ notice: {+ tone: 'error',+ title: t('home_connect.need_url_title', 'Add your Home Assistant address.'),+ body: t('home_connect.need_url_body', 'It is the https URL you use to reach your house from outside it.'),+ },});}if (!values.token) {return render(STATE.EMPTY, {values: { label: values.label, baseUrl: values.baseUrl },focus: 'token',- notice: { tone: 'error', title: 'Add a long-lived access token.', body: `Create one in Home Assistant under ${TOKEN_PATH}.` },+ notice: {+ tone: 'error',+ title: t('home_connect.need_token_title', 'Add a long-lived access token.'),+ // TOKEN_PATH is a path inside the reader's own Home Assistant, which+ // their instance shows them in their own language. Interpolated, so+ // no translation ever rewrites a navigation path.+ body: t('home_connect.need_token_body', 'Create one in Home Assistant under {{path}}.', { path: TOKEN_PATH }),+ },});}@@ -482,10 +498,10 @@ async function submitConnect({ form, label, url, token, submit }) {const controller = new AbortController();const steps = [- { text: 'Checking the address', state: 'done' },- { text: 'Opening a connection to your home', state: 'active' },- { text: 'Reading your rooms and devices', state: 'pending' },- { text: 'Checking for the Model Context Protocol server', state: 'pending' },+ { text: t('home_connect.step_address', 'Checking the address'), state: 'done' },+ { text: t('home_connect.step_connect', 'Opening a connection to your home'), state: 'active' },+ { text: t('home_connect.step_rooms', 'Reading your rooms and devices'), state: 'pending' },+ { text: t('home_connect.step_mcp', 'Checking for the Model Context Protocol server'), state: 'pending' },];render(STATE.VERIFYING, { steps, onCancel: () => controller.abort() });@@ -507,14 +523,19 @@ async function submitConnect({ form, label, url, token, submit }) {if (landed) {return renderHomes(after, {tone: 'info',- title: `${landed.label} connected anyway.`,- body: 'You cancelled while it was still verifying, but your home had already answered by then, so it is connected. Disconnect it below if that is not what you wanted.',+ // The label is the name they gave their own house.+ title: t('home_connect.landed_anyway_title', '{{home}} connected anyway.', { home: landed.label }),+ body: t('home_connect.landed_anyway_body', 'You cancelled while it was still verifying, but your home had already answered by then, so it is connected. Disconnect it below if that is not what you wanted.'),});}return render(STATE.EMPTY, {values: { label: values.label, baseUrl: values.baseUrl },focus: 'url',- notice: { tone: 'info', title: 'Cancelled.', body: 'No home was connected and no token was stored. Try again whenever you are ready.' },+ notice: {+ tone: 'info',+ title: t('home_connect.cancelled_title', 'Cancelled.'),+ body: t('home_connect.cancelled_body', 'No home was connected and no token was stored. Try again whenever you are ready.'),+ },});}renderFailure(err, values);@@ -533,8 +554,8 @@ function renderFailure(err, values) {focus: 'token',notice: {tone: 'error',- title: 'Home Assistant rejected that token.',- body: `Tokens are one per line and easy to truncate on copy. Create a fresh one under ${TOKEN_PATH}, then paste the whole string.`,+ title: t('home_connect.auth_failed_title', 'Home Assistant rejected that token.'),+ body: t('home_connect.auth_failed_body', 'Tokens are one per line and easy to truncate on copy. Create a fresh one under {{path}}, then paste the whole string.', { path: TOKEN_PATH }),},});}@@ -546,11 +567,11 @@ function renderFailure(err, values) {focus: 'url',notice: {tone: 'error',- title: 'We could not reach that address.',+ title: t('home_connect.unreachable_title', 'We could not reach that address.'),body: messageOf(err),bullets: [- 'If the address is right, check the house is online and reachable from outside your network.',- 'If it is only reachable at home, three.ws cannot route to it. The add-on that dials out from inside your network is the path for that.',+ t('home_connect.unreachable_bullet_1', 'If the address is right, check the house is online and reachable from outside your network.'),+ t('home_connect.unreachable_bullet_2', 'If it is only reachable at home, three.ws cannot route to it. The add-on that dials out from inside your network is the path for that.'),],},});@@ -560,7 +581,7 @@ function renderFailure(err, values) {return render(STATE.EMPTY, {values: carried,focus: 'url',- notice: { tone: 'error', title: 'That address does not look right.', body: messageOf(err) },+ notice: { tone: 'error', title: t('home_connect.bad_url_title', 'That address does not look right.'), body: messageOf(err) },});}@@ -575,8 +596,8 @@ function renderFailure(err, values) {title: quotaTitle(err.quota),body: messageOf(err),bullets: [- 'Disconnect a home you no longer use and this one will connect.',- 'Or move to a plan that carries more homes.',+ t('home_connect.quota_bullet_1', 'Disconnect a home you no longer use and this one will connect.'),+ t('home_connect.quota_bullet_2', 'Or move to a plan that carries more homes.'),],},upgrade: err.quota.upgrade || '/pricing',@@ -586,14 +607,15 @@ function renderFailure(err, values) {return render(STATE.EMPTY, {values: carried,focus: 'url',- notice: { tone: 'error', title: 'That did not work.', body: messageOf(err) },+ notice: { tone: 'error', title: t('home_connect.generic_failed', 'That did not work.'), body: messageOf(err) },});}function quotaTitle(quota) {const limit = Number(quota?.limit);- if (!Number.isFinite(limit)) return 'Your plan is at its limit for homes.';- return `Your plan covers ${limit} ${limit === 1 ? 'home' : 'homes'}.`;+ if (!Number.isFinite(limit)) return t('home_connect.quota_title_unknown', 'Your plan is at its limit for homes.');+ // One home and many homes are two catalog keys, not an English "s".+ return plural('home_connect.quota_title_n', limit, 'Your plan covers {{count}} home.', 'Your plan covers {{count}} homes.');}/**@@ -642,8 +664,12 @@ export function checkReachable(input) {} catch (err) {return {ok: false,- short: 'That is not a web address we can use.',- notice: { tone: 'error', title: 'That address does not look right.', body: err?.message || 'Use the full https URL of your Home Assistant.' },+ short: t('home_connect.not_a_url_short', 'That is not a web address we can use.'),+ notice: {+ tone: 'error',+ title: t('home_connect.bad_url_title', 'That address does not look right.'),+ body: err?.message || t('home_connect.bad_url_body', 'Use the full https URL of your Home Assistant.'),+ },};}@@ -651,16 +677,17 @@ export function checkReachable(input) {if (isPrivateHost(host) && !parsed.loopback) {return {ok: false,- short: `${host} is only on your home network.`,+ // The host is what they typed. It is echoed back, never translated.+ short: t('home_connect.private_host_short', '{{host}} is only on your home network.', { host }),notice: {tone: 'warn',- title: `${host} is an address on your home network.`,- body: 'three.ws runs on the public internet, so it cannot reach an address that only exists inside your house. There are two real ways round it.',+ title: t('home_connect.private_host_title', '{{host}} is an address on your home network.', { host }),+ body: t('home_connect.private_host_body', 'three.ws runs on the public internet, so it cannot reach an address that only exists inside your house. There are two real ways round it.'),bullets: [- 'Use your remote https address instead. Home Assistant Cloud gives you one, and so does your own reverse proxy. That works today, with the token you already have.',- 'Or let your house dial out to three.ws instead, with the button below. One small integration inside Home Assistant, no port forwarded, and no Home Assistant token stored here at all.',+ t('home_connect.private_host_bullet_1', 'Use your remote https address instead. Home Assistant Cloud gives you one, and so does your own reverse proxy. That works today, with the token you already have.'),+ t('home_connect.private_host_bullet_2', 'Or let your house dial out to three.ws instead, with the button below. One small integration inside Home Assistant, no port forwarded, and no Home Assistant token stored here at all.'),],- action: { label: 'Connect a home that is only on my network', onClick: () => render(STATE.PAIRING) },+ action: { label: t('home_connect.private_host_action', 'Connect a home that is only on my network'), onClick: () => render(STATE.PAIRING) },},};}@@ -671,11 +698,11 @@ export function checkReachable(input) {if (!parsed.secure && !parsed.loopback) {return {ok: false,- short: 'A plain http address cannot be reached from this page.',+ short: t('home_connect.insecure_short', 'A plain http address cannot be reached from this page.'),notice: {tone: 'warn',- title: 'That is a plain http address.',- body: 'This page is served over https, and a browser will not open an unencrypted connection from it. Use the https address for your house.',+ title: t('home_connect.insecure_title', 'That is a plain http address.'),+ body: t('home_connect.insecure_body', 'This page is served over https, and a browser will not open an unencrypted connection from it. Use the https address for your house.'),},};}@@ -720,8 +747,8 @@ async function disconnect(home) {const homes = await listHomes();const notice = {tone: 'ok',- title: `${home.label} is disconnected.`,- body: 'The access token we held has been erased. Delete the token in Home Assistant too if you want it gone on both sides, under ' + TOKEN_PATH + '.',+ title: t('home_connect.disconnected_title', '{{home}} is disconnected.', { home: home.label }),+ body: t('home_connect.disconnected_body', 'The access token we held has been erased. Delete the token in Home Assistant too if you want it gone on both sides, under {{path}}.', { path: TOKEN_PATH }),};if (homes && homes.length) render(listState(homes), { homes, notice });else render(STATE.REVOKED, { notice });@@ -863,7 +890,7 @@ function setInlineError(f, message) {*/function tokenField(value) {const wrap = el('div', 'hm-field');- const labelEl = el('label', 'hm-label', 'Long-lived access token');+ const labelEl = el('label', 'hm-label', t('home_connect.token_label', 'Long-lived access token'));labelEl.htmlFor = 'hm-token';const shell = el('div', 'hm-secret');@@ -877,19 +904,19 @@ function tokenField(value) {input.setAttribute('spellcheck', 'false');input.setAttribute('placeholder', 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...');- const toggle = el('button', 'hm-reveal', 'Show');+ const toggle = el('button', 'hm-reveal', t('home_connect.token_show', 'Show'));toggle.type = 'button';toggle.setAttribute('aria-pressed', 'false');toggle.addEventListener('click', () => {const revealed = input.type === 'text';input.type = revealed ? 'password' : 'text';- toggle.textContent = revealed ? 'Show' : 'Hide';+ toggle.textContent = revealed ? t('home_connect.token_show', 'Show') : t('home_connect.token_hide', 'Hide');toggle.setAttribute('aria-pressed', String(!revealed));input.focus();});shell.append(input, toggle);- const hintEl = el('p', 'hm-hint', 'Sent to three.ws once, encrypted at rest, and never returned to this page or saved in this browser.');+ const hintEl = el('p', 'hm-hint', t('home_connect.token_hint', 'Sent to three.ws once, encrypted at rest, and never returned to this page or saved in this browser.'));hintEl.id = 'hm-token-hint';input.setAttribute('aria-describedby', hintEl.id);wrap.append(labelEl, shell, hintEl);diff --git a/src/home/floorplan.js b/src/home/floorplan.jsindex 226e968cd..02786c880 100644--- a/src/home/floorplan.js+++ b/src/home/floorplan.js@@ -17,6 +17,10 @@import { assignEntityArea, clearLayout, createArea, getLayout, HomeApiError, saveLayout } from './api.js';import { clear, el, noticeEl } from './connect.js';+// Every string a person reads in this editor goes through here. Room names and+// device names never do: they are the user's own words, interpolated as values+// so the translation model only ever sees {{name}}. See i18n-home.js.+import { formatNumber, plural, t } from './i18n-home.js';/** Metres per grid square. Matches the scene's CELL so the two read alike. */const GRID_M = 1.2;@@ -216,7 +220,11 @@ export function mountFloorplan({ mount, homeId, graph, canEdit = true, onChangestate.version = res.version;state.orphaned = res.orphaned || [];state.unplaced = res.unplaced || [];- state.notice = { tone: 'ok', title: 'Floorplan saved', body: 'Your 3D home follows this plan now.' };+ state.notice = {+ tone: 'ok',+ title: t('home_floorplan.saved_title', 'Floorplan saved'),+ body: t('home_floorplan.saved_body', 'Your 3D home follows this plan now.'),+ };state.history.length = 0;state.future.length = 0;} catch (err) {@@ -248,7 +256,11 @@ export function mountFloorplan({ mount, homeId, graph, canEdit = true, onChangestate.conflict = null;state.history.length = 0;state.future.length = 0;- state.notice = { tone: 'info', title: 'Loaded the other version', body: 'Your changes were not saved. Redraw and save again if you still want them.' };+ state.notice = {+ tone: 'info',+ title: t('home_floorplan.took_theirs_title', 'Loaded the other version'),+ body: t('home_floorplan.took_theirs_body', 'Your changes were not saved. Redraw and save again if you still want them.'),+ };render();onChange?.(toDocument());}@@ -264,7 +276,11 @@ export function mountFloorplan({ mount, homeId, graph, canEdit = true, onChangestate.orphaned = [];state.history.length = 0;state.future.length = 0;- state.notice = { tone: 'info', title: 'Back to the default arrangement', body: 'Rooms pack into a grid per floor until you draw a plan again.' };+ state.notice = {+ tone: 'info',+ title: t('home_floorplan.reset_title', 'Back to the default arrangement'),+ body: t('home_floorplan.reset_body', 'Rooms pack into a grid per floor until you draw a plan again.'),+ };} catch (err) {state.error = describeError(err);} finally {@@ -283,15 +299,17 @@ export function mountFloorplan({ mount, homeId, graph, canEdit = true, onChangeawait assignEntityArea(homeId, { entityId, areaId });state.notice = {tone: 'ok',- title: `${entityId} is in ${nameOf(areaId)} now`,- body: 'That was written to your Home Assistant, so it shows up in your dashboards and voice assistant too.',+ // Both names are the house's own: the entity id and the room the+ // user named. Interpolated, never part of the source string.+ title: t('home_floorplan.filed_title', '{{device}} is in {{room}} now', { device: entityId, room: nameOf(areaId) }),+ body: t('home_floorplan.filed_body', 'That was written to your Home Assistant, so it shows up in your dashboards and voice assistant too.'),};onChange?.(toDocument(), { refreshGraph: true });} catch (err) {// State 9: the local plan is untouched and the failure is named. A// YAML entity has no registry entry and cannot be filed, which is// common and needs a sentence rather than a stack trace.- state.notice = { tone: 'error', title: 'Could not file that device', body: describeError(err).body };+ state.notice = { tone: 'error', title: t('home_floorplan.file_failed', 'Could not file that device'), body: describeError(err).body };}render();}@@ -326,8 +344,16 @@ export function mountFloorplan({ mount, homeId, graph, canEdit = true, onChangestate.creating = false;placeRoom(area.id);state.notice = area.created- ? { tone: 'ok', title: `${area.name} is a room in your home now`, body: 'It was made in your Home Assistant, so you can file devices into it here and use it there.' }- : { tone: 'info', title: `${area.name} already existed`, body: 'It is on the plan now.' };+ ? {+ tone: 'ok',+ title: t('home_floorplan.room_made_title', '{{room}} is a room in your home now', { room: area.name }),+ body: t('home_floorplan.room_made_body', 'It was made in your Home Assistant, so you can file devices into it here and use it there.'),+ }+ : {+ tone: 'info',+ title: t('home_floorplan.room_existed_title', '{{room}} already existed', { room: area.name }),+ body: t('home_floorplan.room_existed_body', 'It is on the plan now.'),+ };render();onChange?.(toDocument(), { refreshGraph: true });@@ -350,13 +376,13 @@ export function mountFloorplan({ mount, homeId, graph, canEdit = true, onChangeclear(view);if (state.loading) return view.append(skeleton());- if (state.error) return view.append(noticeEl({ tone: 'error', ...state.error, action: { label: 'Try again', onClick: load } }));+ if (state.error) return view.append(noticeEl({ tone: 'error', ...state.error, action: { label: t('home_floorplan.try_again', 'Try again'), onClick: load } }));if (state.unreadable) {view.append(noticeEl({tone: 'error',- title: 'This floorplan could not be read',- body: `${state.unreadable} The 3D home is using its default arrangement. Drawing and saving replaces the stored plan.`,+ title: t('home_floorplan.unreadable_title', 'This floorplan could not be read'),+ body: t('home_floorplan.unreadable_body', '{{reason}} The 3D home is using its default arrangement. Drawing and saving replaces the stored plan.', { reason: state.unreadable }),}));}if (state.notice) view.append(noticeEl(state.notice));@@ -371,22 +397,27 @@ export function mountFloorplan({ mount, homeId, graph, canEdit = true, onChangefunction toolbar() {const bar = el('div', 'hm-plan-toolbar');bar.setAttribute('role', 'toolbar');- bar.setAttribute('aria-label', 'Floorplan');+ bar.setAttribute('aria-label', t('home_floorplan.toolbar_aria', 'Floorplan'));if (!canEdit) {// State 8: read only. The plan is still worth seeing.- bar.append(el('p', 'hm-plan-readonly', 'You can see this floorplan. Editing it needs the owner or an admin.'));+ bar.append(el('p', 'hm-plan-readonly', t('home_floorplan.readonly', 'You can see this floorplan. Editing it needs the owner or an admin.')));return bar;}- bar.append(button('Undo', undo, { disabled: !state.history.length, key: 'Ctrl+Z' }));- bar.append(button('Redo', redo, { disabled: !state.future.length, key: 'Ctrl+Shift+Z' }));- bar.append(button('New room', () => openNaming(), { disabled: state.creating }));+ bar.append(button(t('home_floorplan.undo', 'Undo'), undo, { disabled: !state.history.length, key: 'Ctrl+Z' }));+ bar.append(button(t('home_floorplan.redo', 'Redo'), redo, { disabled: !state.future.length, key: 'Ctrl+Shift+Z' }));+ bar.append(button(t('home_floorplan.new_room', 'New room'), () => openNaming(), { disabled: state.creating }));const dirty = state.history.length > 0;- bar.append(button(state.saving ? 'Saving' : 'Save floorplan', save, { primary: true, disabled: state.saving || !dirty }));- bar.append(button('Reset to default', resetPlan, { disabled: state.saving || !state.rooms.size }));-- const count = el('span', 'hm-plan-count', `${state.rooms.size} placed, ${state.unplaced.length} to place`);+ bar.append(button(state.saving ? t('home_floorplan.saving', 'Saving') : t('home_floorplan.save', 'Save floorplan'), save, { primary: true, disabled: state.saving || !dirty }));+ bar.append(button(t('home_floorplan.reset', 'Reset to default'), resetPlan, { disabled: state.saving || !state.rooms.size }));++ // Two counts in one sentence, so it is one translatable string rather+ // than two fragments a translator cannot order for their own language.+ const count = el('span', 'hm-plan-count', t('home_floorplan.count', '{{placed}} placed, {{toPlace}} to place', {+ placed: formatNumber(state.rooms.size),+ toPlace: formatNumber(state.unplaced.length),+ }));count.setAttribute('aria-live', 'polite');bar.append(count);return bar;@@ -410,12 +441,12 @@ export function mountFloorplan({ mount, homeId, graph, canEdit = true, onChange*/function namingForm() {const form = el('form', 'hm-plan-naming');- form.setAttribute('aria-label', 'Make a new room');+ form.setAttribute('aria-label', t('home_floorplan.naming_aria', 'Make a new room'));const id = `hm-plan-newroom-${Math.random().toString(36).slice(2, 8)}`;const label = el('label', null, state.naming.thenFile- ? `Name a room for ${state.naming.thenFile}`- : 'Name the new room');+ ? t('home_floorplan.name_room_for', 'Name a room for {{device}}', { device: state.naming.thenFile })+ : t('home_floorplan.name_new_room', 'Name the new room'));label.htmlFor = id;form.append(label);@@ -425,7 +456,9 @@ export function mountFloorplan({ mount, homeId, graph, canEdit = true, onChangeinput.maxLength = 64;input.required = true;input.autocomplete = 'off';- input.placeholder = 'Kitchen';+ // A placeholder is an example, so it is translated: a French reader is+ // shown a French room, not the English word for one.+ input.placeholder = t('home_floorplan.name_placeholder', 'Kitchen');// Survives the re-render a refusal causes, so the name is theirs to fix// rather than to retype.input.value = state.naming.value || '';@@ -433,12 +466,12 @@ export function mountFloorplan({ mount, homeId, graph, canEdit = true, onChangeform.append(input);const actions = el('div', 'hm-plan-naming-actions');- const submit = el('button', 'hm-plan-btn is-primary', state.creating ? 'Making' : 'Make this room');+ const submit = el('button', 'hm-plan-btn is-primary', state.creating ? t('home_floorplan.making', 'Making') : t('home_floorplan.make_this_room', 'Make this room'));submit.type = 'submit';submit.disabled = state.creating;actions.append(submit);- const cancel = el('button', 'hm-plan-btn', 'Cancel');+ const cancel = el('button', 'hm-plan-btn', t('home_floorplan.cancel', 'Cancel'));cancel.type = 'button';cancel.disabled = state.creating;cancel.addEventListener('click', () => { state.naming = null; render(); });@@ -455,7 +488,7 @@ export function mountFloorplan({ mount, homeId, graph, canEdit = true, onChangee.preventDefault();const name = input.value.trim();if (!name) {- state.naming = { ...state.naming, error: 'Give the room a name, like Kitchen.', value: input.value };+ state.naming = { ...state.naming, error: t('home_floorplan.name_required', 'Give the room a name, like Kitchen.'), value: input.value };return render();}createRoom(name);@@ -466,11 +499,15 @@ export function mountFloorplan({ mount, homeId, graph, canEdit = true, onChangefunction conflictPanel() {const wrap = el('div', 'hm-plan-conflict');wrap.setAttribute('role', 'alertdialog');- wrap.append(el('h3', null, 'Someone else changed this floorplan'));- wrap.append(el('p', null, `They saved version ${state.conflict.theirs?.version ?? '?'} while you were drawing. Nothing is lost yet: pick which one to keep.`));+ wrap.append(el('h3', null, t('home_floorplan.conflict_title', 'Someone else changed this floorplan')));+ wrap.append(el('p', null, t(+ 'home_floorplan.conflict_body',+ 'They saved version {{version}} while you were drawing. Nothing is lost yet: pick which one to keep.',+ { version: state.conflict.theirs?.version === undefined ? '?' : formatNumber(state.conflict.theirs.version) },+ )));const actions = el('div', 'hm-plan-conflict-actions');- actions.append(button('Keep mine', keepMine, { primary: true }));- actions.append(button('Take theirs', takeTheirs));+ actions.append(button(t('home_floorplan.keep_mine', 'Keep mine'), keepMine, { primary: true }));+ actions.append(button(t('home_floorplan.take_theirs', 'Take theirs'), takeTheirs));wrap.append(actions);return wrap;}@@ -481,7 +518,7 @@ export function mountFloorplan({ mount, homeId, graph, canEdit = true, onChangeconst wrap = el('div', 'hm-plan-canvas');wrap.tabIndex = 0;wrap.setAttribute('role', 'application');- wrap.setAttribute('aria-label', 'Floorplan. Arrow keys move the selected room, plus and minus resize it.');+ wrap.setAttribute('aria-label', t('home_floorplan.canvas_aria', 'Floorplan. Arrow keys move the selected room, plus and minus resize it.'));if (!rooms.length) {// States 1 and 2: nothing placed. Which message depends on whether the@@ -490,13 +527,13 @@ export function mountFloorplan({ mount, homeId, graph, canEdit = true, onChangewrap.append(noticeEl(live.length? {tone: 'info',- title: 'No plan yet',- body: 'Your 3D home is using a default grid. Place a room below to start drawing the real thing.',+ title: t('home_floorplan.empty_title', 'No plan yet'),+ body: t('home_floorplan.empty_body', 'Your 3D home is using a default grid. Place a room below to start drawing the real thing.'),}: {tone: 'info',- title: 'Nothing is filed into a room yet',- body: 'Home Assistant has no areas for this house. Make a room below, then drag your devices into it: that writes the room into your Home Assistant, not just here.',+ title: t('home_floorplan.no_areas_title', 'Nothing is filed into a room yet'),+ body: t('home_floorplan.no_areas_body', 'Home Assistant has no areas for this house. Make a room below, then drag your devices into it: that writes the room into your Home Assistant, not just here.'),}));return wrap;}@@ -524,19 +561,24 @@ export function mountFloorplan({ mount, homeId, graph, canEdit = true, onChangenode.style.height = `${d * PX_PER_M}px`;node.tabIndex = 0;node.setAttribute('role', 'button');- node.setAttribute('aria-label', `${nameOf(id)}, ${w} by ${d} metres${orphan ? ', no longer in this home' : ''}`);+ // The room's own name is the user's word, interpolated. The size is+ // formatted for the reader's locale, so 5,7 in French and 5.7 in English.+ node.setAttribute('aria-label', orphan+ ? t('home_floorplan.room_aria_orphan', '{{room}}, {{w}} by {{d}} metres, no longer in this home', { room: nameOf(id), w: formatNumber(w), d: formatNumber(d) })+ : t('home_floorplan.room_aria', '{{room}}, {{w}} by {{d}} metres', { room: nameOf(id), w: formatNumber(w), d: formatNumber(d) }));node.setAttribute('aria-pressed', String(state.selected === id));node.append(el('span', 'hm-plan-room-name', nameOf(id)));- node.append(el('span', 'hm-plan-room-size', `${w} x ${d} m`));+ node.append(el('span', 'hm-plan-room-size', t('home_floorplan.room_size', '{{w}} x {{d}} m', { w: formatNumber(w), d: formatNumber(d) })));if (orphan) {// State 6: the area was deleted in Home Assistant. Never crash, never// silently discard the rest of somebody's plan.- const drop = el('button', 'hm-plan-room-drop', 'Remove');+ const drop = el('button', 'hm-plan-room-drop', t('home_floorplan.remove', 'Remove'));drop.type = 'button';+ drop.setAttribute('aria-label', t('home_floorplan.remove_aria', 'Remove {{room}} from the plan', { room: nameOf(id) }));drop.addEventListener('click', (e) => { e.stopPropagation(); removeRoom(id); });- node.append(el('span', 'hm-plan-room-tag', 'not in this home'));+ node.append(el('span', 'hm-plan-room-tag', t('home_floorplan.orphan_tag', 'not in this home')));node.append(drop);}@@ -559,7 +601,7 @@ export function mountFloorplan({ mount, homeId, graph, canEdit = true, onChangefunction resizeHandle(id, room) {const handle = el('button', 'hm-plan-handle');handle.type = 'button';- handle.setAttribute('aria-label', `Resize ${nameOf(id)}`);+ handle.setAttribute('aria-label', t('home_floorplan.resize_aria', 'Resize {{room}}', { room: nameOf(id) }));handle.addEventListener('pointerdown', (e) => {e.stopPropagation();const start = { x: e.clientX, y: e.clientY, w: room.w ?? DEFAULT_SIZE, d: room.d ?? DEFAULT_SIZE };@@ -623,14 +665,14 @@ export function mountFloorplan({ mount, homeId, graph, canEdit = true, onChangefunction tray() {const wrap = el('div', 'hm-plan-tray');- wrap.append(el('h3', 'hm-plan-tray-title', 'To place'));+ wrap.append(el('h3', 'hm-plan-tray-title', t('home_floorplan.tray_title', 'To place')));// State 2. A house with no areas has nothing to arrange, and the honest// answer is not an empty panel: it is the first room.if (canEdit && !liveRoomIds().some((id) => !id.startsWith('__'))) {const start = el('div', 'hm-plan-tray-start');- start.append(el('p', null, 'Nothing in this home is in a room yet. Make the first one and the plan starts here.'));- start.append(button('Make a room', () => openNaming()));+ start.append(el('p', null, t('home_floorplan.first_room_body', 'Nothing in this home is in a room yet. Make the first one and the plan starts here.')));+ start.append(button(t('home_floorplan.make_a_room', 'Make a room'), () => openNaming()));wrap.append(start);}@@ -648,15 +690,23 @@ export function mountFloorplan({ mount, homeId, graph, canEdit = true, onChange}wrap.append(list);} else {- wrap.append(el('p', 'hm-plan-tray-empty', 'Every room in this home is on the plan.'));+ wrap.append(el('p', 'hm-plan-tray-empty', t('home_floorplan.tray_empty', 'Every room in this home is on the plan.')));}const loose = graph?.unassigned || [];if (loose.length) {- wrap.append(el('h3', 'hm-plan-tray-title', `${loose.length} device${loose.length === 1 ? '' : 's'} not in a room`));+ // One device and many devices are two catalog keys, not an English+ // "s" appended in code: a language with three plural forms cannot be+ // served by a ternary here.+ wrap.append(el('h3', 'hm-plan-tray-title', plural(+ 'home_floorplan.loose_count',+ loose.length,+ '{{count}} device not in a room',+ '{{count}} devices not in a room',+ )));wrap.append(el('p', 'hm-plan-tray-hint', canEdit- ? 'Drag one onto a room. That files it in your Home Assistant, so it shows up in your dashboards and voice assistant too.'- : 'Filing a device into a room needs the owner or an admin.'));+ ? t('home_floorplan.tray_hint', 'Drag one onto a room. That files it in your Home Assistant, so it shows up in your dashboards and voice assistant too.')+ : t('home_floorplan.tray_hint_readonly', 'Filing a device into a room needs the owner or an admin.')));const list = el('ul', 'hm-plan-tray-entities');for (const entity of loose.slice(0, 200)) {const li = el('li', 'hm-plan-tray-entity');@@ -666,16 +716,16 @@ export function mountFloorplan({ mount, homeId, graph, canEdit = true, onChangeli.draggable = true;li.addEventListener('dragstart', (e) => e.dataTransfer?.setData('text/entity-id', entity.entityId));// Keyboard parity: dragging is not the only way in.- const pick = el('button', 'hm-plan-tray-file', 'File');+ const pick = el('button', 'hm-plan-tray-file', t('home_floorplan.file', 'File'));pick.type = 'button';- pick.setAttribute('aria-label', `File ${entity.name || entity.entityId} into a room`);+ pick.setAttribute('aria-label', t('home_floorplan.file_aria', 'File {{device}} into a room', { device: entity.name || entity.entityId }));pick.addEventListener('click', () => fileByPrompt(entity.entityId));li.append(pick);}list.append(li);}wrap.append(list);- if (loose.length > 200) wrap.append(el('p', 'hm-plan-tray-hint', `Showing the first 200 of ${loose.length}.`));+ if (loose.length > 200) wrap.append(el('p', 'hm-plan-tray-hint', t('home_floorplan.tray_truncated', 'Showing the first 200 of {{total}}.', { total: formatNumber(loose.length) })));}return wrap;}@@ -725,7 +775,7 @@ export function mountFloorplan({ mount, homeId, graph, canEdit = true, onChangefunction skeleton() {const s = el('div', 'hm-plan-skeleton');s.setAttribute('aria-busy', 'true');- s.setAttribute('aria-label', 'Loading the floorplan');+ s.setAttribute('aria-label', t('home_floorplan.loading_aria', 'Loading the floorplan'));for (let i = 0; i < 4; i += 1) s.append(el('div', 'hm-plan-skeleton-room'));return s;}@@ -733,9 +783,17 @@ export function mountFloorplan({ mount, homeId, graph, canEdit = true, onChangefunction describeError(err) {if (err instanceof HomeApiError) {- return { title: err.code === 'not_found' ? 'This home is not available' : 'Something went wrong', body: err.message };+ return {+ title: err.code === 'not_found'+ ? t('home_floorplan.err_not_found', 'This home is not available')+ : t('home_floorplan.err_generic', 'Something went wrong'),+ body: err.message,+ };}- return { title: 'Something went wrong', body: err?.message || 'Try again in a moment.' };+ return {+ title: t('home_floorplan.err_generic', 'Something went wrong'),+ body: err?.message || t('home_floorplan.err_retry', 'Try again in a moment.'),+ };}/** Grid snap, in metres. */