Last active
October 5, 2017 18:49
-
-
Save breakds/81a02890797165509c62b3bc01be5b4c to your computer and use it in GitHub Desktop.
Example: Multi-language support in React.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pages: | |
home: | |
title: 首页 | |
searchPlaceholder: 搜索功能尚未开放 | |
armor: | |
title: 防具 | |
armorSet: 套装 | |
produce: 生产 | |
weapon: | |
title: 武器 | |
upgrade: 升级 | |
produce: 生产 | |
shell: 弹药 | |
monster: | |
title: 怪物 | |
weakness: 肉质 | |
quest: | |
title: 任务 | |
fee: 入场费 | |
time: 限制时间 | |
minute: 分钟 | |
reward: 报酬 | |
empty: "没有满足条件的任务" | |
item: | |
title: 物品 | |
gathering: 采集 | |
jewel: | |
title: 珠子 | |
skill: | |
title: 技能 | |
weapons: | |
types: | |
GreatSword: | |
label: 大剑 | |
LongSword: | |
label: 太刀 | |
SwordShield: | |
label: 片手 | |
DualBlades: | |
label: 双刀 | |
Hammer: | |
label: 大锤 | |
HuntingHorn: | |
label: 狩猎笛 | |
Lance: | |
label: 长枪 | |
GunLance: | |
label: 铳枪 | |
SwitchAxe: | |
label: 斩斧 | |
ChargeBlade: | |
label: 盾斧 | |
InsectGlaive: | |
label: 操虫棍 | |
LightBowgun: | |
label: 轻弩 | |
HeavyBowgun: | |
label: 重弩 | |
Bow: | |
label: 弓 | |
shottype: | |
Normal: 通常 | |
Wide: 扩散 | |
Long: 放射 | |
Pierce: 贯通 | |
Rapid: 连射 | |
Spread: 扩散 | |
Heavy: 重射 | |
axephial: | |
Power: 强击瓶 | |
Paralyze: 麻痹瓶 | |
Poison: 毒瓶 | |
Dragon: 灭龙瓶 | |
Element: 强属性瓶 | |
Exhaust: 减气瓶 | |
Impact: 榴弹瓶 | |
arctype: | |
Wide: 放射型 | |
Focus: 集中型 | |
Blast: 爆裂型 | |
Power: 刚射型 | |
bowgun: | |
steady: | |
Steady: 无 | |
BothMild: 左右/小 | |
BothSevere: 左右/大 | |
LeftMild: 左侧/小 | |
LeftSevere: 左侧/大 | |
RightMild: 右侧/小 | |
RightSevere: 右侧/大 | |
reload: | |
Fast: 极快 | |
AboveAverage: 稍快 | |
Average: 普通 | |
BelowAverage: 稍慢 | |
Slow: 极慢 | |
recoil: | |
Low: 小 | |
Some: 偏小 | |
Average: 中 | |
High: 大 | |
insect: | |
Cutting: 切断 | |
Blunt: 打击 | |
properties: | |
Name: 名称 | |
Slots: 孔 | |
Rare: 稀有度 | |
Attack: 攻击 | |
Affinity: 会心 | |
Special: 属性 | |
Sharpness: 斩味 | |
Sharpness0: 斩味 | |
Sharpness1: 斩味+1 | |
Sharpness2: 斩味+2 | |
Notes: 音符 | |
GunLanceShotType: 射击类型 | |
AxePhial: 装填瓶 | |
Rapid: 速射 | |
RapidDetail: 速射 | |
Reload: 上弹 | |
Steadiness: 稳定性 | |
Recoil: 后坐力 | |
BowArc: 曲射 | |
BowShot: 射击类型 | |
InsectType: 猎虫 | |
# Item specific | |
Carry: 携带 | |
Sell: 出售 | |
Buy: 购买 | |
# Armor specific | |
Defense: 防御 | |
# Quest specific | |
Major: 主要怪 | |
Minor: 次要怪 | |
Importance: 关键 | |
specials: | |
Fire: | |
label: 火 | |
Water: | |
label: 水 | |
Thunder: | |
label: 雷 | |
Ice: | |
label: 冰 | |
Dragon: | |
label: 龙 | |
Poison: | |
label: 毒 | |
Paralyze: | |
label: 麻 | |
Sleep: | |
label: 睡 | |
Blast: | |
label: 爆 | |
obtaintype: | |
Gathering: 采集 | |
Fishing: 钓鱼 | |
Mining: 挖矿 | |
Catching: 捕虫 | |
monstertype: | |
Small: 小型 | |
Normal: 大型 | |
Nicknamed: 二名 | |
Ancient: 古龙 | |
monsterWeakness: | |
cut: 斩 | |
impact: 打 | |
shot: 射 | |
fire: 火 | |
water: 水 | |
ice: 冰 | |
thunder: 雷 | |
dragon: 龙 | |
dizzy: 晕 | |
armorRange: | |
BladeMaster: 剑士 | |
Gunner: 弓兵 | |
Both: 远近共用 | |
questIssuer: | |
Village: 村 | |
Hall: 集会 | |
Special: 特殊 | |
DLC: DLC | |
Unknown: 其他 | |
questRank: | |
Low: 下位 | |
High: 上位 | |
G: G级 | |
Unknown: 其他 | |
questImportance: | |
Key: 关键 | |
Urgent: 紧急 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pages: | |
home: | |
title: Home | |
searchPlaceholder: Search not implemented | |
armor: | |
title: Armor | |
armorSet: Set | |
produce: PRODUCE | |
weapon: | |
title: Weapon | |
upgrade: UPGRADE | |
produce: PRODUCE | |
shell: SHELL | |
monster: | |
title: Monster | |
weakness: Absorb | |
quest: | |
title: Quest | |
fee: Fee | |
time: Time | |
minute: Min | |
reward: Reward | |
empty: "No available quests." | |
item: | |
title: Item | |
gathering: GATHERING | |
jewel: | |
title: Jewel | |
skill: | |
title: Skill | |
weapons: | |
types: | |
GreatSword: | |
label: GreatSword | |
LongSword: | |
label: LongSword | |
SwordShield: | |
label: SwordShield | |
DualBlades: | |
label: DualBlades | |
Hammer: | |
label: Hammer | |
HuntingHorn: | |
label: Horn | |
Lance: | |
label: Lance | |
GunLance: | |
label: GunLance | |
SwitchAxe: | |
label: SwitchAxe | |
ChargeBlade: | |
label: ChargeBlade | |
InsectGlaive: | |
label: Glaive | |
LightBowgun: | |
label: LightGun | |
HeavyBowgun: | |
label: HeavyGun | |
Bow: | |
label: Bow | |
shottype: | |
Normal: Normal | |
Wide: Wide | |
Long: Long | |
Pierce: Pierce | |
Rapid: Rapid | |
Spread: Spread | |
Heavy: Heavy | |
axephial: | |
Power: Power | |
Paralyze: Prlyze | |
Poison: Poison | |
Dragon: Dragon | |
Element: Element | |
Exhaust: Exhaust | |
Impact: Impact | |
arctype: | |
Wide: Wide | |
Focus: Focus | |
Blast: Blast | |
Power: Power | |
bowgun: | |
steady: | |
Steady: None | |
BothMild: LR Mild | |
BothSevere: LR Severe | |
LeftMild: L Mild | |
LeftSevere: L Severe | |
RightMild: R Mild | |
RightSevere: R Severe | |
reload: | |
Fast: Fast | |
AboveAverage: Abv.Avg | |
Average: Avg. | |
BelowAverage: Bel.Avg | |
Slow: Slow | |
recoil: | |
Low: Low | |
Some: Some | |
Average: Avg. | |
High: High | |
insect: | |
Cutting: Cutting | |
Blunt: Blunt | |
properties: | |
Name: Name | |
Slots: Slots | |
Rare: Rare | |
Attack: Attack | |
Affinity: Affinity | |
Special: Special | |
Sharpness: Sharp | |
Sharpness0: Sharp | |
Sharpness1: Sharp+1 | |
Sharpness2: Sharp+2 | |
Notes: Notes | |
GunLanceShotType: Shot | |
AxePhial: Phial | |
Rapid: Rapid | |
RapidDetail: Rapid | |
Reload: Reload | |
Steadiness: Steady | |
Recoil: Recoil | |
BowArc: Arc | |
BowShot: Shot | |
InsectType: Insect | |
# Item specific | |
Carry: Carry | |
Sell: Sell | |
Buy: Buy | |
# Armor specific | |
Defense: Defense | |
# Quest specific | |
Major: Major | |
Minor: Minor | |
Importance: Key | |
specials: | |
Fire: | |
label: Fir | |
Water: | |
label: Wat | |
Thunder: | |
label: Thd | |
Ice: | |
label: Ice | |
Dragon: | |
label: Dra | |
Poison: | |
label: Poi | |
Paralyze: | |
label: Par | |
Sleep: | |
label: Slp | |
Blast: | |
label: Bla | |
obtaintype: | |
Gathering: Gather | |
Fishing: Fish | |
Mining: Mine | |
Catching: Catch | |
monstertype: | |
Small: Small | |
Normal: Normal | |
Nicknamed: Nicknamed | |
Ancient: Ancient | |
monsterWeakness: | |
cut: Cut | |
impact: Imp | |
shot: Shot | |
fire: Fir | |
water: Wat | |
ice: Ice | |
thunder: Thu | |
dragon: Dra | |
dizzy: Diz | |
armorRange: | |
BladeMaster: Blade | |
Gunner: Gun | |
Both: B/G | |
questIssuer: | |
Village: Village | |
Hall: Hall | |
Special: Special | |
DLC: DLC | |
Unknown: Other | |
questRank: | |
Low: Low | |
High: High | |
G: G | |
Unknown: Other | |
questImportance: | |
Key: Key | |
Urgent: Urgent | |
annoucement: The work is still under active development. Happy hunting! Feel free to contact mhxdexweb@sina.com. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import eng from "store/i18n/eng.yml"; | |
import chs from "store/i18n/chs.yml"; | |
const LanguageText = [ | |
{ | |
language: "English", | |
short: "eng", | |
corpus: eng | |
}, { | |
language: "Chinese", | |
short: "chs", | |
corpus: chs | |
} | |
]; | |
export default LanguageText; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { observable, computed, action, runInAction } from "mobx"; | |
import LANGUAGE_TEXT from "store/i18n"; | |
export default class State { | |
// Locale (i18n) support. | |
@observable languageId = 0; | |
@computed get corpus() { | |
return LANGUAGE_TEXT[this.languageId].corpus; | |
} | |
@computed get language() { | |
return LANGUAGE_TEXT[this.languageId].short; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Set global state
languageId
to either"eng"
or"chs"
so that all the reference tostore.corpus
will be updated to the corresponding language.