Skip to content

Commit

Permalink
🌏 i18n: Improve clarity of English translation (danny-avila#3154)
Browse files Browse the repository at this point in the history
* 🌏 i18n: Improve clarity of English translation

* 🔧 fix(useCategories): replace i18n string to `com_ui_select_a_category`

* 🔨 refactor: avoid using placeholder strings where possible

This commit simplifies the internationalization approach for English language strings by removing the placeholder ones where they are used only once. This makes proper localization possible for Russian language, and possibly others.

Also renamed `com_ui_text_prompt` to `com_ui_prompt_text` to match the alphabetical order.

* 🎨 style(CreatePromptForm): add missing margin-top to the submit button
  • Loading branch information
KiGamji authored Jun 24, 2024
1 parent e2867ee commit eef894e
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 20 deletions.
2 changes: 1 addition & 1 deletion client/src/components/Prompts/Groups/CategorySelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const CategorySelector = ({
showLabel={false}
emptyTitle={true}
showOptionIcon={true}
searchPlaceholder={localize('com_ui_search_var', localize('com_ui_categories'))}
searchPlaceholder={localize('com_ui_search_categories')}
className={cn('h-10 w-56 cursor-pointer', className)}
currentValueClass="text-md gap-2"
optionsListClass="text-sm max-h-72"
Expand Down
10 changes: 5 additions & 5 deletions client/src/components/Prompts/Groups/CreatePromptForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ const CreatePromptForm = ({
<Controller
name="name"
control={control}
rules={{ required: localize('com_ui_is_required', localize('com_ui_prompt_name')) }}
rules={{ required: localize('com_ui_prompt_name_required') }}
render={({ field }) => (
<div className="mb-1 flex items-center md:mb-0">
<Input
Expand Down Expand Up @@ -127,13 +127,13 @@ const CreatePromptForm = ({
<div className="w-full md:mt-[1.075rem]">
<div>
<h2 className="flex items-center justify-between rounded-t-lg border border-gray-300 py-2 pl-4 pr-1 text-base font-semibold dark:border-gray-600 dark:text-gray-200">
{localize('com_ui_text_prompt')}*
{localize('com_ui_prompt_text')}*
</h2>
<div className="mb-4 min-h-32 rounded-b-lg border border-gray-300 p-4 transition-all duration-150 dark:border-gray-600">
<Controller
name="prompt"
control={control}
rules={{ required: localize('com_ui_is_required', localize('com_ui_text_prompt')) }}
rules={{ required: localize('com_ui_prompt_text_required') }}
render={({ field }) => (
<div>
<TextareaAutosize
Expand All @@ -159,14 +159,14 @@ const CreatePromptForm = ({
onValueChange={(value) => methods.setValue('oneliner', value)}
tabIndex={3}
/>
<div className="flex justify-end">
<div className="mt-4 flex justify-end">
<Button
tabIndex={5}
type="submit"
variant="default"
disabled={!isDirty || isSubmitting || !isValid}
>
{localize('com_ui_create_var', localize('com_ui_prompt'))}
{localize('com_ui_create_prompt')}
</Button>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/Prompts/Groups/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default function List({
className="mx-2 w-full px-3"
onClick={() => navigate('/d/prompts/new')}
>
+ {localize('com_ui_create_var', localize('com_ui_prompt'))}
+ {localize('com_ui_create_prompt')}
</Button>
</div>
)}
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/Prompts/Groups/NoPromptGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default function NoPromptGroup() {
navigate('/d/prompts');
}}
>
{localize('com_ui_back_to_var', localize('com_ui_prompts'))}
{localize('com_ui_back_to_prompts')}
</Button>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/Prompts/PromptDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const PromptDetails = ({ group }: { group: TPromptGroup }) => {
<div className="flex-1 overflow-y-auto border-gray-300 p-0 dark:border-gray-600 md:max-h-[calc(100vh-150px)] md:p-4">
<div>
<h2 className="flex items-center justify-between rounded-t-lg border border-gray-300 py-2 pl-4 text-base font-semibold dark:border-gray-600 dark:text-gray-200">
{localize('com_ui_text_prompt')}
{localize('com_ui_prompt_text')}
</h2>
<div className="group relative mb-4 min-h-32 rounded-b-lg border border-gray-300 p-4 transition-all duration-150 dark:border-gray-600">
<span className="block break-words px-2 py-1 dark:text-gray-200">{promptText}</span>
Expand Down
2 changes: 1 addition & 1 deletion client/src/components/Prompts/PromptEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const PromptEditor: React.FC<Props> = ({ name, isEditing, setIsEditing }) => {
return (
<div>
<h2 className="flex items-center justify-between rounded-t-lg border border-gray-300 py-2 pl-4 text-base font-semibold dark:border-gray-600 dark:text-gray-200">
{localize('com_ui_text_prompt')}
{localize('com_ui_prompt_text')}
<div className="flex flex-row gap-6">
{editorMode === PromptsEditorMode.ADVANCED && (
<AlwaysMakeProd className="hidden sm:flex" />
Expand Down
2 changes: 1 addition & 1 deletion client/src/hooks/Prompts/useCategories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const useCategories = (className = '') => {
data.map((category) => ({
label: category.label
? localize(`com_ui_${category.label}`) || category.label
: localize('com_ui_none_selected'),
: localize('com_ui_select_a_category'),
value: category.value,
icon: category.value ? (
<CategoryIcon category={category.value} className={className} />
Expand Down
20 changes: 11 additions & 9 deletions client/src/localization/languages/Eng.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ export default {
'It appears that the content submitted has been flagged by our moderation system for not aligning with our community guidelines. We\'re unable to proceed with this specific topic. If you have any other questions or topics you\'d like to explore, please edit your message, or create a new conversation.',
com_error_no_user_key: 'No key found. Please provide a key and try again.',
com_error_no_base_url: 'No base URL found. Please provide one and try again.',
com_error_invalid_user_key: 'Invalid key provided. Please provide a key and try again.',
com_error_invalid_user_key:
'Invalid key provided. Please provide a valid key and try again.',
com_error_expired_user_key:
'Provided key for {0} expired at {1}. Please provide a key and try again.',
'Provided key for {0} expired at {1}. Please provide a new key and try again.',
com_files_no_results: 'No results.',
com_files_filter: 'Filter files...',
com_files_number_selected: '{0} of {1} file(s) selected',
Expand Down Expand Up @@ -130,13 +131,14 @@ export default {
com_ui_admin_settings: 'Admin Settings',
com_ui_error_save_admin_settings: 'There was an error saving your admin settings.',
com_ui_prompt_preview_not_shared: 'The author has not allowed collaboration for this prompt.',
com_ui_is_required: '{0} is required',
com_ui_text_prompt: 'Text',
com_ui_prompt_name_required: 'Prompt Name is required',
com_ui_prompt_text_required: 'Text is required',
com_ui_prompt_text: 'Text',
com_ui_back_to_chat: 'Back to Chat',
com_ui_back_to_var: 'Back to {0}',
com_ui_back_to_prompts: 'Back to Prompts',
com_ui_categories: 'Categories',
com_ui_filter_prompts_name: 'Filter prompts by name',
com_ui_search_var: 'Search {0}',
com_ui_search_categories: 'Search Categories',
com_ui_manage: 'Manage',
com_ui_variables: 'Variables',
com_ui_variables_info:
Expand Down Expand Up @@ -229,7 +231,7 @@ export default {
com_ui_assistants_output: 'Assistants Output',
com_ui_delete: 'Delete',
com_ui_create: 'Create',
com_ui_create_var: 'Create {0}',
com_ui_create_prompt: 'Create Prompt',
com_ui_share: 'Share',
com_ui_share_var: 'Share {0}',
com_ui_copy_link: 'Copy link',
Expand Down Expand Up @@ -603,7 +605,7 @@ export default {
com_nav_archive_all_chats: 'Archive all chats',
com_nav_archive_all: 'Archive all',
com_nav_archive_name: 'Name',
com_nav_archive_created_at: 'DateCreated',
com_nav_archive_created_at: 'Date Archived',
com_nav_clear_conversation: 'Clear conversations',
com_nav_clear_conversation_confirm_message:
'Are you sure you want to clear all conversations? This is irreversible.',
Expand Down Expand Up @@ -637,7 +639,7 @@ export default {
'When enabled, the text and attachments you enter in the chat form will be automatically saved locally as drafts. These drafts will be available even if you reload the page or switch to a different conversation. Drafts are stored locally on your device and are deleted once the message is sent.',
com_nav_info_fork_change_default:
'`Visible messages only` includes just the direct path to the selected message. `Include related branches` adds branches along the path. `Include all to/from here` includes all connected messages and branches.',
com_nav_info_fork_split_target_setting: 'idk what this does 🤷‍♂️',
com_nav_info_fork_split_target_setting: 'When enabled, forking will commence from the target message to the latest message in the conversation, according to the behavior selected.',
com_nav_info_user_name_display:
'When enabled, the username of the sender will be shown above each message you send. When disabled, you will only see "You" above your messages.',
com_nav_info_latex_parsing:
Expand Down

0 comments on commit eef894e

Please sign in to comment.