Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added English Version #188

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

NextThread
Copy link

#160
Added English version

@c121914yu
Copy link
Collaborator

c121914yu commented Aug 19, 2023

  • You cann't use useTranslation in not-hook pages.
  • For these api files, you only need to return English and use useTranslation to translate after FE receives English.

I suggest you try to translate this file first: client/src/pages/account/index.tsx

Finally, for t(""), you need to fill in the string in English, not Chinese, and the Chinese translation should be placed in client/public/locales/zh/common.json, the English translation in client/public/locales/en/common.json.

For example: 登出

You should write: t('account.Log out'), and add translate json:

client/public/locales/zh/common.json

{
....
account: {
   Log out: "登出"
}
...
}

client/public/locales/en/common.json

{
....
account: {
   Log out: "Log out"
}
...
}
``

@c121914yu
Copy link
Collaborator

https://github.com/labring/FastGPT/pull/188/files#diff-a230fda8fcaeb65e8d9d6c6a7e46be5ab91f3b77f8fbd27bf477f7130b24457c
https://github.com/labring/FastGPT/pull/188/files#diff-1765c82f6dd349c4a5efe6884d44b21f0f0bdfd864fab200ced0bb2bd0f722cf
https://github.com/labring/FastGPT/pull/188/files#diff-f8c980e5d5a5fd5b2fcf72dfcb59b7041d3362cd80409341b8f19ab3851b7d25
尝试翻译此文件:client/src/pages/account/index.tsx
难道我又走错路了?请确认

@c121914yu

yes.

  1. You need to write English in t(), not Chinese.
  2. You need to add the corresponding translation in local.
  3. You can install vscode's “I18n Ally” plugin to assist with translation.

I mean, you can try to modify the file: client/src/pages/account/index, so that I can help you to correct. This pr is too big for me to comment on one by one

@NextThread
Copy link
Author

NextThread commented Aug 26, 2023

@c121914yu

Screenshot 2023-08-27 at 12 27 06 AM
  1. Added the English inside t()
Screenshot 2023-08-27 at 12 28 33 AM
  1. Added the corresponding in common.json

@c121914yu
Copy link
Collaborator

@c121914yu

Screenshot 2023-08-27 at 12 27 06 AM
  1. Added the English inside t()
Screenshot 2023-08-27 at 12 28 33 AM
  1. Added the corresponding in common.json

yes!
We recommend that translations add prefixes by module.

example:
Confirm to log out > account.Confirm to log out.

Prefixes are roughly divided: account, app, chat, kb, common

@c121914yu
Copy link
Collaborator

@c121914yu

Screenshot 2023-08-27 at 12 27 06 AM
  1. Added the English inside t()
Screenshot 2023-08-27 at 12 28 33 AM
  1. Added the corresponding in common.json

and please fetch and rebase latest code

@NextThread
Copy link
Author

Hi @c121914yu , I did the required changes, please review it

@@ -60,7 +60,7 @@ export const streamFetch = ({
});
} else {
return reject({
message: errMsg || '响应过程出现异常~',
message: errMsg || 'There is an exception in the response process~',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The server error prompt can not be translated first, I think about the server error how to implement i18n

@@ -63,7 +65,7 @@ const APIKeyModal = ({ onClose }: { onClose: () => void }) => {
API 秘钥管理
</Box>
<Box fontSize={'sm'} color={'myGray.600'}>
如果你不想 API 秘钥被滥用,请勿将秘钥直接放置在前端使用~
{t('如果你不想 API 秘钥被滥用,请勿将秘钥直接放置在前端使用~')}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to write it in English.
Example: t('user.Open API Tips')

en: If you do not want the API key to be abused, do not place the key directly on the front end

zh: 如果你不想 API 秘钥被滥用,请勿将秘钥直接放置在前端使用~

@@ -16,7 +16,7 @@ const ContextModal = ({
<MyModal
isOpen={true}
onClose={onClose}
title={`完整对话记录(${context.length}条)`}
title={t(`full conversation log(${context.length}strip)`)}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it is a translation with variables, you need to write:
t('chat.Full Context n strip', {length: context.length})

en.json:

"chat":{
    "Full Context n strip": "Full context ({{length}}) strip"
}

zh.json

"chat":{
    "Full Context n strip": "完整对话记录 ({{length}}) 条"
}

@c121914yu
Copy link
Collaborator

You need to pull the latest code and resolve conflicts first, and I recommend committing a small amount of code first. And I gave some code comment.

There are too many modified files, it is not convenient for me to merge after correction, please submit fewer files for the first time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants