最近在学 typescript,试着写了个非常迷你的 i18n 工具,百分百覆盖的单元测试,压缩后不到 1kb,
資深大佬 : KouShuiYu 1
Example
const i18n = new I18n({ locale: 'zh', fallbackLocale: 'zh', messages: { zh: { hello: "你好 世界", say: { thanks: "{name} 谢谢" } }, en: { hello: "hello world", say: { thanks: "thanks {name}" } } } }); i18n.t('hello') // 你好 世界 i18n.t('say.thanks', {name: 'xiaohong'}) // xiaohong 谢谢
Demo
Documentation
大佬有話說 (0)