voerka-i18n/src/formatters.js
2022-02-24 18:49:54 +08:00

33 lines
784 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/**
* 默认的格式化器
*
* 使用方法:
*
* 在translates/xxx.json文件中进行翻译时可以对插值变量进行格式化
*
* {
* "Now is {date}":{
* "zh-CN":"现在是{date|time}"
* }
* }
*
*
*/
export default {
cn:{
Date:{
default:(value)=>dayjs(value).format("YYYY年MM年DD日"), // 默认的变量格式化器
time:(value)=>dayjs(value).format("HH:mm:ss"),
short:(value)=>dayjs(value).format("YYYY/MM/DD"),
},
Number:{
}
},
en:{
"Date":{
short:(value)=>dayjs(value).format("YYYY/MM/DD"),
time:(value)=>dayjs(value).format("HH:mm:ss")
}
}
}