一、用法:
MessageFormat用来格式化一个消息,通常是一个字符串,比如
示例1:
String pattern = "my name is {0}, come from {1}";
Object[] params = new Object[]{"lucy","China"};
String value = MessageFormat.format(pattern,params);
运行结果:my name is lucy, come from China
示例2:
String pattern = "my name is '{0}'";
Object[] params = new Object[]{"lucy"};
String value = MessageFormat.format(pattern,params);
运行结果:my name is {0}
二、注意:
1.pattern的内容如果包含花括号如{...}或者{sadsa},则应该用单引号括起来。
例如,String pattern = "变量{0}正确的格式为${XXX}"
应该写成String pattern = "变量{0}正确的格式为‘${XXX}’",
否则会报错IllegalArgumentException
相关推荐
java中MessageFormat格式化字符串的例子,包括NumberFormat,DateFormat,ChoiceFormat等
前端项目-messageformat,multipleformat和selectformat message和i18n工具-一个实现ICU标准的javascript。
消息格式包使用 messageformat.js 编译消息树。 输出中没有全局变量。安装 > npm install messageformat-bundle用法 var messageformatBundle = require ( 'messageformat-bundle' ) ;// Work in progress…应用程序...
主要介绍了Java中的MessageFormat.format用法实例,本文先是讲解了MessageFormat的语法,然后给出了多个操作实例,需要的朋友可以参考下
Messageformat是一种用于处理应用程序中的复数形式和性别的机制。 由于它旨在支持包含的,因此它也可以带来更好的翻译。 此monorepo由构成我们的ICU MessageFormat的JS实现的以下程序包组成: core-将MessageFormat...
ngx-translate编译器,它使用messageformat.js来使用ICU语法编译翻译以处理复数形式和性别 (StackBlitz) 目录 安装 假设您已经安装了 。 使用npm : npm install ngx-translate-messageformat-compiler ...
messageformat.net, .NET的ICU MessageFormat实现 用于. NET 的- 更好的用户界面字符串。 这是. NET 中ICU消息格式的实现。 有关该格式的官方信息,请转到: http://userguide.icu-project.org/formatparse/messages...
虽然有很多不同的 MessageFormat 方言,但我将坚持使用接受的语法。 ##特征 语法高亮 短绒: 突出显示无效的转义序列 突出显示无效的 MessageFormat 块 查找缺少“其他”形式的 MessageFormat 块 在 ...
前端项目-angular-translate-interpolation-messageformat,使用messageformat.js根据某些值插入字符串。
适用于Webpack的YAML i18n加载程序使用和YAML文件作为预编译函数加载到JavaScript中。 使用默认选项,将加载 YAML文件,但也可以将其配置为其他内容。 例如,对于具有已在ICU MessageFormat中包含内容的YAML,请与...
如果在本机不支持ES6功能(例如对象分解和箭头功能)的环境中使用,则需要为此使用转译器。 用法 const { parsePo , parseMo } = require ( 'gettext-to-messageformat' ) const { headers , pluralFunction , ...
官方版本,亲测可用
MessageFormat 库必须位于您的源代码树中的路径下,您将使用该路径作为别名,如下面的 RequireJS 配置示例所示。 RequireJS 配置 以下是您的 RequireJS 配置应如下所示: requirejs . config ( { "paths" : { ...
利用MessageFormat格式化字符串实例资料.pdf
通过行业黄金标准MessageFormat使用超强大的语言 通过自动字符串提取和翻译界面实现超级轻松的翻译 通过在力矩,香菜等上自动设置区域设置,超级容易集成 超快速的加载,缓存等。可与BrowserPolicy,appcache等配合...
前端项目-intl-messageformat,将ICU消息字符串格式化为数字、日期、复数,然后选择占位符以创建本地化消息。
主要介绍了Java利用MessageFormat实现短信模板的匹配,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧
Intl Messageformat Parser 是发送给 AST 的解析消息字符串,它可以格式化一个人的语言环境消息。
MessageFormat 编译对象编译 messageformat.js 翻译字符串对象。安装 npm install messageformat-compile-object --save用法 var compile = require('messageformat-compile-...选项locale - 要使用的语言环境。 Messag
和助手 CLI 工具(可通过 npm 脚本使用),基于 CLDR 数据: 复数:生成通用语言环境的复数和有序函数工厂作为 UMD 模块货币:将通用语言环境的货币映射工厂导出为 UMD 模块list:将常用语言环境列表格式的工厂导出...