Tuesday, December 31, 2013

ADF resource bundles

When you add any UI hints the project level resource bundles are getting created.We can access the resource bundle properties from the project properties dialog

Custom settings are not recorded with the project and cannot be shared with other users who use this project.You can note the basic configuration preferences options above.Resource bundle types are Properties Bundle which is the default option ,List resource bundle and Xliff resource bundel

Properties Resource bundle 

Create a new .properties file from the New Gallery option.Add name value pair for the property file.We can add the resource bundle from the "Bundle Search" tab.
From the UI hints section you can search fro the new Properties Bundle created.

List Resource Bundle 

Create a java class

import java.util.ListResourceBundle;

public class TestListResBundle  extends ListResourceBundle {

    @Override
    protected Object[][] getContents() {
        // TODO Implement this method
        return contents;
    }
    static final Object[][] contents = {
          {"key1", "Cabinet {0} contains {1} folders."},
          {"key2", "Folder {0} contains " +
                    "{1,choice,0#no files|1#one file|1<{1,number,integer} files}."},
          {"key3", "Folder \'{0}\' is empty."},                     
          {"key4", "File \"My Stuff\" deleted."},                    
          {"key5", "Added {0,number} files."},            
          {"key6", "Testr"},
          {"key7", "No files were removed while processing " +
                         "current folder."}
      };

    }
Add the resource bundle to the project 
Select the resource bundle from the list resource bundle 

Xliff Resource bundle 

Create a .xlf file 
<?xml version="1.0" encoding="windows-1252" ?>
<xliff version="1.1" xmlns="urn:oasis:names:tc:xliff:document:1.1">
  <file source-language="en" original="myResources" datatype="xml">
    <body>
      <trans-unit id="NAME">
        <source>Name</source>
        <target/>
        <note>Name of employee</note>
      </trans-unit>
      <trans-unit id="HOME_ADDRESS">
        <source>Home Address</source>
        <target/>
        <note>Adress of employee</note>
      </trans-unit>
      <trans-unit id="OFFICE_ADDRESS">
        <source>Office Address</source>
        <target/>
        <note>Office building </note>
      </trans-unit>
    </body>
  </file>
</xliff>
Add xlf resource bundle as other resource bundles.Select the resource bundle for UI hints properties from xlf resource bundle 

No comments:

Post a Comment