国际化相关 vjspUtils.i18n
国际化相关,模板字符串替换
(static).options :Object
属性
Name | Type | Description |
---|---|---|
openTag | String | 占位符开始标签 |
closeTag | String | 占位符结束标签 |
默认参数
Type: Object
设置openTag
(static).setOpenTag (tag)
参数:
Name | Type | Description |
---|---|---|
tag | String | 标签字符串 |
设置closeTag
(static).setCloseTag (tag)
参数:
Name | Type | Description |
---|---|---|
tag | String | 标签字符串 |
替换模板字符串
(static).replace (str, arg) → {String}
示例
//return "tom and jack are friends"
vjspUtils.i18n.replace('{1} and {2} are friends','tom','jack')
参数:
Name | Type | Description |
---|---|---|
str | String | 模板字符串 |
arg | String|Object | 要替换的值 |
返回:String替换后的字符串
将占位符里的字符串作为变量名获取值
(static).evalReplace (str) → {String}
示例
var test = {key : 'testString'};
// return "testString"
vjspUtils.i18n.evalReplace('{test.key}');
参数:
Name | Type | Description |
---|---|---|
str | String | 占位符字符串 |
返回:String 获取到的变量
判断字符串是否是i18n标签
(static).isI18nTag (str) → {Boolean}
参数:
Name | Type | Description |
---|---|---|
str | String | 待判断字符串 |
返回:Boolean 判断结果