Skip to content

Commit 6796f8c

Browse files
committed
Remove UI-specific translation keys from and hardcode corresponding strings directly into the affected React components
1 parent a518141 commit 6796f8c

11 files changed

Lines changed: 92 additions & 202 deletions

File tree

‎packages/shared/src/constants/dictionary.ts‎

Lines changed: 0 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -5,47 +5,6 @@ export const dictionary = {
55
RECEIVING_RESPONSE: 'Receiving response'
66
},
77

8-
'ChatInput.tsx': {
9-
type_something: 'Type something',
10-
completion_instructions: 'Completion instructions',
11-
use_last_choice: 'Use last choice',
12-
select: 'Select...',
13-
code_completions_mode_unavailable_with_text_selection:
14-
'Remove text selection',
15-
code_completions_mode_unavailable_without_active_editor:
16-
'Place cursor for completion',
17-
search: 'Search history',
18-
websocket_not_connected: 'Install or reload the browser extension',
19-
for_history_hint: '(⇅ for history)',
20-
copy_to_clipboard: 'Copy to clipboard',
21-
insert_symbol: 'Insert symbol',
22-
prompt_templates: 'Prompt templates',
23-
approximate_token_count: 'Approximate message length in tokens'
24-
},
25-
26-
'Configurations.tsx': {
27-
my_configurations: 'MY CONFIGURATIONS'
28-
},
29-
30-
'Presets.tsx': {
31-
my_chat_presets: 'MY CHAT PRESETS',
32-
duplicate: 'Duplicate',
33-
edit: 'Edit',
34-
delete: 'Delete',
35-
set_as_selected: 'Set as selected',
36-
unset_as_selected: 'Unset as selected',
37-
collapse_group: 'Collapse',
38-
expand_group: 'Expand',
39-
copy_to_clipboard: 'Copy to clipboard',
40-
run_without_submission: 'Run without submission'
41-
},
42-
43-
'CommitMessageModal.tsx': {
44-
commit_changes: 'Commit changes',
45-
cancel: 'Cancel',
46-
commit: 'Commit'
47-
},
48-
498
information_message: {
509
NO_INTELLIGENT_UPDATE_CONFIGURATIONS_FOUND:
5110
'No "Intelligent Update" configurations found. Please add one in the settings.',
@@ -307,59 +266,5 @@ export const dictionary = {
307266
CONFIGURATION_ALREADY_EXISTS:
308267
'A configuration with these properties already exists.',
309268
CONFIGURATION_NOT_FOUND: 'Configuration not found.'
310-
},
311-
312-
settings: {
313-
SETTINGS_TITLE: 'Settings',
314-
MODEL_PROVIDERS_LABEL: 'Model Providers',
315-
CODE_COMPLETIONS_LABEL: 'Code Completions',
316-
CODE_COMPLETIONS_SUBTITLE:
317-
'Get accurate code-at-cursor from state-of-the-art reasoning models.',
318-
EDIT_CONTEXT_LABEL: 'Edit Context',
319-
EDIT_CONTEXT_SUBTITLE:
320-
'Modify, create or delete files based on natural language instructions.',
321-
INTELLIGENT_UPDATE_LABEL: 'Intelligent Update',
322-
INTELLIGENT_UPDATE_SUBTITLE:
323-
'Integrate truncated code blocks and fix malformed diffs.',
324-
COMMIT_MESSAGES_LABEL: 'Commit Messages',
325-
COMMIT_MESSAGES_SUBTITLE:
326-
'Generate meaningful summaries of changes adhering to your style.',
327-
SELECT_SETTING_FROM_SIDEBAR: 'Select a setting from the sidebar.',
328-
ADD_MODEL_PROVIDER_NAME_TITLE: 'Model Provider Name',
329-
ADD_MODEL_PROVIDER_NAME_PROMPT:
330-
'Enter a name for the custom model provider',
331-
NAME_IS_REQUIRED: 'Name is required',
332-
PROVIDER_WITH_NAME_ALREADY_EXISTS:
333-
'A provider with this name already exists',
334-
BASE_URL_TITLE: 'Base URL',
335-
BASE_URL_PROMPT: 'Enter base URL for the model provider',
336-
BASE_URL_IS_REQUIRED: 'Base URL is required',
337-
MODEL_API_KEY_TITLE: 'Model API Key',
338-
MODEL_API_KEY_PROMPT: 'Enter your model API key',
339-
API_KEY_IS_REQUIRED: 'API key is required',
340-
CUSTOM_ENDPOINT_LABEL: '$(edit) Custom endpoint...',
341-
CUSTOM_ENDPOINT_DESCRIPTION:
342-
'You can use any OpenAI-API compatible provider',
343-
PREDEFINED_ENDPOINTS_LABEL: 'Predefined endpoints',
344-
ADD_NEW_MODEL_PROVIDER_TITLE: 'Add New Model Provider',
345-
ADD_NEW_MODEL_PROVIDER_PLACEHOLDER:
346-
'Choose a predefined provider or create a custom one'
347-
},
348-
349-
home: {
350-
header: 'Home',
351-
new_chat_label: 'Open View: New chat',
352-
new_chat_description: 'Send prompt in a free chatbot',
353-
api_call_label: 'Open View: API call',
354-
api_call_description: 'Send prompt to a model provider',
355-
license_prefix: 'Released under the',
356-
license_link_text: 'GPL-3.0 license',
357-
author: 'Robert Piosik',
358-
follow_x: 'Follow on X',
359-
join_reddit: 'Join subreddit',
360-
join_discord: 'Join Discord server',
361-
documentation: 'Documentation',
362-
visit_website_label: 'Visit website',
363-
support_author_label: 'Support author'
364269
}
365270
}

‎packages/ui/src/components/editor/ChatInput/ChatInput.tsx‎

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,10 @@ import styles from './ChatInput.module.scss'
33
import TextareaAutosize from 'react-textarea-autosize'
44
import cn from 'classnames'
55
import { Icon } from '../Icon'
6-
import { dictionary } from '@shared/constants/dictionary'
76
import { get_highlighted_text } from './utils/get-highlighted-text'
87
import { use_handlers } from './hooks/use-handlers'
98
import { format_token_count } from './utils/format-token-count'
109

11-
const component_dictionary = dictionary['ChatInput.tsx']
12-
1310
export type ChatInputProps = {
1411
value: string
1512
chat_history: string[]
@@ -82,15 +79,15 @@ export const ChatInput: React.FC<ChatInputProps> = (props) => {
8279

8380
if (props.is_in_code_completions_mode) {
8481
if (active_history.length > 0 && is_history_enabled) {
85-
return `${component_dictionary.completion_instructions} ${component_dictionary.for_history_hint}`
82+
return 'Completion instructions (⇅ for history)'
8683
} else {
87-
return component_dictionary.completion_instructions
84+
return 'Completion instructions'
8885
}
8986
}
9087

9188
return active_history.length > 0 && is_history_enabled
92-
? `${component_dictionary.type_something} ${component_dictionary.for_history_hint}`
93-
: component_dictionary.type_something
89+
? 'Type something (⇅ for history)'
90+
: 'Type something'
9491
}, [
9592
props.is_in_code_completions_mode,
9693
props.chat_history,
@@ -102,21 +99,13 @@ export const ChatInput: React.FC<ChatInputProps> = (props) => {
10299
<div className={styles.container}>
103100
{props.has_active_selection && props.is_in_code_completions_mode && (
104101
<div className={styles.error}>
105-
<div className={styles.error__inner}>
106-
{
107-
component_dictionary.code_completions_mode_unavailable_with_text_selection
108-
}
109-
</div>
102+
<div className={styles.error__inner}>Remove text selection</div>
110103
</div>
111104
)}
112105

113106
{props.is_in_code_completions_mode && !props.has_active_editor && (
114107
<div className={styles.error}>
115-
<div className={styles.error__inner}>
116-
{
117-
component_dictionary.code_completions_mode_unavailable_without_active_editor
118-
}
119-
</div>
108+
<div className={styles.error__inner}>Place cursor for completion</div>
120109
</div>
121110
)}
122111

@@ -177,7 +166,7 @@ export const ChatInput: React.FC<ChatInputProps> = (props) => {
177166
'codicon-search'
178167
)}
179168
onClick={props.on_search_click}
180-
title={`${component_dictionary.search} (${
169+
title={`Search history (${
181170
navigator.userAgent.toUpperCase().indexOf('MAC') >= 0
182171
? '⌘F'
183172
: 'Ctrl+F'
@@ -195,7 +184,7 @@ export const ChatInput: React.FC<ChatInputProps> = (props) => {
195184
e.stopPropagation()
196185
props.on_copy()
197186
}}
198-
title={`${component_dictionary.copy_to_clipboard} (${
187+
title={`Copy to clipboard (${
199188
navigator.userAgent.toUpperCase().indexOf('MAC') >= 0
200189
? '⌥⌘C'
201190
: 'Ctrl+Alt+C'
@@ -220,15 +209,15 @@ export const ChatInput: React.FC<ChatInputProps> = (props) => {
220209
<button
221210
onClick={props.on_at_sign_click}
222211
className={cn(styles['footer__left__button'])}
223-
title={component_dictionary.insert_symbol}
212+
title="Insert symbol"
224213
>
225214
<span>@</span>
226215
</button>
227216
)}
228217
<button
229218
onClick={props.on_curly_braces_click}
230219
className={cn(styles['footer__left__button'])}
231-
title={component_dictionary.prompt_templates}
220+
title="Prompt templates"
232221
>
233222
<span className="codicon codicon-json" />
234223
</button>
@@ -242,7 +231,7 @@ export const ChatInput: React.FC<ChatInputProps> = (props) => {
242231
{props.token_count !== undefined && props.token_count > 1 && (
243232
<div
244233
className={styles.footer__right__count}
245-
title={component_dictionary.approximate_token_count}
234+
title="Approximate message length in tokens"
246235
>
247236
{format_token_count(props.token_count)}
248237
</div>
@@ -266,7 +255,7 @@ export const ChatInput: React.FC<ChatInputProps> = (props) => {
266255
</div>
267256
)}
268257
<Icon variant="ENTER" />
269-
<span>{component_dictionary.select}</span>
258+
<span>Select...</span>
270259
</button>
271260

272261
<button
@@ -275,7 +264,7 @@ export const ChatInput: React.FC<ChatInputProps> = (props) => {
275264
title={props.use_last_choice_button_title}
276265
>
277266
<Icon variant="ENTER" />
278-
<span>{component_dictionary.use_last_choice}</span>
267+
<span>Use last choice</span>
279268
</button>
280269
</>
281270
)}
@@ -287,10 +276,10 @@ export const ChatInput: React.FC<ChatInputProps> = (props) => {
287276
e.stopPropagation()
288277
props.on_copy()
289278
}}
290-
title={component_dictionary.copy_to_clipboard}
279+
title="Copy to clipboard"
291280
>
292281
<Icon variant="ENTER" />
293-
<span>{component_dictionary.copy_to_clipboard}</span>
282+
<span>Copy to clipboard</span>
294283
</button>
295284
)}
296285
</div>

‎packages/ui/src/components/editor/Configurations/Configurations.tsx‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
import styles from './Configurations.module.scss'
22
import { DEFAULT_TEMPERATURE } from '@shared/constants/api-tools'
33
import cn from 'classnames'
4-
import { dictionary } from '@shared/constants/dictionary'
54
import { IconButton } from '../IconButton'
65
import { ReactSortable } from 'react-sortablejs'
76

8-
const dict = dictionary['Configurations.tsx']
9-
107
export namespace Configurations {
118
export type Configuration = {
129
id: string
@@ -32,7 +29,7 @@ export const Configurations: React.FC<Configurations.Props> = (props) => {
3229
return (
3330
<div className={styles.container}>
3431
<div className={styles.heading}>
35-
<div className={styles['heading__title']}>{dict.my_configurations}</div>
32+
<div className={styles['heading__title']}>MY CONFIGURATIONS</div>
3633

3734
<IconButton
3835
codicon_icon="edit"

‎packages/ui/src/components/editor/Presets/Presets.tsx‎

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import cn from 'classnames'
55
import { ReactSortable } from 'react-sortablejs'
66
import { Icon } from '../Icon'
77
import { CHATBOTS } from '@shared/constants/chatbots'
8-
import { dictionary } from '@shared/constants/dictionary'
98
import { use_context_menu } from '../../../hooks/use-context-menu'
109

1110
export const chatbot_to_icon: Record<keyof typeof CHATBOTS, Icon.Variant> = {
@@ -101,9 +100,7 @@ export const Presets: React.FC<Presets.Props> = (props) => {
101100
return (
102101
<div className={styles.container}>
103102
<div className={styles['my-presets']}>
104-
<div className={styles['my-presets__left']}>
105-
{dictionary['Presets.tsx'].my_chat_presets}
106-
</div>
103+
<div className={styles['my-presets__left']}>{'MY CHAT PRESETS'}</div>
107104
<IconButton codicon_icon="add" on_click={props.on_create_preset} />
108105
</div>
109106

@@ -264,8 +261,8 @@ export const Presets: React.FC<Presets.Props> = (props) => {
264261
on_click={(e) => e.stopPropagation()}
265262
title={
266263
preset.is_selected
267-
? dictionary['Presets.tsx'].unset_as_selected
268-
: dictionary['Presets.tsx'].set_as_selected
264+
? 'Unset as selected'
265+
: 'Set as selected'
269266
}
270267
/>
271268
)}
@@ -278,11 +275,7 @@ export const Presets: React.FC<Presets.Props> = (props) => {
278275
<div
279276
className={styles['presets__item__left__collapse-icon']}
280277
style={{ cursor: 'pointer' }}
281-
title={
282-
preset.is_collapsed
283-
? dictionary['Presets.tsx'].expand_group
284-
: dictionary['Presets.tsx'].collapse_group
285-
}
278+
title={preset.is_collapsed ? 'Expand' : 'Collapse'}
286279
onClick={(e) => {
287280
e.stopPropagation()
288281
props.on_toggle_group_collapsed(preset.name)
@@ -312,7 +305,7 @@ export const Presets: React.FC<Presets.Props> = (props) => {
312305
(preset.prompt_prefix || preset.prompt_suffix) && (
313306
<IconButton
314307
codicon_icon="copy"
315-
title={dictionary['Presets.tsx'].copy_to_clipboard}
308+
title="Copy to clipboard"
316309
on_click={(e) => {
317310
e.stopPropagation()
318311
props.on_preset_copy(preset.name)
@@ -321,23 +314,23 @@ export const Presets: React.FC<Presets.Props> = (props) => {
321314
)}
322315
<IconButton
323316
codicon_icon="files"
324-
title={dictionary['Presets.tsx'].duplicate}
317+
title="Duplicate"
325318
on_click={(e) => {
326319
e.stopPropagation()
327320
props.on_preset_duplicate(preset.name)
328321
}}
329322
/>
330323
<IconButton
331324
codicon_icon="edit"
332-
title={dictionary['Presets.tsx'].edit}
325+
title="Edit"
333326
on_click={(e) => {
334327
e.stopPropagation()
335328
props.on_preset_edit(preset.name)
336329
}}
337330
/>
338331
<IconButton
339332
codicon_icon="trash"
340-
title={dictionary['Presets.tsx'].delete}
333+
title="Delete"
341334
on_click={(e) => {
342335
e.stopPropagation()
343336
props.on_preset_delete(preset.name)
@@ -369,7 +362,7 @@ export const Presets: React.FC<Presets.Props> = (props) => {
369362
close_context_menu()
370363
}}
371364
>
372-
{dictionary['Presets.tsx'].run_without_submission}
365+
{'Run without submission'}
373366
</div>
374367
</div>
375368
)}

‎packages/ui/src/components/editor/modals/CommitMessageModal/CommitMessageModal.tsx‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ import styles from './CommitMessageModal.module.scss'
33
import { Button } from '../../Button'
44
import { Modal } from '../Modal'
55
import TextareaAutosize from 'react-textarea-autosize'
6-
import { dictionary } from '@shared/constants/dictionary'
7-
8-
const dict = dictionary['CommitMessageModal.tsx']
96

107
type Props = {
118
commit_message: string
@@ -52,7 +49,7 @@ export const CommitMessageModal: React.FC<Props> = (props) => {
5249
return (
5350
<Modal>
5451
<div className={styles.container}>
55-
<div className={styles.title}>{dict.commit_changes}</div>
52+
<div className={styles.title}>Commit changes</div>
5653
<TextareaAutosize
5754
className={styles.textarea}
5855
value={message}
@@ -68,14 +65,14 @@ export const CommitMessageModal: React.FC<Props> = (props) => {
6865
/>
6966
<div className={styles.actions}>
7067
<Button on_click={props.on_cancel} is_secondary={true}>
71-
{dict.cancel}
68+
Cancel
7269
</Button>
7370
<Button
7471
on_click={handle_accept}
7572
disabled={!message.trim()}
7673
is_focused={true}
7774
>
78-
{dict.commit}
75+
Commit
7976
{is_timer_active && countdown > 0 && ` (${countdown})`}
8077
</Button>
8178
</div>

‎packages/ui/src/components/editor/settings/Layout/Layout.module.scss‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
}
2727

2828
&__title {
29-
font-size: 22px;
29+
font-size: 24px;
3030
font-weight: 600;
3131
padding-left: 8px;
3232
}

0 commit comments

Comments
 (0)