-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0de088f
commit e857933
Showing
16 changed files
with
343 additions
and
33 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export default { | ||
"1": "首页", | ||
"2": "关于" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/** | ||
格式化器用来对翻译文本内容中的插值变量进行处理 | ||
如何编写格式器请参阅官网! | ||
*/ | ||
|
||
|
||
export default { | ||
// global : true, // 简单地设置为true,代表当前所有格式化器均注册到全局,false只在当前scope生效 | ||
// global : { // 仅将里面的格式化器注册到全局 | ||
// $config:{... } | ||
// xxxx : value => { ... }, | ||
// xxxx : (value,$config) => { ... }, | ||
// xxxx : (value,...args,$config) => { ... }, | ||
// xxxx : Formatter(value,...args,$config) => { ... }, | ||
// xxxx : FlexFormatter(value,params,$config) => { ... }, | ||
//}, // 是否注册到全局,false只在当前scope生效 | ||
// 直接对内置格式化器进行配置,请参阅官网文档 | ||
// $config:{ | ||
// datetime : { | ||
// units : ["Year","Quarter","Month","Week","Day","Hour","Minute","Second","Millisecond","Microsecond"], | ||
// date :{ | ||
// long : 'YYYY/MM/DD HH:mm:ss', | ||
// short : "YYYY/MM/DD", | ||
// format : "local" | ||
// }, | ||
// quarter : { | ||
// long : ["First Quarter","Second Quarter","Third Quarter","Fourth Quarter"], | ||
// short : ["Q1","Q2","Q3","Q4"], | ||
// format : "short" | ||
// }, | ||
// month:{ | ||
// long : ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], | ||
// short : ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sept", "Oct", "Nov", "Dec"], | ||
// format : "long" // 0-长名称,1-短名称,2-数字 | ||
// }, | ||
// weekday:{ | ||
// long : ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], | ||
// short : ["Sun", "Mon", "Tues", "Wed", "Thur", "Fri", "Sat"], | ||
// format : "long", // 0-长名称,1-短名称,2-数字 | ||
// }, | ||
// time : { | ||
// long : "HH:mm:ss", | ||
// short : "HH:mm:ss", | ||
// format : 'local' | ||
// }, | ||
// timeSlots : { | ||
// slots : [12], | ||
// lowerCases : ["am","pm"], | ||
// upperCases : ["AM","PM"] | ||
// }, | ||
// relativeTime : { | ||
// units : ["seconds","minutes","hours","days","weeks","months","years"], | ||
// now : "Now", | ||
// before : "{value} {unit} ago", | ||
// after : "after {value} {unit}" | ||
// } | ||
// }, | ||
// currency : { | ||
// default : "{symbol}{value}{unit}", | ||
// long : "{prefix} {symbol}{value}{unit}{suffix}", | ||
// short : "{symbol}{value}{unit}", | ||
// custom : "{prefix} {symbol}{value}{unit}{suffix}", | ||
// format : "default", | ||
// //-- | ||
// units : [""," thousands"," millions"," billions"," trillions"], //千,百万,十亿,万亿 | ||
// radix : 3, // 进制,即三位一进,中文是4位一进 | ||
// symbol : "$", // 符号 | ||
// prefix : "USD", // 前缀 | ||
// suffix : "", // 后缀 | ||
// division : 3, // ,分割位 | ||
// precision : 2, // 精度 | ||
|
||
// }, | ||
// number : { | ||
// division : 3, // , 分割位,3代表每3位添加一个, | ||
// precision : 0 // 精度,即保留小数点位置,0代表不限 | ||
// } | ||
// }, | ||
// 改变特定数据类型的默认格式化器 | ||
// $types:{ | ||
// Null : value =>"", | ||
// Undefined: value =>"", | ||
// Boolean : value =>value ? "True":"False", | ||
// } | ||
// 以下可以自定义编写格式化器 | ||
// xxxx : value => { ... }, | ||
// xxxx : (value,$config) => { ... }, | ||
// xxxx : (value,...args,$config) => { ... }, | ||
// xxxx : Formatter(value,...args,$config) => { ... }, | ||
// xxxx : FlexFormatter(value,params,$config) => { ... }, | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/** | ||
格式化器用来对翻译文本内容中的插值变量进行处理 | ||
如何编写格式器请参阅官网! | ||
*/ | ||
|
||
|
||
export default { | ||
// global : true, // 简单地设置为true,代表当前所有格式化器均注册到全局,false只在当前scope生效 | ||
// global : { // 仅将里面的格式化器注册到全局 | ||
// $config:{... } | ||
// xxxx : value => { ... }, | ||
// xxxx : (value,$config) => { ... }, | ||
// xxxx : (value,...args,$config) => { ... }, | ||
// xxxx : Formatter(value,...args,$config) => { ... }, | ||
// xxxx : FlexFormatter(value,params,$config) => { ... }, | ||
//}, // 是否注册到全局,false只在当前scope生效 | ||
// 直接对内置格式化器进行配置,请参阅官网文档 | ||
// $config:{ | ||
// datetime : { | ||
// units : ["Year","Quarter","Month","Week","Day","Hour","Minute","Second","Millisecond","Microsecond"], | ||
// date :{ | ||
// long : 'YYYY/MM/DD HH:mm:ss', | ||
// short : "YYYY/MM/DD", | ||
// format : "local" | ||
// }, | ||
// quarter : { | ||
// long : ["First Quarter","Second Quarter","Third Quarter","Fourth Quarter"], | ||
// short : ["Q1","Q2","Q3","Q4"], | ||
// format : "short" | ||
// }, | ||
// month:{ | ||
// long : ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], | ||
// short : ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sept", "Oct", "Nov", "Dec"], | ||
// format : "long" // 0-长名称,1-短名称,2-数字 | ||
// }, | ||
// weekday:{ | ||
// long : ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], | ||
// short : ["Sun", "Mon", "Tues", "Wed", "Thur", "Fri", "Sat"], | ||
// format : "long", // 0-长名称,1-短名称,2-数字 | ||
// }, | ||
// time : { | ||
// long : "HH:mm:ss", | ||
// short : "HH:mm:ss", | ||
// format : 'local' | ||
// }, | ||
// timeSlots : { | ||
// slots : [12], | ||
// lowerCases : ["am","pm"], | ||
// upperCases : ["AM","PM"] | ||
// }, | ||
// relativeTime : { | ||
// units : ["seconds","minutes","hours","days","weeks","months","years"], | ||
// now : "Now", | ||
// before : "{value} {unit} ago", | ||
// after : "after {value} {unit}" | ||
// } | ||
// }, | ||
// currency : { | ||
// default : "{symbol}{value}{unit}", | ||
// long : "{prefix} {symbol}{value}{unit}{suffix}", | ||
// short : "{symbol}{value}{unit}", | ||
// custom : "{prefix} {symbol}{value}{unit}{suffix}", | ||
// format : "default", | ||
// //-- | ||
// units : [""," thousands"," millions"," billions"," trillions"], //千,百万,十亿,万亿 | ||
// radix : 3, // 进制,即三位一进,中文是4位一进 | ||
// symbol : "$", // 符号 | ||
// prefix : "USD", // 前缀 | ||
// suffix : "", // 后缀 | ||
// division : 3, // ,分割位 | ||
// precision : 2, // 精度 | ||
|
||
// }, | ||
// number : { | ||
// division : 3, // , 分割位,3代表每3位添加一个, | ||
// precision : 0 // 精度,即保留小数点位置,0代表不限 | ||
// } | ||
// }, | ||
// 改变特定数据类型的默认格式化器 | ||
// $types:{ | ||
// Null : value =>"", | ||
// Undefined: value =>"", | ||
// Boolean : value =>value ? "True":"False", | ||
// } | ||
// 以下可以自定义编写格式化器 | ||
// xxxx : value => { ... }, | ||
// xxxx : (value,$config) => { ... }, | ||
// xxxx : (value,...args,$config) => { ... }, | ||
// xxxx : Formatter(value,...args,$config) => { ... }, | ||
// xxxx : FlexFormatter(value,params,$config) => { ... }, | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export default { | ||
"首页": 1, | ||
"关于": 2 | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/** | ||
* 注意:执行compile命令会重新生成本文件,所以请不要修改本文件 | ||
*/ | ||
import idMap from "./idMap" // 语言ID映射文件 | ||
import { translate,VoerkaI18nScope } from "@voerkai18n/runtime" | ||
import defaultFormatters from "./formatters/zh" | ||
import defaultMessages from "./zh" | ||
import storage from "./storage" | ||
|
||
|
||
|
||
const messages = { | ||
'zh' : defaultMessages, | ||
'en' : ()=>import("./en") | ||
} | ||
|
||
const formatters = { | ||
'zh' : defaultFormatters, | ||
'en' : ()=>import("./formatters/en") | ||
} | ||
|
||
// 语言配置文件 | ||
const scopeSettings = { | ||
"languages": [ | ||
{ | ||
"name": "zh", | ||
"title": "zh" | ||
}, | ||
{ | ||
"name": "en", | ||
"title": "en" | ||
} | ||
], | ||
"defaultLanguage": "zh", | ||
"activeLanguage": "zh", | ||
"namespaces": {} | ||
} | ||
|
||
// 语言作用域 | ||
const scope = new VoerkaI18nScope({ | ||
id : "voerkai18n-example-vue2-ts", // 当前作用域的id,自动取当前工程的package.json的name | ||
debug : false, // 是否在控制台输出调试信息 | ||
idMap, // 消息id映射列表 | ||
library : false, // 开发库时设为true | ||
messages, // 语言包 | ||
formatters, // 扩展自定义格式化器 | ||
storage, // 语言配置存储器 | ||
...scopeSettings | ||
}) | ||
// 翻译函数 | ||
const scopedTtranslate = translate.bind(scope) | ||
export { | ||
scopedTtranslate as t, | ||
scope as i18nScope | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
export default { | ||
get(key:string){ | ||
if(globalThis.localStorage){ | ||
return globalThis.localStorage.getItem(key) | ||
} | ||
}, | ||
set(key:string,value:any){ | ||
if(globalThis.localStorage){ | ||
globalThis.localStorage.setItem(key,value) | ||
} | ||
}, | ||
remove(key:string){ | ||
if(globalThis.localStorage){ | ||
globalThis.localStorage.removeItem(key) | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export default { | ||
"1": "首页", | ||
"2": "关于" | ||
} |
Oops, something went wrong.