Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 1ebddb4

Browse files
author
lei
committed
feat: 🎸 模式名称
1 parent 121657a commit 1ebddb4

File tree

3 files changed

+36
-9
lines changed

3 files changed

+36
-9
lines changed

‎public/locales/zh/translation.json

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,34 @@
2020
"Type": "类型",
2121
"Definition": "定义",
2222
"Use When": "使用场景",
23-
"creational":"创建型",
24-
"creational_desc":"这些设计模式都与类实例化有关。此模式可以细分为类创建模式和对象创建模式。类创建模式在实例化过程中使用继承,而对象创建模式使用委派。",
25-
"structural":"结构型",
26-
"structural_desc":"这些设计模式都是关于类和对象组合的。结构类创建模式使用继承来组合接口。结构对象模式定义了组合对象以获取新功能的方法。",
27-
"behavioral":"行为型",
28-
"behavioral_desc":"这些设计模式都是关于类的对象通信。行为模式是最具体关注对象之间通信的模式",
29-
"Abstract Factory":"抽象工厂(Abstract Factory)"
23+
"creational": "创建型",
24+
"creational_desc": "这些设计模式都与类实例化有关。此模式可以细分为类创建模式和对象创建模式。类创建模式在实例化过程中使用继承,而对象创建模式使用委派。",
25+
"structural": "结构型",
26+
"structural_desc": "这些设计模式都是关于类和对象组合的。结构类创建模式使用继承来组合接口。结构对象模式定义了组合对象以获取新功能的方法。",
27+
"behavioral": "行为型",
28+
"behavioral_desc": "这些设计模式都是关于类的对象通信。行为模式是最具体关注对象之间通信的模式",
29+
"Abstract Factory": "抽象工厂(Abstract Factory)",
30+
"Builder": "建造者(Builder)",
31+
"Factory": "工厂(Factory)",
32+
"Prototype": "原型(Prototype)",
33+
"Singleton": "单例(Singleton)",
34+
"Adapter": "适配器(Adapter)",
35+
"Bridge": "桥接(Bridge)",
36+
"Composite": "组合(Composite)",
37+
"Decorator": "装饰器(Decorator)",
38+
"Facade": "外观(Facade)",
39+
"Flyweight": "享元(Flyweight)",
40+
"Proxy": "代理(Proxy)",
41+
"Chain of Responsibility": "职责链(Chain of Responsibility)",
42+
"Command": "命令(Command)",
43+
"Interpreter": "解释器(Interpreter)",
44+
"Iterator": "迭代器(Iterator)",
45+
"Mediator": "中介者(Mediator)",
46+
"Memento": "备忘录(Memento)",
47+
"Observer": "观察者(Observer)",
48+
"State": "状态(State)",
49+
"Strategy": "策略(Strategy)",
50+
"Template": "模板(Template)",
51+
"Visitor": "访问者(Visitor)",
52+
"Try Again": "再试一次"
3053
}

‎src/components/ButtonContainer.jsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import Button from './Button';
66
import { submitAnswer } from '../actions/submitAnswer';
77
import { getCurrent, getPatterns } from '../selectors';
88
import { shuffle } from '../helpers/shuffleArray';
9+
import { useTranslation } from 'react-i18next';
910

1011
const StyledButtonContainer = styled.div`
1112
align-content: space-around;
@@ -17,6 +18,9 @@ const StyledButtonContainer = styled.div`
1718
`;
1819

1920
export const ButtonContainer = props => {
21+
22+
const { t } = useTranslation();
23+
2024
const { current, patterns, onSubmitAnswer } = props;
2125

2226
// get 3 random patterns in addition to correct one
@@ -28,7 +32,7 @@ export const ButtonContainer = props => {
2832
return (
2933
<StyledButtonContainer>
3034
{variants.map(({ uuid, name }) => (
31-
<Button label={name} id={uuid} key={uuid} onClick={() => onSubmitAnswer(uuid)} />
35+
<Button label={t(name)} id={uuid} key={uuid} onClick={() => onSubmitAnswer(uuid)} />
3236
))}
3337
</StyledButtonContainer>
3438
);

‎src/pages/Game.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ const Game = ({ intro, current, answers, style, onStart, onRestart }) => {
7676
<Result />
7777
<Percentage />
7878
<Restart>
79-
<Button label="Try Again" id="try_again" onClick={onRestart} />
79+
<Button label={t("Try Again")} id="try_again" onClick={onRestart} />
8080
</Restart>
8181
<ShareContainer>
8282
<GitHubButton

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /