resourcebundle

System.ArgumentNullException in ResourceManager.GetString internals

拟墨画扇 提交于 2019-12-06 15:03:21
My code: System.Resources.ResourceManager resourceManager = GetResourceManager(); string str = resourceManager.GetString("delete", new CultureInfo(1033)); In current project compiled under .NET 2.0 everything works as excepted. Variable str contains resource string for LCID 1033 - Delete , this is ok. We are now upgrading to .NET 4.0, recompiled project under target framework .NET 4.0. Now compiled as .NET 4.0 assemblies, it throws exception System.ArgumentNullException with message Value cannot be null. .Stack trace: at System.Threading.Monitor.Enter(Object obj) at System.Resources

Spring MVC Webapp: Where to store paths to common images?

六眼飞鱼酱① 提交于 2019-12-06 14:46:26
问题 I'm building a Spring MVC web application with Tiles/JSP as the view technology. Previously I stored the paths to common images in class Common: public final static String IMG_BREADCRUMBS_NEXT = "/shared/images/famfam/bullet_arrow_right.png"; Then I would use this class in jsp to get the image src like <img src="<%= Common.IMG_BREADCRUMBS_NEXT %>"/> I would like to get rid of scriptlets in my jsp code and use jstl etc. instead. What is the best way to store this kind of information? Is it

使用java.util.ResourceBundle国际化

别来无恙 提交于 2019-12-06 12:47:19
如果简单使用信息文件message.properties,可以使用java.util.Properties直接load文件即可获取键值对。 但是如果考虑到国际化,需要将message.properties的内容写成不同语言的文字,也许可以考虑分别建立message.properties,message1.properties,message2.properties等等的文件存储不同的语言文字,然后在使用java.util.Properties加载时,使用Locale.getDefault()获取默认语言,或者根据客户端信息生成Locale实例,以此来写一堆if语句逐个判断使用哪个properties文件。 java.util.ResourceBundle就是将上面的过程简化的类,ResourceBundle.getBundle("message",Locale.getDefault())可以根据Locale的值自动判断对应的message.properties文件,但是自动总是要有代价的,就是命名properties文件时,有固定格式:自定义名_语言代码_国家代码.properties。如果没有对应Locale的文件,会再找默认的message.properties。 关于语言和国家如下: 语言参数是一个有效的 ISO 语言代码。这些代码是由 ISO-639 定义的小写两字母代码

Struts 2 Dynamic message with OGNL

最后都变了- 提交于 2019-12-06 11:53:30
In a Struts 2 project, consider below key in message resources: export.filename.accountsummary=customer ${export} The action has export filed with setter and getter. If you call the getText("export.filename.accountsummary") struts will automatically call the getExport() and fill it with correct value. (I think that struts use OGNL too lookup the resource messages that are endorse with ${} ) Is this correct ?! I try to use customer ${#sessionScope.CurrentUser.userName} an expected that struts use this OGNL expression but it did not worked. Looks like the variable sessionScope is not available

Dynamically change ResourceBundle Locale in Java

二次信任 提交于 2019-12-06 11:02:10
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); Call ResourceBundle.clearCache(); then load your bundle again with the locale you want. 来源: https://stackoverflow.com/questions/10981521/dynamically-change-resourcebundle-locale-in-java

Externalized message.properties file is not picking up in Tomcat

断了今生、忘了曾经 提交于 2019-12-06 07:40:24
According to my requirement, I need to externalize the message.properties file (Keep outside from war file) and in same time it should be automatically re loadable on update. So I achieved both by following code and its working fine with Jetty Server. But in when I use Tomcat Server that externalized property file is not picking up by the system, instead its uses only the file inside the war. public final class Messages { public static final String BUNDLE_NAME = "com.sample.project.core.ui.resources.messages"; // private static ResourceBundle resourceBundle = ResourceBundle.getBundle(BUNDLE

.NET equivalent of choices in Java resource bundles?

只愿长相守 提交于 2019-12-06 02:57:21
In Java resource bundles I may have the following Resource Bundle definitions: en_GB - British English jobs.search.resultstr = There {1,choice,0#are no jobs|1#is one job|1<are {1,number,integer} jobs} for your search ceb_PH - Cebuano jobs.search.resultstr = Adunay {1,choice,0#mga walay mga|1#mao ang 1 nga|1<{1,number,integer}} trabaho alang sa {1,choice,0#inyong mga|1#imong|1<inyong mga} search The code I would use to extract the resource would make choices based on the input data and format the string correctly resulting in one of three different outputs. pseudo code: myResultStr =

java.util.MissingResourceException: Can't find bundle for base name

做~自己de王妃 提交于 2019-12-05 22:41:48
问题 I'm testing Java's i18n features and have a problem, I can't load the language file when it's not in the class root. Right now my files are in the /lang directory. Looked several answers here in SO, putting it in a classes subdir and loading it like lang.Messages , used complete location routing /Test/lang/Message (test is the project name), using just /lang/Message and still I'm getting the: java.util.MissingResourceException: Can't find bundle for base name error. Anything else to try? My

How to clear ResourceBundle cache

折月煮酒 提交于 2019-12-05 17:09:51
This is a webapp running on Tomcat, using Guice. According to the docs we should be able to call ResourceBundle.clearCache(); to clear the ResourceBundle cache and presumably get the latest from the bundle property files. We have also tried the following: Class klass = ResourceBundle.getBundle("my.bundle").getClass().getSuperclass(); Field field = klass.getDeclaredField("cacheList"); field.setAccessible(true); ConcurrentHashMap cache = (ConcurrentHashMap) field.get(null); cache.clear(); // If i debug here I can see the cache is now empty! and ResourceBundle.clearCache(this.class.getClassLoader

ResourceBundle returns NULL without any errors being raised

非 Y 不嫁゛ 提交于 2019-12-05 13:16:38
For internationalized data it would be great to work with the \ResourceBundle class from PHP's "intl" extension. I got the extension running (PHP 5.3.4; Windows) and created a .dat file using the ICU Data Library Customizer *, but I don't get the expected result from the resource bundle class. Now I do this $bundle = '/var/www/libs/icudt48l.dat'; $resource = new \ResourceBundle('en_US', $bundle, true); var_dump($resource, is_file($bundle)); //--> NULL, TRUE The problem is $resource returns NULL without any errors being raised. What's going on? *(Only the last two data sections were checked