resourcebundle

Java: How to write “Arabic” in properties file?

﹥>﹥吖頭↗ 提交于 2019-11-30 20:22:23
I want to write "Arabic" in the message resource bundle (properties) file but when I try to save it I get this error: "Save couldn't be completed Some characters cannot be mapped using "ISO-85591-1" character encoding. Either change encoding or remove the character ..." Can anyone guide please? I want to write: global.username = اسم المستخدم How should I write the Arabic of "username" in properties file? So, that internationalization works.. BR SC http://sourceforge.net/projects/eclipse-rbe/ You can use the above plugin for eclipse IDE to make the Unicode conversion for you. mtraut As

Getting OS language in java

别来无恙 提交于 2019-11-30 20:19:09
I'm running into a kind of problem here. I'm French and working on an English version of Windows XP. Therefore, I set the regional options to French, but still have an English language UI. I'm working on a small Java SE application, and decided to internationalize it using resources bundle. To display the proper language, I create the bundle with this function : private static ResourceBundle bundle = ResourceBundle .getBundle("locale.Strings", Locale.getDefault()); But the Locale.getDefault() function returns the regional settings (meaning : French) and not the system UI language. As a result,

Java ResourceBundle leading whitespace in values

只愿长相守 提交于 2019-11-30 17:01:12
I'm trying out the example given at Oracle's documentations . The java file is here as shown in that page. Now with this java file, I keep a LabelsBundle.properties file in the same directory. # This is the default LabelsBundle.properties file s1 = computer s2 = disk s3 = monitor s4 = keyboard it seems that the trailing whitespace is not ignored while reading the values and the leading whitespaces are ignored. So if I want leading spaces to be there, what do I do? In other words, what do I need to do to read the value of s1 as computer instead of computer ? A Unicode escape sequence \u0020

Apostrophe doesn't get translated properly when placed in a resource bundle

北慕城南 提交于 2019-11-30 16:46:14
Apostrophe doesn't get translated properly when placed in a resource bundle. key = {0}'s brush is {1} centimeters tall (e.g. Sam's brush is 4 centimeters tall) The apostrophe gets missed if I format the above key from a java.util.ResourceBundle What could be the problem here? You should escape the single quote as key = {0}''s brush is {1} centimeters tall I strongly belive that the problem is not the ressource bundle but the MessageFormater you use to print the message: From MessageFormater java doc : Within a String, '' ( two single quotes ) represents a single quote. A QuotedString can

In Java how do I find out what languages I have available my Resource Bundle

淺唱寂寞╮ 提交于 2019-11-30 11:03:49
I have some resource bundles packaged in my main jar widget_en.properties widget_de.properties I retrieve a resource bundle based on my default locale as folows ResourceBundle.getBundle("widget", Locale.getDefault()); But I want to present the user with a list of available languages supported so that can select a language that may be different to their computers default But I can't find a method in ResourceBundle that would list available locales, I don't want to hardcode a list as I may forget to update it when another resource bundle is added. EDIT As I only resource bundles for different

Resource files not found from JUnit test cases

扶醉桌前 提交于 2019-11-30 10:42:53
问题 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:

Do resource bundles in Java support runtime string substitution?

无人久伴 提交于 2019-11-30 01:17:25
Can you do the following with a Java ResourceBundle? In the properties file... example.dynamicresource=You currently have {0} accounts. At runtime... int accountAcount = 3; bundle.get("example.dynamicresource",accountCount,param2,...); To give a result of "You currently have 3 accounts." David Sykes Not without using the MessageFormat class, such as: String pattern = bundle.getString("example.dynamicresource"); String message = MessageFormat.format(pattern, accountCount); skaffman On their own, ResourceBundle does not support property placeholders. The usual idea is to take the String you get

Java ResourceBundle leading whitespace in values

时光怂恿深爱的人放手 提交于 2019-11-30 00:57:55
问题 I'm trying out the example given at Oracle's documentations. The java file is here as shown in that page. Now with this java file, I keep a LabelsBundle.properties file in the same directory. # This is the default LabelsBundle.properties file s1 = computer s2 = disk s3 = monitor s4 = keyboard it seems that the trailing whitespace is not ignored while reading the values and the leading whitespaces are ignored. So if I want leading spaces to be there, what do I do? In other words, what do I

Apostrophe doesn't get translated properly when placed in a resource bundle

只愿长相守 提交于 2019-11-30 00:04:18
问题 Apostrophe doesn't get translated properly when placed in a resource bundle. key = {0}'s brush is {1} centimeters tall (e.g. Sam's brush is 4 centimeters tall) The apostrophe gets missed if I format the above key from a java.util.ResourceBundle What could be the problem here? 回答1: You should escape the single quote as key = {0}''s brush is {1} centimeters tall 回答2: I strongly belive that the problem is not the ressource bundle but the MessageFormater you use to print the message: From

Bundling .js files vs CDN

雨燕双飞 提交于 2019-11-29 22:06:35
In order to improve performance of our web pages, we are recommended to use CDN s 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? Matt Why can't you bundle them and place them are the CDN? It should hardly be a decision of one or the other? If you have to choose one or the other, it depends on how many .js files you are