Skip to content

Commit

Permalink
Merge pull request #2776 from thematters/fix/i18n-component
Browse files Browse the repository at this point in the history
fix(i18): fallback to zh_hant only if en is nullish
  • Loading branch information
robertu7 authored Sep 14, 2022
2 parents c947d3f + aa330f3 commit 6ba9e70
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/common/utils/translate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,7 @@ export const translate = ({ lang, ...props }: TranslateArgs): string => {
translations = { zh_hant, zh_hans, en }
}

return translations[lang || 'zh_hant'] || translations.zh_hant
const translation = translations[lang || 'zh_hant']

return typeof translation === 'string' ? translation : translations.zh_hant
}
2 changes: 1 addition & 1 deletion src/components/Dialogs/ReviseArticleDialog/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const ReviseArticleDialog = ({ children, revisionCountLeft }: Props) => {
</p>
<p>
<b>
<Translate zh_hant="你還可以修訂" zh_hans="你还可以修订" en=" " />
<Translate zh_hant="你還可以修訂" zh_hans="你还可以修订" en="" />
<span className="count"> {revisionCountLeft} </span>
<Translate
zh_hant="版"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ const CircleNewBroadcastNotice = ({ notice }: { notice: NoticeType }) => {
<Translate
zh_hant={` 發布了新廣播`}
zh_hans={` 发布了新广播`}
en=" "
en=""
/>
</NoticeHead>

Expand Down
2 changes: 1 addition & 1 deletion src/views/ArticleDetail/EditMode/Header/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ const EditModeHeader = ({
<Translate
zh_hant="正文及作品管理剩 "
zh_hans="正文及作品管理剩 "
en=" "
en=""
/>
{revisionCountLeft}
<Translate
Expand Down

1 comment on commit 6ba9e70

@vercel
Copy link

@vercel vercel bot commented on 6ba9e70 Sep 14, 2022

Choose a reason for hiding this comment

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

Please sign in to comment.