resourcebundle

ResourceBundle from Java/Struts and replace expressions

If I have a Resource bundle property file: A.properties: thekey={0} This is a test And then I have java code that loads the resource bundle: ResourceBundle labels = ResourceBundle.getBundle("A", currentLocale); labels.getString("thekey"); How can I replace the {0} text with some value labels.getString("thekey", "Yes!!!"); Such...

How do I use ResourceBundle to avoid hardcoded config paths in Java apps?

I'd like to eliminate dependencies on hardcoded paths for configuration data in my Java apps, I understand that using ResourceBundle will help me use the classloader to find resources. Can someone tell me how I would replace a hardcoded path to a resource (say a .properties configuration data file required by a class) with appropriate u...

In Java, how to reload dynamically resources bundles in a web application ?

We are using fmt:setBundle to load a resource bundle from a database (we extended the ResourceBundle class to do that). When we modify a value in database, we have to reload the web server to display the new value on the web app. Is there any simple way to use the new value without restarting the web server ? (We do not want to always ...

How do I specify values in a properties file so they can be retrieved using ResourceBundle#getStringArray?

I am trying to use ResourceBundle#getStringArray to retrieve a String[] from a properties file. The description of this method in the documentation reads: Gets a string array for the given key from this resource bundle or one of its parents. However, I have attempted to store the values in the properties file as multiple individual...

Locales and ResourceBundles in a plugin-based program

We need to start adding internationalisation to our program. Thankfully not the whole thing yet, just a few bits, but I want the way we do it to scale up to potentially cover the whole program. The thing is, our program is based on plugins, so not all strings belong in the same place. As far as I understand it, Java's ResourceBundle wor...

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

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_BREA...

How to override some Resources from a PropertyResourceBundle.

I have an exsisting Java/JSF website all the text on the screen is coming from property files via <f:loadBundle basename="org.example.applicaltion" var="applicaltion" /> which pulls the text from applicaltion.properties. For a runtime configurable subset of these I am wanting to pull the string from else where (CMS via web services). Lo...

JSF Validation not finding custom ResourceBundle class

Hello, I have a custom ResourceBundle class org.example.web.UILabels.java which works well in running code but the JSF editor in Eclipse is not finding it, I assume the editor/validator is only looking for properties files by the name. This also means I no longer get type ahead find on the resources which was very nice to have. Any ide...

Is there a tool for non-developers (translators!) to edit resource bundles?

What we do in our company to let our software be translated by external translators is ... well .. how to put it... cvs co someModule ant translation.export (behind this target there is a self-made ant task, exporting all resource bundles together as one big tab-seperated text file, columns: the different languages, each row all langua...

How to load a resource bundle from a file resource?

I have a file called mybundle.txt in c:/temp - c:/temp/mybundle.txt how do I load this file into a java.util.resource bundle? The file is a valid resource bundle. This does not seem to work: java.net.URL resourceURL = null; String path = "c:/temp/mybundle.txt"; java.io.File fl = new java.io.File(path); try { resourceURL = fl.to...

Spring: can ResourceBundleMessageSource be configured to load properties in xml format

As you may know, properties are usually written in files in key=value format but can also be written in XML format. The question is if (and how) can Spring's ResourceBundleMessageSource be configured to load properties in XML format. ...

How to externalize a Spring MessageSources bundle outside the WAR

Hi, I have to externalize the Spring MessageSources bundle for i18n support (properties files) outside the classpath in order to modify properties more easily. How can I do that ? <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource"> <property name="basename" value="test-messages"/> Tha...

ResourceBundle.getString removed backslash character

I tried to get a resource from a file path from a properties file. Property File: info_path=c:\Info\output Java: String path = ResourceBundle.getBundle("bundle_name").getString("info_path"); Result: C:Infooutput I would need to set the file: info_path=c:\\Info\\output Is this the default behavior? or would it depend on the fil...

Java ResourceBundle Performance

I am using a ResourceBundle and Locale to lookup property values. Quite simply, the code looks like this: public static String getPropertyValue(Locale locale, String resourceName, String key) { ResourceBundle resource = ResourceBundle.getBundle(resourceName, locale); return resource.getString(key); } My question is about p...

ResourceBundle MissingResourceException Linux Specific Key

Hi, I have been having this issue in iterating through an array of keys and calling the getString() method on the resource bundle. I have all the mappings I need in my bundle and for some reason one of the resource will not be fetched. This is only an issue in Linux Ubunthu 9. It works in Windows. It finds all the resources up until my ...

How to check if a Java ResourceBundle is loadable, without loading it?

I would like to check the existence of a ResourceBundle without actually loading it. Typically, I'm using Guice, and at initialization time, I want to check the existence, while at execution time, I want to load it. If the bundle doesn't exist, I want an early report of the inexistence of the RB. If it was possible to get the ResourceB...

Java i18n: use one ResourceBundle accessor per package, or one for whole project?

I don't know anything about internationalization. I have a project with several packages. I am using Eclipse's built-in "Externalize Strings" wizard to extract String constants in my classes to a properties file and replace those Strings with calls to a static accessor. So instead of System.out.println("Hello, world!"); I end up with...

Test for null parameter in .properties file for MessageFormat

Is it possible, with resource bundles and MessageFormat to have the following result? when I call getBundle("message.07", "test") to get "Group test" when I call getBundle("message.07", null) to get "No group selected" Every example I found on the Internet is with planets, with files on the disk and so on. I only need to check if o...

superscripting text in resource bundle in java

Hi, has anyone included superscripted text in a resource bundle? any advice on this matter would be appreciated! ie: programmingpanda thanks, panda ...

How to load resource bundle messages from DB

Can I load a resource bundle dynamically? Can I edit a resource bundle dynamically? It would be best if I can have such a logical resource bundle (i.e. located in context not as physical file). Related: How to load a resource bundle from a file resource? ...