Runtime components : Core components : Typed data : Concepts : NLS
  
NLS
For error messages during validation, each supported locale has a types_<locale>.properties and a typesext_<locale>.properties file (such as types_en.properties and typesext_en_US.properties). To provide National Language Support (NLS), the toolkit uses ErrorInfo's get(String id, Locale locale) method (which in turn uses the DSEType getMessageForLocale method) passing the key as the message ID and the locale stored in the dse_locale variable of the session as the locale. The getMessageForLocale method retrieves the localized message from the appropriate resource bundle.
Note The method first checks the typesext_<locale>.properties file before it checks the types_< locale>.properties file.
To see how NLS works with validation messages, look at the following:
public Object validateForType(Object toValidate, PropertyDescription descriptor, com.ibm.btt.base.Hashtable parameters) throws DSETypeException in com.ibm.btt.base.types.ext.DateValidator (in bttcore.jar). This method performs syntactic field validation. Its messages are translated in the typesext_xx_YY.properties files.
public void validate(String fullyQualifiedName, com.ibm.btt.base.DataField df, com.ibm.btt.base.Context ctxt) throws com.ibm.btt.base.types.DSETypeException method in AccountTransferXVal class in the HTML Sample Application. This method performs semantic field validation. Its messages are translated in the typesext_xx_YY.properties files.
typesext_xx_YY.properties files in bttcore.jar (TypedDataExtensions component) and updated typesext_xx_YY.properties files in the code for the HTML Sample Application. When creating an application, you should extract the files from the JAR, build your own by adding new messages as necessary, and locate them in the classpath.
To improve performance with localization, UDTT features two caches of resource bundle instances: typesext and types. The toolkit implements the caches as a Hashtable in the resTypesCache attribute (for classes in the com.ibm.btt.base.types package) and the resTypesExtCache attribute (for classes in the com.ibm.btt.base.types.ext package) of DSEType classes. The key in each Hashtable is the locale object and the value is the resource bundle associated with the locale. When the system needs to get a localized message, it searches in the caches for the locale's resource bundle. The system first looks in the typesext cache. If the system cannot find the resource bundle in the typesext cache, it then look in the types cache.
Note You can extend typesext resource bundles with your own codes to override resource bundles contained in the types cache because typesext resource bundles have priority over types resource bundles.
If the resource bundle is not in either cache, the system gets it, retrieves the localized message, and places the resource bundle in the cache. If the system cannot find the locale's resource bundle, it places a flag in the appropriate cache. The flag means that the system does not look for this resource bundle and reduces the high performance cost associated with throwing exceptions.
See also
Concepts