Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

fix(chat): replace hardcoded English strings with i18n keys (#4452)

Cindy Zhang269a2817a0df
diff --git a/packages/core/locales/en.json b/packages/core/locales/en.json
index c93740f3da..632847d510 100644
--- a/packages/core/locales/en.json
+++ b/packages/core/locales/en.json
@@ -647,6 +647,14 @@
"defaultMessage": "Collapse {label}",
"description": "Screen-reader-only label on the ChatComposerDrawer toggle when the drawer is expanded. Example: `Collapse Attachments`. Pairs with `expand`."
},
+ "@astryx.chatDictationButton.startDictation": {
+ "defaultMessage": "Start dictation",
+ "description": "Accessible label for the microphone button when idle (not listening)."
+ },
+ "@astryx.chatDictationButton.stopDictation": {
+ "defaultMessage": "Stop dictation",
+ "description": "Accessible label for the microphone button when actively listening."
+ },
"@astryx.chatLayout.newMessages": {
"defaultMessage": "New messages",
"description": "Text on a floating pill at the bottom of a chat viewport when unseen messages arrive below the fold; clicking scrolls to bottom. Keep short — narrow pill."
@@ -667,6 +675,14 @@
"defaultMessage": "Send",
"description": "Primary button label on the chat submit button (paperplane icon). Imperative verb; pairs with `Stop`. Very short."
},
+ "@astryx.chatToolCalls.error": {
+ "defaultMessage": "Error: {message}",
+ "description": "Screen-reader text for a tool call that failed. {message} is the error detail."
+ },
+ "@astryx.chatToolCalls.groupLabel": {
+ "defaultMessage": "{count} tool calls",
+ "description": "Summary label shown in the group header when multiple tool calls are expanded. {count} is the number of calls."
+ },
"@astryx.chatTriggerMenu.suggestions": {
"defaultMessage": "Suggestions",
"description": "Screen-reader-only fallback label for the popover listbox opened by a trigger character (`@`, `/`) in the chat composer when the trigger provides no specific label."
diff --git a/packages/core/src/Chat/ChatDictationButton.tsx b/packages/core/src/Chat/ChatDictationButton.tsx
index f8fb838dcc..451d0aa2ed 100644
--- a/packages/core/src/Chat/ChatDictationButton.tsx
+++ b/packages/core/src/Chat/ChatDictationButton.tsx
@@ -26,6 +26,7 @@ import {Button} from '../Button';
import {Icon} from '../Icon';
import {mergeProps} from '../utils';
import type {BaseProps} from '../BaseProps';
+import {useTranslator} from '../i18n';
// =============================================================================
// Types
@@ -110,13 +111,18 @@ export function ChatDictationButton({
style,
...rest
}: ChatDictationButtonProps) {
+ const t = useTranslator();
+
if (isHiddenWhenUnsupported && !dictation.isSupported) {
return null;
}
const {isListening, bands, volume: rawVolume} = dictation;
const accessibleLabel =
- label ?? (isListening ? 'Stop dictation' : 'Start dictation');
+ label ??
+ (isListening
+ ? t('@astryx.chatDictationButton.stopDictation')
+ : t('@astryx.chatDictationButton.startDictation'));
// Boost each band for visibility — quiet speech (0-10%) maps to full visual range
const boostedBands = bands.map(b => Math.min(Math.pow(b / 0.2, 0.5), 1));
diff --git a/packages/core/src/Chat/ChatToolCalls.tsx b/packages/core/src/Chat/ChatToolCalls.tsx
index f764863c66..234a2e4f42 100644
--- a/packages/core/src/Chat/ChatToolCalls.tsx
+++ b/packages/core/src/Chat/ChatToolCalls.tsx
@@ -37,6 +37,7 @@ import {Icon, type IconName} from '../Icon';
import {Spinner} from '../Spinner';
import {VisuallyHidden} from '../VisuallyHidden';
import {themeProps} from '../utils/themeProps';
+import {useTranslator} from '../i18n';
// =============================================================================
// Types
@@ -363,6 +364,7 @@ function getToolCallKey(call: ChatToolCallItem): string {
// =============================================================================
function CallRow({call}: {call: ChatToolCallItem}) {
+ const t = useTranslator();
const status = call.status ?? 'complete';
const hasDetail = call.resultDetail != null;
const [isDetailOpen, setIsDetailOpen] = useState(false);
@@ -414,7 +416,11 @@ function CallRow({call}: {call: ChatToolCallItem}) {
// as real text so it reaches screen readers, keyboard, and touch
// users. Rendering it inside the row also folds it into the
// accessible name of expandable (role="button") rows.
- <VisuallyHidden>{`Error: ${call.errorMessage}`}</VisuallyHidden>
+ <VisuallyHidden>
+ {t('@astryx.chatToolCalls.error', {
+ message: call.errorMessage ?? '',
+ })}
+ </VisuallyHidden>
)}
</span>
<span {...stylex.props(styles.callName)}>{call.name}</span>
@@ -498,6 +504,7 @@ function CallRow({call}: {call: ChatToolCallItem}) {
* ```
*/
export function ChatToolCalls(props: ChatToolCallsProps) {
+ const t = useTranslator();
const {
calls,
label: _customLabel,
@@ -580,7 +587,7 @@ export function ChatToolCalls(props: ChatToolCallsProps) {
<Icon icon="wrench" size="sm" color="inherit" />
</span>
<span {...stylex.props(styles.groupLabel)}>
- {calls.length} tool calls
+ {t('@astryx.chatToolCalls.groupLabel', {count: calls.length})}
</span>
</>
) : (