Scott Gray wrote:
Ok thanks for checking up on it, I had assumed that if we could find
ExampleUiLabels.xml then that would contain all of the available locale
translations end of story.
That would be true if we supported only one xml format. With our custom
xml format,
ExampleUiLabels.xml could be one of two formats.
So for example are you saying that if the local
is "ru" it should try and find ExampleUiLabels_ru.properties before
looking
at ExampleUiLabels.xml?
Using the current UtilProperties resolver code, resource =
"ExampleUiLabels" and locale = "ru" and
server locale = "en", here are the candidate file names in order:
ExampleUiLabels_ru.xml
ExampleUiLabels_ru.properties
ExampleUiLabels_ru
ExampleUiLabels_en.xml
ExampleUiLabels_en.properties
ExampleUiLabels_en
ExampleUiLabels.xml
ExampleUiLabels.properties
ExampleUiLabels
So, the resolver code works just like ResourceBundle.getBundle(...) except
it also checks for xml
files. Without the ".xml" extension embedded in the resource name, the
code assumes each file
contains only one locale. That's how we maintain compatibility with
existing properties files.
I figured we were supporting one style or the other but not both for the
same resource, or am I completely missing what your saying?
Ideally, we should support the Java standard properties file formats in
addition to our own. Some
shops might frown on "proprietary" file formats and prefer to use the Java
standards.
-Adrian
Scott
On 03/01/2008, Adrian Crum <[EMAIL PROTECTED]> wrote:
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;
}