Skip to content

Commit 35703ed

Browse files
committed
Internationalize home mode button labels and improve text overflow handling
- should truncate with ellipsis if there is not enough space to show text in a single line - translate 'Autofill', for example in polish it would be 'Autouzupełnij' - translate 'Copy prompt', for example in polish it would be 'Skopiuj prompt' - translate 'Chatbots', for example in polish it would be 'Czatboty' - translate 'Make', for example in polish it would be 'Wykonaj' - translate 'API calls', for example in polish it would be 'Żądania API'
1 parent ee17f09 commit 35703ed

4 files changed

Lines changed: 105 additions & 6 deletions

File tree

‎apps/editor/src/views/prompt/frontend/Home/Home.tsx‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,14 +163,18 @@ export const Home: React.FC<Props> = (props) => {
163163
ref={mode_ref}
164164
>
165165
<UiModeButton
166-
pre={props.is_connected ? 'Autofill' : 'Copy for'}
167-
label="Chatbots"
166+
pre={
167+
props.is_connected
168+
? t('home.mode.autofill')
169+
: t('home.mode.copy-prompt')
170+
}
171+
label={t('home.mode.chatbots')}
168172
on_click={props.on_chatbots_click}
169173
is_compact={is_mode_sticky}
170174
/>
171175
<UiModeButton
172-
pre="Make"
173-
label="API calls"
176+
pre={t('home.mode.make')}
177+
label={t('home.mode.api-calls')}
174178
on_click={props.on_api_calls_click}
175179
is_compact={is_mode_sticky}
176180
/>

‎apps/editor/src/views/prompt/frontend/i18n/translations/home.ts‎

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,96 @@ export const home = {
107107
hu: 'Szerzői jog © {year} {link}',
108108
bg: 'Авторско право © {year} {link}'
109109
},
110+
'home.mode.copy-prompt': {
111+
en: 'Copy prompt',
112+
pl: 'Skopiuj prompt',
113+
'zh-cn': '复制提示词',
114+
ja: 'プロンプトをコピー',
115+
'zh-tw': '複製提示詞',
116+
de: 'Prompt kopieren',
117+
es: 'Copiar prompt',
118+
fr: 'Copier le prompt',
119+
'pt-br': 'Copiar prompt',
120+
ru: 'Скопировать промпт',
121+
ko: '프롬프트 복사',
122+
it: 'Copia prompt',
123+
tr: 'İstemi kopyala',
124+
cs: 'Kopírovat prompt',
125+
hu: 'Prompt másolása',
126+
bg: 'Копиране на промпта'
127+
},
128+
'home.mode.autofill': {
129+
en: 'Autofill',
130+
pl: 'Autouzupełnij',
131+
'zh-cn': '自动填充',
132+
ja: '自動入力',
133+
'zh-tw': '自動填入',
134+
de: 'Automatisch ausfüllen',
135+
es: 'Autocompletar',
136+
fr: 'Saisie automatique',
137+
'pt-br': 'Preenchimento automático',
138+
ru: 'Автозаполнение',
139+
ko: '자동 완성',
140+
it: 'Compilazione automatica',
141+
tr: 'Otomatik doldur',
142+
cs: 'Automatické vyplnění',
143+
hu: 'Automatikus kitöltés',
144+
bg: 'Автоматично попълване'
145+
},
146+
'home.mode.make': {
147+
en: 'Make',
148+
pl: 'Wykonaj',
149+
'zh-cn': '执行',
150+
ja: '実行',
151+
'zh-tw': '執行',
152+
de: 'Ausführen',
153+
es: 'Realizar',
154+
fr: 'Effectuer',
155+
'pt-br': 'Realizar',
156+
ru: 'Выполнить',
157+
ko: '실행',
158+
it: 'Esegui',
159+
tr: 'Gerçekleştir',
160+
cs: 'Provést',
161+
hu: 'Végrehajtás',
162+
bg: 'Изпълни'
163+
},
164+
'home.mode.chatbots': {
165+
en: 'Chatbots',
166+
pl: 'Czatboty',
167+
'zh-cn': '聊天机器人',
168+
ja: 'チャットボット',
169+
'zh-tw': '聊天機器人',
170+
de: 'Chatbots',
171+
es: 'Chatbots',
172+
fr: 'Chatbots',
173+
'pt-br': 'Chatbots',
174+
ru: 'Чат-боты',
175+
ko: '챗봇',
176+
it: 'Chatbot',
177+
tr: 'Sohbet Botları',
178+
cs: 'Chatboti',
179+
hu: 'Chatbotok',
180+
bg: 'Чатботове'
181+
},
182+
'home.mode.api-calls': {
183+
en: 'API calls',
184+
pl: 'Żądania API',
185+
'zh-cn': 'API 调用',
186+
ja: 'API呼び出し',
187+
'zh-tw': 'API 呼叫',
188+
de: 'API-Aufrufe',
189+
es: 'Llamadas API',
190+
fr: 'Appels API',
191+
'pt-br': 'Chamadas de API',
192+
ru: 'Вызовы API',
193+
ko: 'API 호출',
194+
it: 'Chiamate API',
195+
tr: 'API çağrıları',
196+
cs: 'Volání API',
197+
hu: 'API hívások',
198+
bg: 'API заявки'
199+
},
110200
'home.shrink-source-code': {
111201
en: 'Strip function bodies',
112202
pl: 'Usuń ciała funkcji',

‎packages/shared/src/hooks/use-compacting.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ export const use_compacting = (max_compact_step = 4) => {
77

88
const report_width = useCallback((width: number, step: number) => {
99
set_thresholds((prev) => {
10-
// Round up and add 1px buffer to account for subpixel rendering differences
11-
const threshold = Math.ceil(width) + 10
10+
const threshold = Math.ceil(width)
1211
if (prev[step] == threshold) return prev
1312
return { ...prev, [step]: threshold }
1413
})

‎packages/ui/src/components/editor/prompt/ModeButton/ModeButton.module.scss‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
flex-direction: column;
1919
padding: 0 12px;
2020
height: 80px;
21+
max-width: 100%;
22+
overflow: hidden;
2123

2224
&--compact {
2325
height: 36px;
@@ -46,6 +48,10 @@
4648
font-size: 22px;
4749
line-height: 1.2;
4850
letter-spacing: 1px;
51+
white-space: nowrap;
52+
overflow: hidden;
53+
text-overflow: ellipsis;
54+
max-width: 100%;
4955
}
5056

5157
&__label-char {

0 commit comments

Comments
 (0)