resourcebundle

Resource files not found from JUnit test cases

限于喜欢 提交于 2019-11-29 22:01:04
Summary My JUnit tests are not finding the files they require during execution. I'm using Maven for dependency management and compilation. Details All files required by the test cases are located in: src/test/resources . For example, src/test/resources/resourceFile.txt . To access a resource I use the following code: URL url = getClass().getResource("/resourceFile.txt").getFile(); File file = new File(url); But then file.exists() returns false . And the error I get is: Tests in error: myJUnitTestCase(tests.MyJUnitTestClass): /home/me/workspace/Project%20Name/target/test-classes/resourceFile

Android Studio - Include ResourceBundles in Module

怎甘沉沦 提交于 2019-11-29 14:13:21
I currently switched from eclipse to android studio. In eclipse I had 2 projects, one android application project and one java project which I included in the android project as library. This java project uses ResourceBundles to create internationalized error messages for it's own errors. This has been my project structure: /MyApp /src /res ... /MyLibrary /src /res (added as source folder to build path) /loc Bundle_en.properties This worked when loading the RessourceBundles as following: ResourceBundle.getBundle("loc.Bundle", Locale.ENGLISH); Now I switched to android studio and my new project

Dynamically load files on classpath using ReloadableResourceBundleMessageSource

∥☆過路亽.° 提交于 2019-11-29 07:54:29
I'm new to Spring and am attempting to use it's ReloadableResourceBundleMessageSource class. I'm attempting to use it so that we no longer have to restart our web app for properties files changes/updates. I have a web app (Primarily using JSF) and a separate tar component which contains all my properties files. The structure of the properties tar is as follows: - CompanyOneMessages.properties - CompanyOneMessages_fr_FR.properties - CompanyTwoMessages.properties - CompanyTwoMessages_fr_FR.properties - CompanyThreeMessages.properties - CompanyThreeMessages_fr_FR.properties - ... This tar is

XCode, Swift (Domain = NSPOSIXErrorDomain, Code = 22)

天涯浪子 提交于 2019-11-29 07:07:47
问题 My friend came to me with a small request of creating a video portfolio app. I thought it was a good excuse to try out Swift, which is what I did. (The app is not intended for release on the app store, only to distribute via Testflight) I've run into some trouble where I'm getting the following error when trying to run my project: An error was encountered while running (Domain = NSPOSIXErrorDomain, Code = 22) The error appeared after adding a directory with .mp4 video files to my project in

List all available ResourceBundle Files

笑着哭i 提交于 2019-11-29 06:58:05
i am using ResourceBundle and I want to give the user an option to select a language for the GUI. i want to get a list of all resource files that are under a specific package. i don't know what resources I will have since this application is based on plug-ins. Is there an option to ask from java to search all available resources under a package? (if no i guess the plug-in should give all available local for it) thank you all The files may reside on a web server. There is no standard way of listing files (pages) on a web server. So, in general, what you need to do is remember which locales you

Pass parameters to messages from resource bundle to components other than **h:outputFormat**

被刻印的时光 ゝ 提交于 2019-11-29 03:58:25
Is there a convenient way to pass parameters to messages from resource bundle to components other than h:outputFormat ? For instance, this is legal: <h:outputFormat value="#{myBundle['parametricMessage']}"> <f:param value="#{myBundle['someParameterValue']}"/> </h:outputFormat> But I need it for a button, like this (which won't work): <h:commandButton value="#{myBundle['parametricMessage']}"> <f:param value="#{myBundle['someParameterValue']}"/> </h:commandButton> Of course, I can use link instead of button, and I can make it through a property in a managed bean, but in this question I'm seeking

ResourceBundle not found for MessageSource when placed inside a folder

泪湿孤枕 提交于 2019-11-28 19:44:43
I am trying to use resource bundles with Spring's Message Source. Here is the way I am doing it: @Component public class MessageResolver implements MessageSourceAware { @Autowired private MessageSource messageSource; public void setMessageSource(MessageSource messageSource) { this.messageSource = messageSource; } public String getMessage(){ return messageSource.getMessage("user.welcome", new Object[]{"Rama"} , Locale.US); } } And here is my folder structure: messages_en_US.properties contains just one line: user.welcome=Welcome {0} Here is the xml configuration used: <bean name="messageSource"

Format a message using MessageFormat.format() in Java

断了今生、忘了曾经 提交于 2019-11-28 18:32:22
I have stored some messages in a resource bundle. I'm trying to format these messages as follows. import java.text.MessageFormat; String text = MessageFormat.format("You're about to delete {0} rows.", 5); System.out.println(text); Assume that the first parameter i.e the actual message is stored in a property file which is somehow retrieved. The second parameter i.e 5 is a dynamic value and should be placed in the placeholder {0} which doesn't happen. The next line prints, Youre about to delete {0} rows. The placeholder is not replaced with the actual parameter. It is the apostrophe here - You

Bundling .js files vs CDN

雨燕双飞 提交于 2019-11-28 18:23:27
问题 In order to improve performance of our web pages, we are recommended to use CDNs to serve .js files on our web pages. That makes sense. Also, we are recommended to bundle our .js files in order to reduce the number of requests which are being made to server on load. So, we need to sit down and make decision between if we use CDN or bundle .js files. What are the pros and cons? Which ones make more sense? 回答1: Why can't you bundle them and place them are the CDN? It should hardly be a decision

Injecting ResourceBundle via @ManagedProperty doesn't seem to work inside @Named

怎甘沉沦 提交于 2019-11-28 12:47:25
How can I access messages bundle from java code to get message according to current locale? I tried using @ManagedProperty like below: @Named @SessionScoped public class UserBean implements Serializable { @ManagedProperty("#{msg}") private ResourceBundle bundle; // ... public void setBundle(ResourceBundle bundle) { this.bundle = bundle; } } However, it remains null . It seems that it doesn't work inside a @Named . This is how I registered the resource bundle in faces-context.xml : <application> <message-bundle>validator.messages</message-bundle> <locale-config> <supported-locale>en_US<