Skip to content

Commit d61b913

Browse files
committed
Implement internationalization for settings and shared configuration forms by migrating hardcoded text to translation files
- remove modal provider in settings, as it is not necessary to show modal - fix incorrect translation keys - consistently name the translation exported variables 'translations'
1 parent af1f14d commit d61b913

16 files changed

Lines changed: 1041 additions & 269 deletions

File tree

‎apps/editor/src/views/settings/frontend/App.tsx‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import ReactDOM from 'react-dom/client'
22
import { Settings } from './Settings'
33
import { translations } from './i18n/translations'
44
import { TranslationContext } from './i18n/use-translation'
5+
import { TranslationContext as SharedTranslationContext } from '@/views/shared/i18n/use-translation'
6+
import { translations as sharedTranslations } from '@/views/shared/i18n/translations'
57

68
import '@vscode/codicons/dist/codicon.css'
79
import 'simplebar-react/dist/simplebar.min.css'
@@ -10,7 +12,9 @@ import '@ui/styles/global.scss'
1012
const App = () => {
1113
return (
1214
<TranslationContext.Provider value={translations}>
13-
<Settings />
15+
<SharedTranslationContext.Provider value={sharedTranslations}>
16+
<Settings />
17+
</SharedTranslationContext.Provider>
1418
</TranslationContext.Provider>
1519
)
1620
}

‎apps/editor/src/views/settings/frontend/forms/EditModelProviderForm/EditModelProviderForm.tsx‎

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,31 +46,34 @@ export const EditModelProviderForm: React.FC<Props> = (props) => {
4646
<UiScrollable top_shadow>
4747
<div className={styles.form}>
4848
<UiFieldset>
49-
<UiField label={t('model-providers.form.name.label')} html_for="name">
49+
<UiField
50+
label={t('edit-model-provider-form.name.label')}
51+
html_for="name"
52+
>
5053
<UiInput
5154
id="name"
5255
type="text"
5356
value={name}
5457
on_change={set_name}
55-
placeholder={t('model-providers.form.name.placeholder')}
58+
placeholder={t('edit-model-provider-form.name.placeholder')}
5659
/>
5760
</UiField>
5861

5962
<UiField
60-
label={t('model-providers.form.base-url.label')}
63+
label={t('edit-model-provider-form.base-url.label')}
6164
html_for="base_url"
6265
>
6366
<UiInput
6467
id="base_url"
6568
type="text"
6669
value={base_url}
6770
on_change={set_base_url}
68-
placeholder={t('model-providers.form.base-url.placeholder')}
71+
placeholder={t('edit-model-provider-form.base-url.placeholder')}
6972
/>
7073
</UiField>
7174

7275
<UiField
73-
label={t('model-providers.form.api-key.label')}
76+
label={t('edit-model-provider-form.api-key.label')}
7477
html_for="api_key"
7578
action={
7679
(props.provider.api_key_mask || api_key) &&
@@ -82,7 +85,7 @@ export const EditModelProviderForm: React.FC<Props> = (props) => {
8285
set_is_api_key_cleared(true)
8386
}}
8487
>
85-
{t('model-providers.form.api-key.action.clear')}
88+
{t('edit-model-provider-form.api-key.action.clear')}
8689
</button>
8790
) : undefined
8891
}
@@ -97,20 +100,24 @@ export const EditModelProviderForm: React.FC<Props> = (props) => {
97100
}}
98101
placeholder={
99102
is_api_key_cleared
100-
? t('model-providers.form.api-key.placeholder.cleared')
103+
? t('edit-model-provider-form.api-key.placeholder.cleared')
101104
: props.provider.api_key_mask
102105
? `...${props.provider.api_key_mask.slice(-4)}`
103-
: t('model-providers.form.api-key.placeholder.default')
106+
: t('edit-model-provider-form.api-key.placeholder.default')
104107
}
105108
/>
106109
</UiField>
107110

108111
{base_url.includes('api.anthropic.com') && (
109112
<UiField
110-
label={t('model-providers.extended-cache.anthropic.title')}
113+
label={t(
114+
'edit-model-provider-form.extended-cache.anthropic.title'
115+
)}
111116
info={
112117
<>
113-
{t('model-providers.extended-cache.anthropic.description')}{' '}
118+
{t(
119+
'edit-model-provider-form.extended-cache.anthropic.description'
120+
)}{' '}
114121
<a
115122
href="#"
116123
onClick={(e) => {
@@ -120,7 +127,9 @@ export const EditModelProviderForm: React.FC<Props> = (props) => {
120127
)
121128
}}
122129
>
123-
{t('model-providers.extended-cache.anthropic.learn-more')}
130+
{t(
131+
'edit-model-provider-form.extended-cache.anthropic.learn-more'
132+
)}
124133
</a>
125134
</>
126135
}

‎apps/editor/src/views/settings/frontend/i18n/translations/actions.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export const actions = {
1+
export const translations = {
22
'action.add-new': {
33
en: 'Add New',
44
pl: 'Dodaj...',

‎apps/editor/src/views/settings/frontend/i18n/translations/api-calls.ts‎

Lines changed: 1 addition & 200 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export const api_calls = {
1+
export const translations = {
22
'api-calls.title': {
33
en: 'API Calls',
44
pl: 'Konfiguracje API',
@@ -91,61 +91,6 @@ export const api_calls = {
9191
hu: 'Hiányzó modell szolgáltató.',
9292
bg: 'Липсващ доставчик.'
9393
},
94-
'api-calls.model-providers.extended-cache.anthropic.title': {
95-
en: 'Extended Cache for Anthropic',
96-
pl: 'Rozszerzona pamięć podręczna dla Anthropic',
97-
'zh-cn': 'Anthropic 的扩展缓存',
98-
ja: 'Anthropic の拡張キャッシュ',
99-
'zh-tw': 'Anthropic 的擴展快取',
100-
de: 'Erweiterter Cache für Anthropic',
101-
es: 'Caché extendido para Anthropic',
102-
fr: 'Cache étendu pour Anthropic',
103-
'pt-br': 'Cache Estendido para Anthropic',
104-
ru: 'Расширенный кэш для Anthropic',
105-
ko: 'Anthropic용 확장 캐시',
106-
it: 'Cache estesa per Anthropic',
107-
tr: 'Anthropic için Genişletilmiş Önbellek',
108-
cs: 'Rozšířená mezipaměť pro Anthropic',
109-
hu: 'Bővített gyorsítótár Anthropic-hoz',
110-
bg: 'Разширен кеш за Anthropic'
111-
},
112-
'api-calls.model-providers.extended-cache.anthropic.description': {
113-
en: 'Enable 1-hour prompt caching for requests including the selected files.',
114-
pl: 'Włącz 1-godzinne buforowanie promptów dla zapytań zawierających wybrane pliki.',
115-
'zh-cn': '为包含所选文件的请求启用 1 小时提示词缓存。',
116-
ja: '選択されたファイルを含むリクエストに対して、1時間のプロンプトキャッシュを有効にします。',
117-
'zh-tw': '為包含所選檔案的請求啟用 1 小時提示詞快取。',
118-
de: 'Aktivieren Sie das 1-stündige Prompt-Caching für Anfragen, die die ausgewählten Dateien enthalten.',
119-
es: 'Habilita el almacenamiento en caché de prompts de 1 hora para las solicitudes que incluyan los archivos seleccionados.',
120-
fr: 'Activez la mise en cache des prompts pendant 1 heure pour les requêtes incluant les fichiers sélectionnés.',
121-
'pt-br':
122-
'Ative o cache de prompts de 1 hora para requisições que incluam os arquivos selecionados.',
123-
ru: 'Включить 1-часовое кэширование промптов для запросов, включающих выбранные файлы.',
124-
ko: '선택한 파일이 포함된 요청에 대해 1시간 프롬프트 캐싱을 활성화합니다.',
125-
it: 'Abilita la cache dei prompt di 1 ora per le richieste che includono i file selezionati.',
126-
tr: 'Seçili dosyaları içeren istekler için 1 saatlik istem önbelleğe almayı etkinleştirin.',
127-
cs: 'Povolit 1hodinové ukládání promptů do mezipaměti pro požadavky obsahující vybrané soubory.',
128-
hu: 'Engedélyezze az 1 órás prompt gyorsítótárazást a kiválasztott fájlokat tartalmazó kérésekhez.',
129-
bg: 'Включете 1-часово кеширане на промптове за заявки, включващи избраните файлове.'
130-
},
131-
'api-calls.model-providers.extended-cache.anthropic.learn-more': {
132-
en: 'Learn more',
133-
pl: 'Dowiedz się więcej',
134-
'zh-cn': '了解更多',
135-
ja: '詳細はこちら',
136-
'zh-tw': '了解更多',
137-
de: 'Mehr erfahren',
138-
es: 'Más información',
139-
fr: 'En savoir plus',
140-
'pt-br': 'Saiba mais',
141-
ru: 'Узнать больше',
142-
ko: '자세히 알아보기',
143-
it: 'Scopri di più',
144-
tr: 'Daha fazla bilgi edin',
145-
cs: 'Dozvědět se více',
146-
hu: 'Tudjon meg többet',
147-
bg: 'Научете повече'
148-
},
14994
'api-calls.model-providers.action.insert': {
15095
en: 'Insert a new provider below/above',
15196
pl: 'Wstaw nowego dostawcę poniżej/powyżej',
@@ -236,150 +181,6 @@ export const api_calls = {
236181
hu: 'modell szolgáltatók',
237182
bg: 'доставчици на модели'
238183
},
239-
'api-calls.model-providers.form.name.label': {
240-
en: 'Name',
241-
pl: 'Nazwa',
242-
'zh-cn': '名称',
243-
ja: '名前',
244-
'zh-tw': '名稱',
245-
de: 'Name',
246-
es: 'Nombre',
247-
fr: 'Nom',
248-
'pt-br': 'Nome',
249-
ru: 'Название',
250-
ko: '이름',
251-
it: 'Nome',
252-
tr: 'Ad',
253-
cs: 'Název',
254-
hu: 'Név',
255-
bg: 'Име'
256-
},
257-
'api-calls.model-providers.form.name.placeholder': {
258-
en: 'e.g. OpenAI',
259-
pl: 'np. OpenAI',
260-
'zh-cn': '例如 OpenAI',
261-
ja: '例:OpenAI',
262-
'zh-tw': '例如 OpenAI',
263-
de: 'z.B. OpenAI',
264-
es: 'ej. OpenAI',
265-
fr: 'ex. OpenAI',
266-
'pt-br': 'ex. OpenAI',
267-
ru: 'напр. OpenAI',
268-
ko: '예: OpenAI',
269-
it: 'es. OpenAI',
270-
tr: 'örn. OpenAI',
271-
cs: 'např. OpenAI',
272-
hu: 'pl. OpenAI',
273-
bg: 'напр. OpenAI'
274-
},
275-
'api-calls.model-providers.form.base-url.label': {
276-
en: 'Base URL',
277-
pl: 'Bazowy adres URL',
278-
'zh-cn': '基础 URL',
279-
ja: 'ベース URL',
280-
'zh-tw': '基礎 URL',
281-
de: 'Basis-URL',
282-
es: 'URL base',
283-
fr: 'URL de base',
284-
'pt-br': 'URL Base',
285-
ru: 'Базовый URL',
286-
ko: '기본 URL',
287-
it: 'URL di base',
288-
tr: 'Temel URL',
289-
cs: 'Základní URL',
290-
hu: 'Alap URL',
291-
bg: 'Базов URL'
292-
},
293-
'api-calls.model-providers.form.base-url.placeholder': {
294-
en: 'e.g. https://api.openai.com/v1',
295-
pl: 'np. https://api.openai.com/v1',
296-
'zh-cn': '例如 https://api.openai.com/v1',
297-
ja: '例:https://api.openai.com/v1',
298-
'zh-tw': '例如 https://api.openai.com/v1',
299-
de: 'z.B. https://api.openai.com/v1',
300-
es: 'ej. https://api.openai.com/v1',
301-
fr: 'ex. https://api.openai.com/v1',
302-
'pt-br': 'ex. https://api.openai.com/v1',
303-
ru: 'напр. https://api.openai.com/v1',
304-
ko: '예: https://api.openai.com/v1',
305-
it: 'es. https://api.openai.com/v1',
306-
tr: 'örn. https://api.openai.com/v1',
307-
cs: 'např. https://api.openai.com/v1',
308-
hu: 'pl. https://api.openai.com/v1',
309-
bg: 'напр. https://api.openai.com/v1'
310-
},
311-
'api-calls.model-providers.form.api-key.label': {
312-
en: 'API Key',
313-
pl: 'Klucz API',
314-
'zh-cn': 'API 密钥',
315-
ja: 'API キー',
316-
'zh-tw': 'API 金鑰',
317-
de: 'API-Schlüssel',
318-
es: 'Clave API',
319-
fr: 'Clé API',
320-
'pt-br': 'Chave API',
321-
ru: 'API-ключ',
322-
ko: 'API 키',
323-
it: 'Chiave API',
324-
tr: 'API Anahtarı',
325-
cs: 'Klíč API',
326-
hu: 'API Kulcs',
327-
bg: 'API Ключ'
328-
},
329-
'api-calls.model-providers.form.api-key.action.clear': {
330-
en: 'Clear',
331-
pl: 'Wyczyść',
332-
'zh-cn': '清除',
333-
ja: 'クリア',
334-
'zh-tw': '清除',
335-
de: 'Löschen',
336-
es: 'Borrar',
337-
fr: 'Effacer',
338-
'pt-br': 'Limpar',
339-
ru: 'Очистить',
340-
ko: '지우기',
341-
it: 'Cancella',
342-
tr: 'Temizle',
343-
cs: 'Vymazat',
344-
hu: 'Törlés',
345-
bg: 'Изчистване'
346-
},
347-
'api-calls.model-providers.form.api-key.placeholder.cleared': {
348-
en: 'API Key cleared',
349-
pl: 'Klucz API wyczyszczony',
350-
'zh-cn': 'API 密钥已清除',
351-
ja: 'API キーがクリアされました',
352-
'zh-tw': 'API 金鑰已清除',
353-
de: 'API-Schlüssel gelöscht',
354-
es: 'Clave API borrada',
355-
fr: 'Clé API effacée',
356-
'pt-br': 'Chave API apagada',
357-
ru: 'API-ключ очищен',
358-
ko: 'API 키 지워짐',
359-
it: 'Chiave API cancellata',
360-
tr: 'API Anahtarı temizlendi',
361-
cs: 'Klíč API vymazán',
362-
hu: 'API Kulcs törölve',
363-
bg: 'API ключът е изчистен'
364-
},
365-
'api-calls.model-providers.form.api-key.placeholder.default': {
366-
en: 'Enter API Key',
367-
pl: 'Wprowadź klucz API',
368-
'zh-cn': '输入 API 密钥',
369-
ja: 'API キーを入力',
370-
'zh-tw': '輸入 API 金鑰',
371-
de: 'API-Schlüssel eingeben',
372-
es: 'Introducir clave API',
373-
fr: 'Entrer la clé API',
374-
'pt-br': 'Inserir Chave API',
375-
ru: 'Введите API-ключ',
376-
ko: 'API 키 입력',
377-
it: 'Inserisci Chiave API',
378-
tr: 'API Anahtarı Girin',
379-
cs: 'Zadejte klíč API',
380-
hu: 'Adja meg az API Kulcsot',
381-
bg: 'Въведете API ключ'
382-
},
383184
'api-calls.configurations.title': {
384185
en: 'Configurations',
385186
pl: 'Konfiguracje',

‎apps/editor/src/views/settings/frontend/i18n/translations/chatbots.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export const chatbots = {
1+
export const translations = {
22
'chatbots.title': {
33
en: 'Chatbots',
44
pl: 'Chatboty',

‎apps/editor/src/views/settings/frontend/i18n/translations/common.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
export const common = {
1+
export const translations = {
22
'common.expand': {
33
en: 'Expand',
44
pl: 'Rozwiń',

0 commit comments

Comments
 (0)