Skip to content

Commit 9f907ee

Browse files
committed
Update translations
1 parent cff1893 commit 9f907ee

File tree

20 files changed

+409
-10
lines changed

20 files changed

+409
-10
lines changed

webview-ui/src/components/settings/providers/HuggingFace.tsx

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,14 @@ export const HuggingFace = ({ apiConfiguration, setApiConfigurationField }: Hugg
154154
<div className="flex flex-col gap-2">
155155
<label className="block font-medium text-sm">
156156
{t("settings:providers.huggingFaceModelId")}
157-
{loading && <span className="text-xs text-gray-400 ml-2">Loading...</span>}
158-
{!loading && <span className="text-xs text-gray-400 ml-2">({models.length} models)</span>}
157+
{loading && (
158+
<span className="text-xs text-gray-400 ml-2">{t("settings:providers.huggingFaceLoading")}</span>
159+
)}
160+
{!loading && (
161+
<span className="text-xs text-gray-400 ml-2">
162+
{t("settings:providers.huggingFaceModelsCount", { count: models.length })}
163+
</span>
164+
)}
159165
</label>
160166

161167
<SearchableSelect
@@ -167,31 +173,31 @@ export const HuggingFace = ({ apiConfiguration, setApiConfigurationField }: Hugg
167173
label: model.id,
168174
}),
169175
)}
170-
placeholder="Select a model..."
171-
searchPlaceholder="Search models..."
172-
emptyMessage="No models found"
176+
placeholder={t("settings:providers.huggingFaceSelectModel")}
177+
searchPlaceholder={t("settings:providers.huggingFaceSearchModels")}
178+
emptyMessage={t("settings:providers.huggingFaceNoModelsFound")}
173179
disabled={loading}
174180
/>
175181
</div>
176182

177183
{currentModel && availableProviders.length > 0 && (
178184
<div className="flex flex-col gap-2">
179-
<label className="block font-medium text-sm">Provider</label>
185+
<label className="block font-medium text-sm">{t("settings:providers.huggingFaceProvider")}</label>
180186
<SearchableSelect
181187
value={selectedProvider}
182188
onValueChange={handleProviderSelect}
183189
options={[
184-
{ value: "auto", label: "Auto" },
190+
{ value: "auto", label: t("settings:providers.huggingFaceProviderAuto") },
185191
...availableProviders.map(
186192
(mapping): SearchableSelectOption => ({
187193
value: mapping.provider,
188194
label: `${formatProviderName(mapping.provider)} (${mapping.status})`,
189195
}),
190196
),
191197
]}
192-
placeholder="Select a provider..."
193-
searchPlaceholder="Search providers..."
194-
emptyMessage="No providers found"
198+
placeholder={t("settings:providers.huggingFaceSelectProvider")}
199+
searchPlaceholder={t("settings:providers.huggingFaceSearchProviders")}
200+
emptyMessage={t("settings:providers.huggingFaceNoProvidersFound")}
195201
/>
196202
</div>
197203
)}
Lines changed: 162 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
import React from "react"
2+
import { render, screen } from "@/utils/test-utils"
3+
import { HuggingFace } from "../HuggingFace"
4+
import { ProviderSettings } from "@roo-code/types"
5+
6+
// Mock the VSCodeTextField component
7+
vi.mock("@vscode/webview-ui-toolkit/react", () => ({
8+
VSCodeTextField: ({
9+
children,
10+
value,
11+
onInput,
12+
placeholder,
13+
className,
14+
style,
15+
"data-testid": dataTestId,
16+
...rest
17+
}: any) => {
18+
return (
19+
<div
20+
data-testid={dataTestId ? `${dataTestId}-text-field` : "vscode-text-field"}
21+
className={className}
22+
style={style}>
23+
{children}
24+
<input
25+
type="text"
26+
value={value}
27+
onChange={(e) => onInput && onInput(e)}
28+
placeholder={placeholder}
29+
data-testid={dataTestId}
30+
{...rest}
31+
/>
32+
</div>
33+
)
34+
},
35+
VSCodeLink: ({ children, href, onClick }: any) => (
36+
<a href={href} onClick={onClick} data-testid="vscode-link">
37+
{children}
38+
</a>
39+
),
40+
VSCodeButton: ({ children, onClick, ...rest }: any) => (
41+
<button onClick={onClick} data-testid="vscode-button" {...rest}>
42+
{children}
43+
</button>
44+
),
45+
}))
46+
47+
// Mock the translation hook
48+
vi.mock("@src/i18n/TranslationContext", () => ({
49+
useAppTranslation: () => ({
50+
t: (key: string) => {
51+
// Return the key for testing, but simulate some actual translations
52+
const translations: Record<string, string> = {
53+
"settings:providers.getHuggingFaceApiKey": "Get Hugging Face API Key",
54+
"settings:providers.huggingFaceApiKey": "Hugging Face API Key",
55+
"settings:providers.huggingFaceModelId": "Model ID",
56+
}
57+
return translations[key] || key
58+
},
59+
}),
60+
}))
61+
62+
// Mock the UI components
63+
vi.mock("@src/components/ui", () => ({
64+
Select: ({ children }: any) => <div data-testid="select">{children}</div>,
65+
SelectContent: ({ children }: any) => <div data-testid="select-content">{children}</div>,
66+
SelectItem: ({ children }: any) => <div data-testid="select-item">{children}</div>,
67+
SelectTrigger: ({ children }: any) => <div data-testid="select-trigger">{children}</div>,
68+
SelectValue: ({ placeholder }: any) => <div data-testid="select-value">{placeholder}</div>,
69+
SearchableSelect: ({ value, onValueChange, placeholder, children }: any) => (
70+
<div data-testid="searchable-select">
71+
<input
72+
data-testid="searchable-select-input"
73+
value={value}
74+
onChange={(e) => onValueChange && onValueChange(e.target.value)}
75+
placeholder={placeholder}
76+
/>
77+
{children}
78+
</div>
79+
),
80+
}))
81+
82+
describe("HuggingFace Component", () => {
83+
const mockSetApiConfigurationField = vi.fn()
84+
85+
beforeEach(() => {
86+
vi.clearAllMocks()
87+
})
88+
89+
it("should render with internationalized labels", () => {
90+
const apiConfiguration: Partial<ProviderSettings> = {
91+
huggingFaceApiKey: "",
92+
huggingFaceModelId: "",
93+
}
94+
95+
render(
96+
<HuggingFace
97+
apiConfiguration={apiConfiguration as ProviderSettings}
98+
setApiConfigurationField={mockSetApiConfigurationField}
99+
/>,
100+
)
101+
102+
// Check that the translated labels are rendered
103+
expect(screen.getByText("Get Hugging Face API Key")).toBeInTheDocument()
104+
expect(screen.getByText("Hugging Face API Key")).toBeInTheDocument()
105+
expect(screen.getByText("Model ID")).toBeInTheDocument()
106+
})
107+
108+
it("should render API key input field", () => {
109+
const apiConfiguration: Partial<ProviderSettings> = {
110+
huggingFaceApiKey: "test-api-key",
111+
huggingFaceModelId: "",
112+
}
113+
114+
render(
115+
<HuggingFace
116+
apiConfiguration={apiConfiguration as ProviderSettings}
117+
setApiConfigurationField={mockSetApiConfigurationField}
118+
/>,
119+
)
120+
121+
// Check that the API key input is rendered with the correct value
122+
const apiKeyInput = screen.getByDisplayValue("test-api-key")
123+
expect(apiKeyInput).toBeInTheDocument()
124+
})
125+
126+
it("should render model selection components", () => {
127+
const apiConfiguration: Partial<ProviderSettings> = {
128+
huggingFaceApiKey: "test-api-key",
129+
huggingFaceModelId: "test-model",
130+
}
131+
132+
render(
133+
<HuggingFace
134+
apiConfiguration={apiConfiguration as ProviderSettings}
135+
setApiConfigurationField={mockSetApiConfigurationField}
136+
/>,
137+
)
138+
139+
// Check that the searchable select component is rendered
140+
expect(screen.getByTestId("searchable-select")).toBeInTheDocument()
141+
expect(screen.getByTestId("searchable-select-input")).toBeInTheDocument()
142+
})
143+
144+
it("should display the get API key link", () => {
145+
const apiConfiguration: Partial<ProviderSettings> = {
146+
huggingFaceApiKey: "",
147+
huggingFaceModelId: "",
148+
}
149+
150+
render(
151+
<HuggingFace
152+
apiConfiguration={apiConfiguration as ProviderSettings}
153+
setApiConfigurationField={mockSetApiConfigurationField}
154+
/>,
155+
)
156+
157+
// Check that the API key button is rendered
158+
const apiKeyButton = screen.getByTestId("vscode-button")
159+
expect(apiKeyButton).toBeInTheDocument()
160+
expect(apiKeyButton).toHaveTextContent("Get Hugging Face API Key")
161+
})
162+
})

webview-ui/src/i18n/locales/ca/settings.json

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webview-ui/src/i18n/locales/de/settings.json

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webview-ui/src/i18n/locales/en/settings.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,16 @@
262262
"getHuggingFaceApiKey": "Get Hugging Face API Key",
263263
"huggingFaceApiKey": "Hugging Face API Key",
264264
"huggingFaceModelId": "Model ID",
265+
"huggingFaceLoading": "Loading...",
266+
"huggingFaceModelsCount": "({{count}} models)",
267+
"huggingFaceSelectModel": "Select a model...",
268+
"huggingFaceSearchModels": "Search models...",
269+
"huggingFaceNoModelsFound": "No models found",
270+
"huggingFaceProvider": "Provider",
271+
"huggingFaceProviderAuto": "Auto",
272+
"huggingFaceSelectProvider": "Select a provider...",
273+
"huggingFaceSearchProviders": "Search providers...",
274+
"huggingFaceNoProvidersFound": "No providers found",
265275
"getGeminiApiKey": "Get Gemini API Key",
266276
"openAiApiKey": "OpenAI API Key",
267277
"apiKey": "API Key",

webview-ui/src/i18n/locales/es/settings.json

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webview-ui/src/i18n/locales/fr/settings.json

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webview-ui/src/i18n/locales/hi/settings.json

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webview-ui/src/i18n/locales/id/settings.json

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webview-ui/src/i18n/locales/it/settings.json

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)