feature: full i18n support

This commit is contained in:
kkzzhizhou 2021-11-29 13:56:44 +08:00
parent 933c74804c
commit 6433c4c72a
10 changed files with 64 additions and 52 deletions

View file

@ -1,14 +1,14 @@
import * as React from "react";
import DailyItem from "./DailyItem"
import { Tab, Tabs, TabList, TabPanel } from "react-tabs";
import { Trans } from 'react-i18next';
import { Trans, useTranslation } from 'react-i18next';
export default function Index(props: any) {
const [title, setTitle] = React.useState('')
let { t ,i18n} = useTranslation()
if (props.dailys == undefined) {
return <div id="classDisplay">
<input type="text" placeholder="添加每日任务" onChange={event => setTitle(event.target.value)} />
<input type="text" placeholder={t('Add Daily Task')} onChange={event => setTitle(event.target.value)} />
<button className="submit-button" id="add-daily" onClick={props.onChange} name={title}><Trans>submit</Trans></button>
<Trans>No Dailies Present</Trans>
</div>
@ -32,7 +32,7 @@ export default function Index(props: any) {
<Tab><Trans>Completed</Trans></Tab>
</TabList>
<TabPanel>
<input type="text" id="task-input-box" placeholder="添加每日任务" onChange={event => setTitle(event.target.value)} value={title} />
<input type="text" id="task-input-box" placeholder={t('Add Daily Task')} onChange={event => setTitle(event.target.value)} value={title} />
<button className="submit-button" id="add-daily" onClick={function (e) { setTitle(""); props.onChange(e) }} name={title}><Trans>submit</Trans></button>
<div className="task-panel">
<ul>{incompleteDailies}</ul>

View file

@ -4,9 +4,10 @@ import { useTranslation, Trans, Translation } from 'react-i18next'
export default function Index(props: any){
const [title, setTitle] = React.useState('')
let { t ,i18n} = useTranslation()
if(props.habits == undefined) {
return (<div id="classDisplay">
<input type="text" placeholder="添加习惯" onChange={event => setTitle(event.target.value)} />
<input type="text" placeholder={t('Add Habit')} onChange={event => setTitle(event.target.value)} />
<button className="submit-button" id="add-habit" onClick={props.onChange} name={title}><Trans>submit</Trans></button>
<Trans>No habits present.</Trans>
</div>)
@ -18,7 +19,7 @@ export default function Index(props: any){
const display = <div id="classDisplay">
<input type="text" placeholder="添加习惯" onChange={event => setTitle(event.target.value)} />
<input type="text" placeholder={t('Add Habit')} onChange={event => setTitle(event.target.value)} />
<button className="submit-button" id="add-habit" onClick={props.onChange} name={title}><Trans>submit</Trans></button>
<ul>{allHabits}</ul>
</div>

View file

@ -1,12 +1,13 @@
import * as React from "react";
import RewardItem from "./RewardItem"
import { Trans } from 'react-i18next'
import { Trans,useTranslation } from 'react-i18next'
export default function Index(props: any){
const [title, setTitle] = React.useState('')
let { t ,i18n} = useTranslation()
if(props.rewards == undefined) {
return (<div id="classDisplay">
<input type="text" placeholder="添加奖励" onChange={event => setTitle(event.target.value)} />
<input type="text" placeholder={t('Add Reward')} onChange={event => setTitle(event.target.value)} />
<button className="submit-button" id="add-reward" onClick={props.onChange} name={title}><Trans>submit</Trans></button>
<Trans>No Rewards present.</Trans>
</div>)
@ -16,7 +17,7 @@ export default function Index(props: any){
return <RewardItem key={reward.id} id={reward.id} reward_text={reward.text} reward_notes={reward.notes} reward_value={reward.value} onChange={props.onChange}/>
})
const display = <div id="classDisplay">
<input type="text" placeholder="添加奖励" onChange={event => setTitle(event.target.value)} />
<input type="text" placeholder={t('Add Reward')} onChange={event => setTitle(event.target.value)} />
<button className="submit-button" id="add-reward" onClick={props.onChange} name={title}><Trans>submit</Trans></button>
<ul>{allRewards}</ul>
</div>

View file

@ -1,13 +1,14 @@
import * as React from "react";
import TodoItem from "./TodoItem"
import { Tab, Tabs, TabList, TabPanel } from "react-tabs";
import { Trans } from 'react-i18next'
import { Trans,useTranslation } from 'react-i18next'
export default function Index(props: any){
const [title, setTitle] = React.useState('')
let { t ,i18n} = useTranslation()
if(props.todos == undefined) {
return <div id="classDisplay">
<input type="text" placeholder="添加待办事项" onChange={event => setTitle(event.target.value)} />
<input type="text" placeholder={t('Add Todo')} onChange={event => setTitle(event.target.value)} />
<button className="submit-button" id="add-todo" onClick={props.onChange} name={title}><Trans>submit</Trans></button>
No Todos present.
</div>
@ -28,7 +29,7 @@ export default function Index(props: any){
<Tab><Trans>Completed</Trans></Tab>
</TabList>
<TabPanel>
<input type="text" placeholder="添加待办事项" onChange={event => setTitle(event.target.value)} />
<input type="text" placeholder={t('Add Todo')} onChange={event => setTitle(event.target.value)} />
<button className="submit-button" id="add-todo" onClick={props.onChange} name={title}><Trans>submit</Trans></button>
<ul>{incompleteTodos}</ul>
</TabPanel>