Intl Messageformat格式化字符串
Intl Messageformat 可以用占位符格式化字符串,包括复数和选择支持创建本地化消息。
示例代码:
var MESSAGES = { 'en-US': { NUM_PHOTOS: 'You have {numPhotos, plural, ' + '=0 {no photos.}' + '=1 {one photo.}' + 'other {# photos.}}' }, 'es-MX': { NUM_PHOTOS: 'Usted {numPhotos, plural, ' + '=0 {no tiene fotos.}' + '=1 {tiene una foto.}' + 'other {tiene # fotos.}}' } }; var output; var enNumPhotos = new IntlMessageFormat(MESSAGES['en-US'].NUM_PHOTOS, 'en-US'); output = enNumPhotos.format({numPhotos: 1000});console.log(output); // => "You have 1,000 photos." var esNumPhotos = new IntlMessageFormat(MESSAGES['es-MX'].NUM_PHOTOS, 'es-MX'); output = esNumPhotos.format({numPhotos: 1000});console.log(output); // => "Usted tiene 1,000 fotos."
评论
Intl Messageformat格式化字符串
IntlMessageformat可以用占位符格式化字符串,包括复数和选择支持创建本地化消息。示例代码:var MESSAGES = { 'en-US': { NUM
Intl Messageformat格式化字符串
0
Intl Messageformat Parser解析消息字符串
Intl Messageformat Parser 是发送给 AST 的解析消息字符串,它可以格式化
Intl Messageformat Parser解析消息字符串
0
Intl Messageformat Parser解析消息字符串
IntlMessageformatParser是发送给AST的解析消息字符串,它可以格式化一个人的语言环境消息。
Intl Messageformat Parser解析消息字符串
0
Intl RelativeformatJavaScript 日期格式化工具
Intl Relativeformat 可以格式化相关字符串的 JavaScript 日期。示例代码
Intl RelativeformatJavaScript 日期格式化工具
0
Intl RelativeformatJavaScript 日期格式化工具
IntlRelativeformat可以格式化相关字符串的JavaScript日期。示例代码:var rf = new IntlRelativeFormat('en-US');var posts =
Intl RelativeformatJavaScript 日期格式化工具
0