Skip to content

Commit

Permalink
Guide users what to do next when users meet http 429 in using Bing so…
Browse files Browse the repository at this point in the history
…urce
  • Loading branch information
chunibyocola committed Dec 19, 2023
1 parent b52faa4 commit 2a29224
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 1 deletion.
3 changes: 3 additions & 0 deletions public/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,9 @@
"sentenceRefreshPage": {
"message": "Refresh page"
},
"sentenceBingHttp429": {
"message": "(Too Many Requests) You may need to go to the official website to translate and complete the verification before you can continue to use it. Official website:"
},
"contextMenus_OPEN_THIS_PAGE_WITH_PDF_VIEWER": {
"message": "Open this page with PDF viewer"
},
Expand Down
3 changes: 3 additions & 0 deletions public/_locales/ja/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,9 @@
"sentenceRefreshPage": {
"message": "ページを更新"
},
"sentenceBingHttp429": {
"message": "(リクエストが多すぎます)利用を継続する前に、公式サイトで翻訳し、検証を完了する必要があるかもしれない。公式サイト:"
},
"contextMenus_OPEN_THIS_PAGE_WITH_PDF_VIEWER": {
"message": "PDFビューアでこのページを開く"
},
Expand Down
3 changes: 3 additions & 0 deletions public/_locales/zh_CN/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,9 @@
"sentenceRefreshPage": {
"message": "刷新页面"
},
"sentenceBingHttp429": {
"message": "(请求过多)你可能需要前往官网进行翻译并完成验证后才能继续使用。官网:"
},
"contextMenus_OPEN_THIS_PAGE_WITH_PDF_VIEWER": {
"message": "用 PDF 阅读器打开此页面"
},
Expand Down
3 changes: 3 additions & 0 deletions public/_locales/zh_TW/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,9 @@
"sentenceRefreshPage": {
"message": "刷新頁面"
},
"sentenceBingHttp429": {
"message": "(請求過多)你可能需要前往官網進行翻譯並完成驗證後才能繼續使用。官網:"
},
"contextMenus_OPEN_THIS_PAGE_WITH_PDF_VIEWER": {
"message": "用 PDF 閱讀器打開此頁面"
},
Expand Down
16 changes: 15 additions & 1 deletion src/components/TranslateResult/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import ErrorMessage from '../ErrorMessage';
import IconFont from '../IconFont';
import ListenButton from '../ListenButton';
import './style.css';
import { BING_COM } from '../../constants/translateSource';

type TranslateResultProps = {
translateRequest: TranslateRequest;
Expand All @@ -27,7 +28,20 @@ const TranslateResult: React.FC<TranslateResultProps> = ({ translateRequest, sou
translateRequest.status === 'init' ?
getMessage('contentTranslateAfterInput') :
translateRequest.status === 'error' ?
<ErrorMessage errorCode={translateRequest.errorCode} retry={retry} /> :
<>
<ErrorMessage errorCode={translateRequest.errorCode} retry={retry} />
{retry && translateRequest.errorCode.includes('429') && source === BING_COM && <>
<br />
<span>{getMessage('sentenceBingHttp429')}</span>
<a
href={`https://${getOptions().useDotCn ? 'cn' : 'www'}.bing.com/translator/?ref=TThis&text=test&from=en&to=zh-Hans`}
rel='noreferrer'
target='_blank'
>
{`${getOptions().useDotCn ? 'cn' : 'www'}.bing.com/translator`}
</a>
</>}
</> :
<>
{((displayOfTranslation.phonetic && translateRequest.result.from === LANG_EN)
|| (displayOfTranslation.phonetic_nonEnglish && translateRequest.result.from !== LANG_EN))
Expand Down

0 comments on commit 2a29224

Please sign in to comment.