resourcebundle

java.util.MissingResourceException: Can't find resource for bundle java.util.PropertyResourceBundle, key

会有一股神秘感。 提交于 2019-12-08 05:17:20
问题 I don't know whats going on. Here is my Titles_en_US.properties file: WEBSITE.TITLE = Hello World FOOTER.DISCLAIMER = Disclaimer FOOTER.TERMS_OF_USE = Terms of Use FOOTER.PRIVACY_POLICY = Privacy Policy Here is my method: private String getTitle() throws Exception { System.out.println("\n\n==>"+getProperty("FOOTER.DISCLAIMER",LabelsFile())); return getProperty("WEBSITE.TITLE", LabelsFile()); } Both FOOTER.DISCLAIMER and WEBSITE.TITLE in same properties file but one is working and other is

System.ArgumentNullException in ResourceManager.GetString internals

一曲冷凌霜 提交于 2019-12-08 03:40:03
问题 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

Dynamically change ResourceBundle Locale in Java

♀尐吖头ヾ 提交于 2019-12-08 02:56:18
问题 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? 回答1: 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); 回答2: Call ResourceBundle.clearCache(); then load your bundle again with the locale you want. 来源: https://stackoverflow

How to clear ResourceBundle cache

人走茶凉 提交于 2019-12-07 10:30:02
问题 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

ResourceBundle returns NULL without any errors being raised

ⅰ亾dé卋堺 提交于 2019-12-07 08:55:14
问题 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

Can't load ResourceBundle during junit test

若如初见. 提交于 2019-12-07 07:57:14
问题 I'm trying to write some Junit tests to test old classes in our app. The code is trying to load a ResourceBundle (for translations) but fails. I guess the problem is classpath related but I can't figure it out. The code is laid out in /src and my tests are in /test. The ResourceBundles are loaded given a base name relative to /src, say, "foo/bar/baz". My tests use the same classpath as the app itself, so I don't understand why it won't find the bundles. Any ideas to what's wrong? 回答1:

getBytes() With UTF-8 Doesn't Work for Upper-Case German Umlauts

时光怂恿深爱的人放手 提交于 2019-12-07 06:13:36
问题 For development I'm using ResourceBundle to read a UTF-8 encoded properties-file (I set that in Eclipse' file properties on that file) directly from my resources-directory in the IDE (native2ascii is used on the way to production), e.g.: menu.file.open.label=&Öffnen... label.btn.add.name=&Hinzufügen label.btn.remove.name=&Löschen Since that causes issues with the character encoding when using non-ASCII characters I thought I'd be happy with: ResourceBundle resourceBundle = ResourceBundle

EL variable in JSF ResourceBundle

寵の児 提交于 2019-12-07 05:42:06
问题 i read somewhere (don't find it anymore) that i can use EL Expresions in the resource bundle and then use it without changes in *.xhtml files. some.text=#{someBean.stepsLeft} more to switch the position of the variable in different languages. But actually it wont work. I can use Interpolator class to handle the parsing or add some.text.before some.text.after and let one of them empty. I would prefer it to use it without interpolator.interpolate() if possible. 回答1: JSF resourcebundles does by

JSF Internationalization f:loadbundle or through faces-config: Performance point

隐身守侯 提交于 2019-12-07 05:23:55
问题 There are two ways to load the properties file into JSF 2.0. Global Resource Bundle To load the properties file globally, so that all the jsf pages can access the messages. You can create a “faces-config.xml” file and declare the properties file explicitly. faces-config.xml <?xml version="1.0" encoding="UTF-8"?> <faces-config xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com

How to ignore the system default Locale to retrieve resourceBundle

谁说我不能喝 提交于 2019-12-07 03:10:03
问题 I am localizing a web application using a java.util.ResourceBundle class and property files. I have two locales, fr_FR and en_US, and I want to use en_US as the default, so I wrote the following files : messages_fr_FR.properties with fr_FR messages messages.properties with en_US messages My problem is that the ResourceBundle.getBundle(BUNDLE_NAME, locale) method fall back Locale.getDefault() before using the default property file, which means if the JVM Locale is set to fr_FR, ResourceBundle