Skip to content

Commit

Permalink
chore: update chinese locales (mckaywrigley#247)
Browse files Browse the repository at this point in the history
* chore: update chinese locales

* chore: update locales
  • Loading branch information
Chanzhaoyu authored Mar 28, 2023
1 parent a78a8c4 commit 28c8bf0
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 15 deletions.
24 changes: 15 additions & 9 deletions components/Promptbar/PromptModal.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Prompt } from '@/types/prompt';
import { FC, KeyboardEvent, useEffect, useRef, useState } from 'react';
import { useTranslation } from 'next-i18next';

interface Props {
prompt: Prompt;
Expand All @@ -8,6 +9,7 @@ interface Props {
}

export const PromptModal: FC<Props> = ({ prompt, onClose, onUpdatePrompt }) => {
const { t } = useTranslation('promptbar');
const [name, setName] = useState(prompt.name);
const [description, setDescription] = useState(prompt.description);
const [content, setContent] = useState(prompt.content);
Expand Down Expand Up @@ -42,11 +44,11 @@ export const PromptModal: FC<Props> = ({ prompt, onClose, onUpdatePrompt }) => {

return (
<div
className="z-100 fixed inset-0 flex items-center justify-center bg-black bg-opacity-50"
className="fixed inset-0 flex items-center justify-center bg-black bg-opacity-50 z-100"
onKeyDown={handleEnter}
>
<div className="fixed inset-0 z-10 overflow-y-auto">
<div className="flex min-h-screen items-center justify-center px-4 pt-4 pb-20 text-center sm:block sm:p-0">
<div className="flex items-center justify-center min-h-screen px-4 pt-4 pb-20 text-center sm:block sm:p-0">
<div
className="hidden sm:inline-block sm:h-screen sm:align-middle"
aria-hidden="true"
Expand All @@ -58,7 +60,7 @@ export const PromptModal: FC<Props> = ({ prompt, onClose, onUpdatePrompt }) => {
role="dialog"
>
<div className="text-sm font-bold text-black dark:text-neutral-200">
Name
{t('Name')}
</div>
<input
ref={nameInputRef}
Expand All @@ -69,32 +71,36 @@ export const PromptModal: FC<Props> = ({ prompt, onClose, onUpdatePrompt }) => {
/>

<div className="mt-6 text-sm font-bold text-black dark:text-neutral-200">
Description
{t('Description')}
</div>
<textarea
className="mt-2 w-full rounded-lg border border-neutral-500 px-4 py-2 text-neutral-900 shadow focus:outline-none dark:border-neutral-800 dark:border-opacity-50 dark:bg-[#40414F] dark:text-neutral-100"
style={{ resize: 'none' }}
placeholder="A description for your prompt."
placeholder={t('A description for your prompt.') || ''}
value={description}
onChange={(e) => setDescription(e.target.value)}
rows={3}
/>

<div className="mt-6 text-sm font-bold text-black dark:text-neutral-200">
Prompt
{t('Prompt')}
</div>
<textarea
className="mt-2 w-full rounded-lg border border-neutral-500 px-4 py-2 text-neutral-900 shadow focus:outline-none dark:border-neutral-800 dark:border-opacity-50 dark:bg-[#40414F] dark:text-neutral-100"
style={{ resize: 'none' }}
placeholder="Prompt content. Use {{}} to denote a variable. Ex: {{name}} is a {{adjective}} {{noun}}"
placeholder={
t(
'Prompt content. Use {{}} to denote a variable. Ex: {{name}} is a {{adjective}} {{noun}}',
) || ''
}
value={content}
onChange={(e) => setContent(e.target.value)}
rows={10}
/>

<button
type="button"
className="mt-6 w-full rounded-lg border border-neutral-500 px-4 py-2 text-neutral-900 shadow hover:bg-neutral-100 focus:outline-none dark:border-neutral-800 dark:border-opacity-50 dark:bg-white dark:text-black dark:hover:bg-neutral-300"
className="w-full px-4 py-2 mt-6 border rounded-lg shadow border-neutral-500 text-neutral-900 hover:bg-neutral-100 focus:outline-none dark:border-neutral-800 dark:border-opacity-50 dark:bg-white dark:text-black dark:hover:bg-neutral-300"
onClick={() => {
const updatedPrompt = {
...prompt,
Expand All @@ -107,7 +113,7 @@ export const PromptModal: FC<Props> = ({ prompt, onClose, onUpdatePrompt }) => {
onClose();
}}
>
Save
{t('Save')}
</button>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion components/Promptbar/Promptbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export const Promptbar: FC<Props> = ({

{prompts.length > 1 && (
<Search
placeholder="Search prompts..."
placeholder={t('Search prompts...') || ''}
searchTerm={searchTerm}
onSearch={setSearchTerm}
/>
Expand Down
5 changes: 3 additions & 2 deletions pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ const Home: React.FC<HomeProps> = ({ serverSideApiKeyIsSet }) => {
</button>
<div
onClick={handleToggleChatbar}
className="absolute top-0 left-0 z-10 h-full w-full bg-black opacity-70 sm:hidden"
className="absolute top-0 left-0 z-10 w-full h-full bg-black opacity-70 sm:hidden"
></div>
</div>
) : (
Expand Down Expand Up @@ -713,7 +713,7 @@ const Home: React.FC<HomeProps> = ({ serverSideApiKeyIsSet }) => {
</button>
<div
onClick={handleTogglePromptbar}
className="absolute top-0 left-0 z-10 h-full w-full bg-black opacity-70 sm:hidden"
className="absolute top-0 left-0 z-10 w-full h-full bg-black opacity-70 sm:hidden"
></div>
</div>
) : (
Expand Down Expand Up @@ -741,6 +741,7 @@ export const getServerSideProps: GetServerSideProps = async ({ locale }) => {
'chat',
'sidebar',
'markdown',
'promptbar'
])),
},
};
Expand Down
7 changes: 5 additions & 2 deletions public/locales/zh/chat.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"OpenAI API Key Required": "需要 OpenAI API 密钥",
"Please set your OpenAI API key in the bottom left of the sidebar.": "请在侧边栏左下角设置您的 OpenAI API 密钥。",
"If you don't have an OpenAI API key, you can get one here: ": "如果你没有 OpenAI API 密钥,你可以在此获取:",
"Stop Generating": "停止生成",
"Prompt limit is {{maxLength}} characters": "提示字数限制为 {{maxLength}} 个字符",
"System Prompt": "系统提示",
Expand All @@ -12,14 +13,16 @@
"Conversation": "对话",
"OR": "",
"Loading...": "加载中...",
"Type a message...": "输入一条消息...",
"Type a message or type \"/\" to select a prompt...": "输入一条消息或键入 \"/\" 以选择提示...",
"Error fetching models.": "获取模型时出错。",
"AI": "AI",
"You": "",
"Cancel": "取消",
"Save & Submit": "保存并提交",
"Make sure your OpenAI API key is set in the bottom left of the sidebar.": "请确保您的 OpenAI API 密钥已在侧边栏左下角设置。",
"If you completed this step, OpenAI may be experiencing issues.": "如果您已完成此步骤,OpenAI 可能遇到了问题。",
"Message limit is {{maxLength}} characters. You have entered {{valueLength}} characters.": "消息字数限制为 {{maxLength}} 个字符。您已输入 {{valueLength}} 个字符。",
"Please enter a message": "请输入一条消息",
"Chatbot UI is an advanced chatbot kit for OpenAI's chat models aiming to mimic ChatGPT's interface and functionality.": "Chatbot UI 是一个高级聊天机器人工具包,旨在模仿 OpenAI 聊天模型的 ChatGPT 界面和功能。",
"Are you sure you want to clear all messages?": "你确定要清除所有的消息吗?"
}
}
12 changes: 12 additions & 0 deletions public/locales/zh/promptbar.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"New prompt": "新建提示",
"New folder": "新建文件夹",
"No prompts.": "无提示词",
"Search prompts...": "搜索提示...",
"Name": "名称",
"Description": "描述",
"A description for your prompt.": "提示词描述",
"Prompt": "提示词",
"Prompt content. Use {{}} to denote a variable. Ex: {{name}} is a {{adjective}} {{noun}}": "提示内容。使用 {{}} 表示一个变量。例如:{{name}} 是一个 {{adjective}} {{noun}}",
"Save": "保存"
}
2 changes: 1 addition & 1 deletion public/locales/zh/sidebar.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"New folder": "新建文件夹",
"New chat": "新建聊天",
"No conversations.": "无对话",
"No conversations.": "无对话",
"Search conversations...": "搜索对话...",
"OpenAI API Key": "OpenAI API 密钥",
"Import conversations": "导入对话",
Expand Down

0 comments on commit 28c8bf0

Please sign in to comment.