How to enumerate keys in Resource Bundle?

Is there any way to enumerate all the keys (but not the values) of resource bundle?

If rb is a ResourceBundle, you can enumerate the keys and values in its 'content' property with the following code:
for (var key:String in rb.content)
    var value:* = rb.content[key];
Gordon Smith
Adobe Flex SDK Team

Similar Messages

  • Jheadstart oes not generate NLS key in resource bundle for Static domains

    Hello
    according to jhsdevguide1013 on section 6.5.2 about "Translation of static domains" when I check "Generate NLS-enabled prompts and tabs" and run application generator , Jheadstart oes not generate NLS key in resource bundle for Static domains.
    Does anybody can help us for this problem?

    Thank you for reporting this, I have logged it as a bug.
    As a workaround, you can customize the Generator Template default/item/staticDomainOptions.vm
    See http://blogs.oracle.com/jheadstart/2006/11/30#a108 for an example how to let a template generate extra resource bundle keys.
    Hope this helps,
    Sandra Muller
    JHeadstart Team
    Oracle Consulting

  • How to compare and edit Resource bundle file using java programe

    Hi All
    I have two resource bundle with key, value and some comments. I need to write a java code to compare both of the values of the keys and if the values are different then i want to replace the second value with the first value.
    Its a programe which will udpate the second file with the first file values.
    I tried using Properties class but it didnt worked because when i am saving the file using store method it removes all the comments and the order of text also got disturbed.
    How I need to do this any help appriciated.
    Please elt me know if someone needs more info.
    Thanks in advance.

    Let's assume the ini file is a mapping type storage (key=value) so lets use Properties object. (works with java 1.4 & up)
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.util.Properties;
    public class Test {
         private static Properties props;
         public static void main(String[] args) throws IOException {
              File file = new File("test.ini");//This is out ini file
              props = new Properties();//Create the properties object
              read(file);//Read the ini file
              //Once we've populated the Properties object. set/add a property using the setProperty() method.
              props.setProperty("testing", "value");
              write(file);//Write to ini file
         public static void read(File file) throws IOException {
              FileInputStream fis = new FileInputStream(file);//Create a FileInputStream
              props.load(fis);//load the ini to the Properties file
              fis.close();//close
         public static void write(File file) throws IOException {
              FileOutputStream fos = new FileOutputStream(file);//Create a FileOutputStream
              props.store(fos, "");//write the Properties object values to our ini file
              fos.close();//close
    }

  • How to use xliff as resource bundle ?

    I used to do Java i18n as following base on resource bundle in properties file format:
    Locale myLocale = new Locale("es", "ES");
    ResourceBundle bundle = ResourceBundle.getBundle("HelloResourceBundle", myLocale);
    System.out.println(bundle.getString("Hello"));I realized that there is new bundle called xliff like:
    <trans-unit id="Hello">
    <source>Hello how are you</source>
    <note>This is message to say hello</note>
    </trans-unit>Does java resource bundle support xliff file similar to properties file? if not, could anybody give an example how to handle xliff file?
    Thanks

    Following code worked for me:
    import oracle.javatools.resourcebundle.BundleFactory;
    import java.util.ResourceBundle;
    * This method retrieves localized strings from a given XLIF resource bundle.
    * @param bundleName The XLIF bundle from which the localized string is to be retrieved.
    * @param key The key of the localized string.
    * @return The localized string retrieved from the given XLIF bundle.
    public static String getXlifLocalizedString(String bundleName, String key) {
    if (StringUtils.isEmpty(key)) {
    return key;
    if (StringUtils.isEmpty(bundleName)) {
    return "[" + key + "]";
    String localizedString = null;
    ResourceBundle resourceBundle = null;
    try {
    resourceBundle = BundleFactory.getBundle(bundleName);
    localizedString = resourceBundle.getString(key);
    } catch (Exception e) {
    LOG.log(Level.SEVERE, "Problem in loading XLIF resource bundle: " + bundleName, e);
    return "[" + key + "]";
    return localizedString;
    }

  • How faces-config with two resource bundle???

    Hi all,
    In my application,
    I want to put several message bundle in faces-config.xml.
    How can I do that?
    I defined two message bundle like
    <application>
    <default-render-kit-id>oracle.adf.core</default-render-kit-id>
    <message-bundle>com.resource1</message-bundle>
    <message-bundle>com.resource2</message-bundle>
    <locale-config>
    <supported-locale>en</supported-locale>
    </locale-config>
    </application>
    but the application cannot get messages in resource1 file.

    Hi,
    you need to load the bundles on the page
    <f:loadBundle basename="Bundle" var="msg"/>
    <f:loadBundle basename="Bundle2" var="msg2"/>
    <af:outputText value="#{msg[\'message.key\']}"/>
    <af:outputText value="#{msg2[\'message.key\']}"/>
    Then you can use strings in both properties files. If you only need the strings of one file, delete the other reference
    Frank

  • How to use a resource bundle in viewcontroller project

    How can I create a resource bundle for a viewcontroller project ? Is there any way to add entries to it other than adding manually editing the property file ? so that all the key generated will be unique? How to access a message in the resource bundle in my backing bean so that I can display it in my screen ?
    Thanks
    Suneesh

    Suneesh Raman wrote:
    How to access a message in the resource bundle in my backing bean so that I can display it in my screen ?Take a look at this: http://adfcodebits.blogspot.com/2010/04/bit-5-accessing-resource-bundle-from.html

  • How to deal with resource bundle in multiple applications system

    Hi all,
    I'm building new system depend on the method of
    one common model with multiple applications for the view objects
    my JDeveloper version 11.1.2.3
    my Question
    How can i merge the resource bundle for these applications
    as in the common model exists file for resouce bundle
    and each other applications contains resource bundle files how can i merge all these file in one Resource bundle file ?
    Edited by: 985756 on Apr 2, 2013 12:39 AM

    Hi,
    Please check anerjusb blog for your answer
    Hoping this will help you.
    http://andrejusb.blogspot.in/2009/12/reusing-resource-bundles-from-different.html
    Thanks & Regards,
    Vikas

  • How to use resource bundles?

    I have a requirement to translate the test that appears on the custom buttons of my portal application. I know resource bundles are part of .properties file that are delivered in Classes floder. But i am not sure how should i make use of this in translating the button text. It would be grate if someone knows it. I will be  very helpfull.
    Regards,
    Ameya

    Hi Ameya,
    [This link|http://help.sap.com/saphelp_nw04/helpdata/en/74/641640b7b6dd5fe10000000a155106/frameset.htm] will provide you information on how to implement Portal Content Translation.
    [This link|http://help.sap.com/saphelp_nw04/helpdata/en/62/8b1d40bb37e569e10000000a155106/frameset.htm] will explain how to create and access Resource Bundles (read the entire chapter).
    Hope it helps,
    Roy
    Edited by: Roy Cohen on Nov 26, 2008 3:21 PM

  • WebCenter Spaces: Customise Resource Bundles?

    Does anyone know if and how the webcenter spaces resource bundles may be customised or overridden?
    I need to rename the "My Group Spaces" tab to a custom name. I see that the label is obtained (within webcenter java code) from a resource bundle "oracle.webcenter.webcenterapp.resource.WebCenterResourceBundle".
    Thanks in advance,
    Bijesh

    Read this white paper: http://www.oracle.com/technetwork/middleware/webcenter/owcs-r11-extend-spaces-wp-132596.pdf
    Page 42: Renaming the personal space tab.
    The paper should also explain how to create your own resource bundle.

  • How to merge two resource bundle values ?

    Hi All,
    JDev ver : 11.1.1.7
    I want to merge two resource bundle values.. How to do it ?
    like this #{expr ? str1 : str1 + str2}
    I tried like the one below and used some jstl fuctions... but no use not worked.. got some parse exception, compilation exception,etc..
      <af:outputText value="#{ row.accountName eq 'AccountName9' ? resource['LBL_WELC'] : resource['LBL_WELC'] + resource['LBL_HOME'] }"/>
    Let me know how to do this ?
    Regards,
    Gopi

    The above outputtext is an example, I may use diff bundle keys like below,
    <af:outputText value="#{ row.accountName eq 'AccountName9' ? resource['LBL_TEST'] : resource['LBL_KEY1'] + resource['LBL_KEY2'] }"/>
    The principle is the same
    <af:outputText value="#{ row.accountName eq 'AccountName9' ? resource['LBL_TEST'] : '' }#{ row.accountName eq 'AccountName9' ? '' : resource['LBL_KEY1'] }#{ row.accountName eq 'AccountName9' ? '' : resource['LBL_KEY2'] }"/>
    Dario

  • How to use XLIFF file as resource bundle in Java code

    We use xliff as resource bundle for our ADF application. it is has been no problem to have localized message displayed on UI. how ever, I'm wonderring how to use Java code to access xliff as resource bundle which similar to access properties resource bundle. for example:
    Locale myLocale = new Locale("es", "ES");
    ResourceBundle bundle = ResourceBundle.getBundle("HelloResourceBundle", myLocale);
    System.out.println(bundle.getString("Hello"));is it posible to create "HelloResourceBundle" in xliff format?
    Thanks

    Following code worked for me:
    import oracle.javatools.resourcebundle.BundleFactory;
    import java.util.ResourceBundle;
    * This method retrieves localized strings from a given XLIF resource bundle.
    * @param bundleName The XLIF bundle from which the localized string is to be retrieved.
    * @param key The key of the localized string.
    * @return The localized string retrieved from the given XLIF bundle.
    public static String getXlifLocalizedString(String bundleName, String key) {
    if (StringUtils.isEmpty(key)) {
    return key;
    if (StringUtils.isEmpty(bundleName)) {
    return "[" + key + "]";
    String localizedString = null;
    ResourceBundle resourceBundle = null;
    try {
    resourceBundle = BundleFactory.getBundle(bundleName);
    localizedString = resourceBundle.getString(key);
    } catch (Exception e) {
    LOG.log(Level.SEVERE, "Problem in loading XLIF resource bundle: " + bundleName, e);
    return "[" + key + "]";
    return localizedString;
    }

  • Concat Strings to create a Resource Bundle KEY

    Hello, I`m having a little problem. I need, at the same point o a JSF page to show 2 different messages depending on a String variable value inside a Bean.
    Then I was thinking if a could have the 2 different keys for the 2 different messages written in the bundle file, but the first part of the key would be the same, then the second would be equal to the String variable in the bean, so I would need to do a concatenation to get the correct KEY and then retrieve the correct message. Is that possible? If so, how could I do that?
    So far, I have tried: But none worked
    #{messages[''+'']}
    #{messages[''] + messages['']}

    The + is an arithmetic operator, not string-concatenation -- if you apply it to strings, the EL will attempt to coerce them to numeric values in order to apply the '+'.
    There are some string manipulation functions in the JSTL standard function library. "str-concat" is not one of them, but there is a "replace" function.
    Assuming your resource bundle is called 'messages' and the key suffix is in a bean called 'keysuffix', you could try something like this:
    #{message[fn:replace('blah.blah.SUFFIX', 'SUFFIX', keysuffix)]}

  • How to configure resource bundle in facescontext.xml in JSF

    I have to take each label from the resource bundle in my web application, so how to configure resource bundle in JSF and how to use it, so please help me.....

    Follow the below mentioned steps ::
    1) make a properties file say mymessages.properties alongwith your java files. Put content like
    click=Click Me !!!
    #where click is the key and Click Me !!! is the actual value that needs to be displayed
    2) Add in faces-config.xml like this ::
    <application>
              <message-bundle>mymessages.mymessages</message-bundle>
         </application>     
    3) Use in your jsp page like this ::
    <f:view>
    <f:loadBundle basename="mymessages/mymessages" var="msg"/>
    hello :: <h:commandButton value="#{msg.click}" onclick="callJavaMethod()"></h:commandButton>
    </f:view>

  • How to link the resource bundle in JSF implemented in  eclipse?

    Kindly help me out

    This is how I called the resource bundle in JSF
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
    <%@ taglib prefix="f" uri="http://java.sun.com/jsf/core"%>
    <%@ taglib prefix="h" uri="http://java.sun.com/jsf/html"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
    </head>
    <body>
    <f:view>
    <f:loadBundle basename="constantsUIProp" var="prop"/>
    <h:form>
    <h:inputText maxlength="#{prop.AREA_CODE_MAX}"></h:inputText>
    </h:form>
    </f:view>
    </body>
    </html>
    when i tend to build, it shows an error like+ Resource bundle cannot be found on the classpath+
    I have saved the resource bundle in WebContent/Web-Inf/classes/constantsUIProp

  • How to use resource bundle entries for column names/title in .rpt file

    <p>Our application needs to be able to support reporting in multiple languages. Hence we do not want to put language specifiec column names in the rpt file but rather use text for a particular locale during runtime which in java world is easily achievable using Resource Bundle entries.</p><p>Does JRC allow for using resource bundle entries as column names or for that matter for titles etc. in the .rpt file?</p>

    Hi,
       You can follow this step-by-step tutorial to find out how to achieve this using our User Function Libraries (UFLs). The walkthrough can be found here:
    <a href="http://diamond.businessobjects.com/node/412">http://diamond.businessobjects.com/node/412</a>
    Regards,<br />Sean Johnson (CR4E Product Manager) <br /><br /> <a href="http://www.eclipseplugincentral.com/Web_Links-index-req-ratelink-lid-639.html">Rate this plugin @ Eclipse Plugin Central</a>

Maybe you are looking for