You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit a92c348
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: .roo/rules-translate/001-general-rules.md
+5-1Lines changed: 5 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -30,7 +30,10 @@
30
30
# 4. WEBVIEW UI LOCALIZATION (webview-ui/src/)
31
31
32
32
- Located in webview-ui/src/i18n/locales/
33
-
- Uses standard React i18next patterns with the useTranslation hook
33
+
- Use react-i18next's `useTranslation` and `Trans` (`import { Trans, useTranslation } from "react-i18next"`):
34
+
- Always pass the component's `t` to `Trans` (`<Trans t={t} i18nKey="..." />`); `Trans` does not follow language changes on its own (ESLint enforces this)
35
+
- Never use the global `t` from `i18next` (`i18next.t`); memoized output would keep showing the previous language after a switch (ESLint enforces this). Pass `t` to helpers instead, as `utils/format.ts` and `utils/validate.ts` do
36
+
-`useTranslation()` takes fully qualified keys (`t("chat:about")`); `useTranslation("chat")` also takes keys relative to that namespace (`t("about")`); fully qualified keys still work
34
37
- All user interface strings should be internationalized
35
38
- Always use the Trans component with named components for text with embedded components
|**WebView UI**|`webview-ui/src/i18n/locales/`| User interface strings|
36
36
37
37
## Brand Voice, Tone, and Word Choice
38
38
@@ -70,24 +70,30 @@ This guidance file is loaded at runtime and should be consulted for the latest b
70
70
## WebView UI Localization (webview-ui/src/)
71
71
72
72
- Located in `webview-ui/src/i18n/locales/`
73
-
- Uses standard React i18next patterns with the `useTranslation` hook
73
+
- Use react-i18next's `useTranslation` and `Trans` (`import { Trans, useTranslation } from "react-i18next"`):
74
+
- Always pass the component's `t` to `Trans` (`<Trans t={t} i18nKey="..." />`); `Trans` does not follow language changes on its own (ESLint enforces this)
75
+
- Never use the global `t` from `i18next` (`i18next.t`); memoized output would keep showing the previous language after a switch (ESLint enforces this). Pass `t` to helpers instead, as `utils/format.ts` and `utils/validate.ts` do
76
+
-`useTranslation()` takes fully qualified keys (`t("chat:about")`); `useTranslation("chat")` also takes keys relative to that namespace (`t("about")`); fully qualified keys still work
74
77
- All user interface strings should be internationalized
75
78
- Always use the `Trans` component with named components for text with embedded components
76
79
77
80
### Trans Component Example
78
81
79
82
Translation string:
83
+
80
84
```json
81
85
"changeSettings": "You can always change this at the bottom of the <settingsLink>settings</settingsLink>"
1. First add or modify English strings, then ask for confirmation before translating to all other languages
107
113
2. Use this process for each localization task:
108
-
1. Identify where the string appears in the UI/codebase
109
-
2. Understand the context and purpose of the string
110
-
3. Update English translation first
111
-
4. Use the `search_files` tool to find JSON keys that are near new keys in English translations but do not yet exist in the other language files for `apply_diff` SEARCH context
112
-
5. Create appropriate translations for all other supported languages utilizing the `search_files` result using `apply_diff` without reading every file
113
-
6. Do not output the translated text into the chat, just modify the files
114
-
7. Validate your changes with the missing translations script
114
+
1. Identify where the string appears in the UI/codebase
115
+
2. Understand the context and purpose of the string
116
+
3. Update English translation first
117
+
4. Use the `search_files` tool to find JSON keys that are near new keys in English translations but do not yet exist in the other language files for `apply_diff` SEARCH context
118
+
5. Create appropriate translations for all other supported languages utilizing the `search_files` result using `apply_diff` without reading every file
119
+
6. Do not output the translated text into the chat, just modify the files
120
+
7. Validate your changes with the missing translations script
115
121
116
122
3. Flag or comment if an English source string is incomplete ("please see this...") to avoid truncated or unclear translations
117
123
118
124
4. For UI elements, distinguish between:
119
-
- Button labels: Use short imperative commands ("Save", "Cancel")
120
-
- Tooltip text: Can be slightly more descriptive
125
+
- Button labels: Use short imperative commands ("Save", "Cancel")
126
+
- Tooltip text: Can be slightly more descriptive
121
127
122
128
5. Preserve the original perspective: If text is a user command directed at the software, ensure the translation maintains this direction
0 commit comments