resourcebundle

EL variable in JSF ResourceBundle

主宰稳场 提交于 2019-12-05 11:27:13
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. JSF resourcebundles does by default not resolve EL. It however by default supports MessageFormat API in combination with <h:outputFormat

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

拈花ヽ惹草 提交于 2019-12-05 10:37:40
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/xml/ns/javaee/web-facesconfig_2_0.xsd" version="2.0"> <application> <resource-bundle> <base-name>com

Can't load ResourceBundle during junit test

。_饼干妹妹 提交于 2019-12-05 09:35:29
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? Resources are not resolved from the source folder but from the class directory. Are your resource files copied to

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

无人久伴 提交于 2019-12-05 06:53:37
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 languages for one key) Some VB tool does something with the file (you don't wanna know) Translators work in Excel on their column Someone collects and merges the translations VB tool ant translation.import cvs commit ... Best case: 2 weeks between 1. and 8.,

How to ignore the system default Locale to retrieve resourceBundle

核能气质少年 提交于 2019-12-05 06:26:17
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.getBundle("name", new Locale("en", "US")) returns the fr_FR bundle. I could rename the messages

How to escape curly braces in my properties file which is fetched using the ResourceBundle API

大城市里の小女人 提交于 2019-12-05 06:02:39
In properties file I am having a key=A: {{0}, {1}}, B: {{2}, {3}} . I am expecting a string "A: {0, 1}, B: {1, 2}" . The numbers inside the curly braces are parsing. How can I include the character '{' without binding to any value? I also tried by escaping the character like this "//{". Even I couldn't get the expected result. An error java.lang.IllegalArgumentException: can't parse argument number 0, 1 \ occurs. key=A: '{'{0}, {1}'}', B: '{'{2}, {3}'}' just run the properties file through native2ascii tool that comes with the JDK. it will do the work for you. Or better use the JRCEditor 来源:

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

给你一囗甜甜゛ 提交于 2019-12-04 19:12:33
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 resource bundles? How have you solved this? kosoant In the end I used Spring's theme support to achieve

How to add specific files to assetic?

拈花ヽ惹草 提交于 2019-12-04 17:54:41
问题 I have my custom resources directory for my bundle where there are some files: /longpathtoSymfony/src/MyOwn/Bundle/MyOwnBundle/Resources/public |-- bootstrap | |-- css | | |-- bootstrap-theme.css | | |-- bootstrap-theme.min.css | | |-- bootstrap.css | | |-- bootstrap.min.css | | `-- carousel.css | |-- fonts | | |-- glyphicons-halflings-regular.eot | | |-- glyphicons-halflings-regular.svg | | |-- glyphicons-halflings-regular.ttf | | `-- glyphicons-halflings-regular.woff | `-- js | |--

Why does maven not copy the properties files during the build process?

喜你入骨 提交于 2019-12-04 17:26:00
问题 Nothing I've found has been able to help me solve this one specific case. I recently switched from a plain old java web app project (which was working) to a maven web project. I get the following runtime exception: java.util.MissingResourceException: Can't find bundle for base name com.myapp.config, locale en I am using Netbeans to create a JSF 2.0, Spring, and Hibernate web app. I have the following directory structure: src\main\java\com\myapp Contains config.properties src\main\resources

How do I avoid repetition in Java ResourceBundle strings?

不羁的心 提交于 2019-12-04 09:08:38
问题 We had a lot of strings which contained the same sub-string, from sentences about checking the log or how to contact support, to branding-like strings containing the company or product name. The repetition was causing a few issues for ourselves (primarily typos or copy/paste errors) but it also causes issues in that it increases the amount of text our translator has to translate. The solution I came up with went something like this: public class ExpandingResourceBundleControl extends