Adrian:
how about putting this explanation in the code?

Adrian Crum sent the following on 1/2/2008 9:41 AM:
> Scott,
> 
> Thank you for taking care of the "ripple effect" of the recent
> UtilProperties changes. This commit breaks the properties file resolver
> code however. Java xml properties files use the same naming convention
> as *.properties files (resource_locale.xml).
> 
> I'll go into a little detail here for the benefit of anyone interested.
> 
> Getting UtilProperties.java to support multiple properties file formats
> was no easy task. Each format must be resolved along with a specified
> locale. The Java properties file naming convention makes the process
> pretty straightforward and simple:
> 
> http://java.sun.com/j2se/1.4.2/docs/api/java/util/ResourceBundle.html#getBundle(java.lang.String,%20java.util.Locale,%20java.lang.ClassLoader)
> 
> 
> but adding in the OFBiz custom XML file format throws a wrench in the
> machinery. If the resource "ExampleUiLabels" and locale "en_US" resolve
> to "ExampleUiLabels.xml" - how do we know if that xml file is "resource
> of last resort" found in the getBundle(...) strategy mentioned in the
> link, or if it's an OFBiz custom xml file that contains multiple
> locales? I couldn't think of any way to differentiate between the two
> except to specify the ".xml" in the resource name of the OFBiz custom
> xml file format.
> 
> So, a better way to solve the problem in the Example component would be
> to change all
> 
> resource="ExampleUiLabels"
> 
> to
> 
> resource="ExampleUiLabels.xml"
> 
> which will enable UtilProperties to resolve and process the OFBiz custom
> file format.
> 
> -Adrian
> 
> [EMAIL PROTECTED] wrote:
>> Author: lektran
>> Date: Tue Jan  1 02:50:01 2008
>> New Revision: 607823
>>
>> URL: http://svn.apache.org/viewvc?rev=607823&view=rev
>> Log:
>> Fixed a small problem with the new xml uiLabels, fail-property in
>> minilang wasn't able to retrieve any xml properties.
>>
>> Modified:
>>    
>> ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilProperties.java
>>
>>
>> Modified:
>> ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilProperties.java
>>
>> URL:
>> http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilProperties.java?rev=607823&r1=607822&r2=607823&view=diff
>>
>> ==============================================================================
>>
>> ---
>> ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilProperties.java
>> (original)
>> +++
>> ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilProperties.java
>> Tue Jan  1 02:50:01 2008
>> @@ -665,6 +665,7 @@
>>          if (UtilValidate.isEmpty(resource)) {
>>              throw new IllegalArgumentException("resource cannot be
>> null or empty");
>>          }
>> +        // This is for *.properties files only (not *.xml files)
>>          String resourceName = createResourceName(resource, locale);
>>          if (propertiesNotFound.contains(resourceName)) {
>>              return null;
>> @@ -679,7 +680,7 @@
>>                  }
>>              }
>>              // Check for XML properties file next
>> -            url = FlexibleLocation.resolveLocation(resourceName +
>> ".xml");
>> +            url = FlexibleLocation.resolveLocation(resource + ".xml");
>>              if (url != null) {
>>                  return url;
>>              }
>>
>>
>>
> 
> 
> 
> 

Reply via email to