Skip to content

Commit

Permalink
feat: add i18n text
Browse files Browse the repository at this point in the history
  • Loading branch information
wwwenjie committed Apr 25, 2021
1 parent 2e495cf commit cbcf576
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/components/organisms/Home/Post.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ import { usePosts } from '@data'
import { Button } from '@components/atoms'
import { useHistory } from 'react-router-dom'
import { FooterButtonGroup, PostCard } from '@components/molecules'
import { useTranslation } from 'react-i18next'

export const Post: FC = () => {
const { t } = useTranslation()
const { data: posts, loading, error } = usePosts()
const history = useHistory()

Expand All @@ -23,7 +25,7 @@ export const Post: FC = () => {
))}
</div>
<Button className="my-4" onClick={handleBackClick}>
Go Back
{t('goBack')}
</Button>
<FooterButtonGroup />
</div>
Expand Down
4 changes: 3 additions & 1 deletion src/components/organisms/Landing/Landing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import React, { FC } from 'react'
import { Button, Description, Logo } from '@components/atoms'
import { FooterButtonGroup, LinkGroup } from '@components/molecules'
import { useHistory } from 'react-router-dom'
import { useTranslation } from 'react-i18next'

export const Landing: FC = () => {
const { t } = useTranslation()
const history = useHistory()

const handleDataButtonClick = () => {
Expand All @@ -15,7 +17,7 @@ export const Landing: FC = () => {
<Logo />
<Description />
<Button className="my-2" onClick={handleDataButtonClick}>
Data fetching example
{t('dataFetchingExample')}
</Button>
<FooterButtonGroup />
<LinkGroup />
Expand Down
2 changes: 2 additions & 0 deletions src/locales/en/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
"desc": "Opinionated React Starter Template",
"learn": "Learn",
"docs": "Docs",
"goBack": "Go Back",
"dataFetchingExample": "Data fetching example",
"notFound": "Sorry, the page you visited does not exist."
}
2 changes: 2 additions & 0 deletions src/locales/zh-CN/translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,7 @@
"desc": "固执己见的 React 起手式模版",
"learn": "学习",
"docs": "文档",
"goBack": "返回",
"dataFetchingExample": "数据获取示例",
"notFound": "抱歉,您访问的页面不存在"
}

0 comments on commit cbcf576

Please sign in to comment.