感谢你阅读这篇文章。
我希望在我的Spring-Shell应用程序中提供i18n。具体地说,我希望能够在@CliOption中根据区域设置以不同的语言打印帮助消息。我还没有找到任何具体的例子来说明如何开箱即用。我已经看过代码了,我确实看到了一个区域设置转换器。不过,我不确定这是否足够。
Spring-Shell支持开箱即用的i18n吗?任何与此相关的资源的帮助/提示/指针都将不胜感激。
谢谢。
发布于 2015-09-03 15:43:45
这目前还不受支持,并且需要在Spring Shell中进行重大更改。我将把它作为Spring Shell的下一次重大发展的一个要求。
您引用的LocaleConverter用于将参数从文本(String)格式转换为Locale,也就是说,如果存在这样的命令:
@CliCommand(value="translate", help="translate text from one language to another")
public String translate(
@CliOption(key={"", "text"}, help="the text to translate") String text,
@CliOption(key="from", help="the source Locale") Locale source,
@CliOption(key="to", help="the target Locale") Locale target) {
Word from = service.lookup(text, source);
Word to = from.tranlatedTo(target);
return to.toString();
}
}这样,在输入以下命令时,您将直接获得一个Locale对象。
translate bonjour --from fr_FR --to en希望这是有意义的。
https://stackoverflow.com/questions/32348093
复制相似问题