在Java中动态更改ResourceBundle Locale [英] Dynamically change ResourceBundle Locale in Java

查看:308
本文介绍了在Java中动态更改ResourceBundle Locale的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在加载ResourceBundle之后是否可以执行此操作?我在Tomcat下工作并尝试了不同的代码示例,但它们都没有为我工作。有什么建议吗?

Is it possible to do this operation after the ResourceBundle has already been loaded? I'm working under Tomcat and have tried different code examples but none of them worked for me. Any suggestion?

推荐答案

不,你不能改变一个包的语言环境。但是您可以使用其他语言环境重新加载相同的包基本名称:

No, you can't change the locale of a bundle. But you can reload the same bundle base name using another locale:

bundle = ResourceBundle.getBundle("my.base.name", otherLocale);

这篇关于在Java中动态更改ResourceBundle Locale的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆