Re: svn commit: r607823 - /ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilProperties.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
15 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r607823 - /ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilProperties.java

Adrian Crum
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

[hidden email] 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 | Threaded
Open this post in threaded view
|

Re: svn commit: r607823 - /ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilProperties.java

Scott Gray
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.  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?

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?

Scott

On 03/01/2008, Adrian Crum <[hidden email]> 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
>
> [hidden email] 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 | Threaded
Open this post in threaded view
|

Re: svn commit: r607823 - /ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilProperties.java

Adrian Crum
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 <[hidden email]> 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
>>
>>[hidden email] 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 | Threaded
Open this post in threaded view
|

Re: svn commit: r607823 - /ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilProperties.java

BJ Freeman
In reply to this post by Adrian Crum
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
>
> [hidden email] 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 | Threaded
Open this post in threaded view
|

Re: svn commit: r607823 - /ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilProperties.java

Scott Gray
In reply to this post by Adrian Crum
Ok I understand what you're trying to achieve, not going to work with the
current code though, if the resource string ends with .xml we're only ever
going to be able to find ExampleUiLabels.xml, but if we take it out then
anything contained with ExampleUiLabels.xml will never be found.  In the
list for "ru" below, by the time you get to ExampleUiLabels.xml the file is
found but then is searched for the locale "".

Regards
Scott

On 03/01/2008, Adrian Crum <[hidden email]> wrote:

>
> 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 <[hidden email]> 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
> >>
> >>[hidden email] 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 | Threaded
Open this post in threaded view
|

Re: svn commit: r607823 - /ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilProperties.java

Adrian Crum
Scott Gray wrote:
> Ok I understand what you're trying to achieve, not going to work with the
> current code though, if the resource string ends with .xml we're only ever
> going to be able to find ExampleUiLabels.xml, but if we take it out then
> anything contained with ExampleUiLabels.xml will never be found.  In the
> list for "ru" below, by the time you get to ExampleUiLabels.xml the file is
> found but then is searched for the locale "".
>
> Regards
> Scott

Exactly! We can mix *.properties and *.xml files if the *.xml files are in the Java xml file format.
By having the custom format, we have to choose one way or the other - we can't have both.

I'm sure the custom xml format idea will be refined as time goes on. Maybe someone can come up with
a better resolver strategy.

It will be interesting to see how the community reacts to the two xml file formats. Personally, I
don't have a strong leaning either way. The Java xml file format is a standard and operates the same
as the *.properties file format, but on the other hand having all translations in a single file has
benefits too.

-Adrian

>
> On 03/01/2008, Adrian Crum <[hidden email]> wrote:
>
>>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 <[hidden email]> 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
>>>>
>>>>[hidden email] 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 | Threaded
Open this post in threaded view
|

Re: svn commit: r607823 - /ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilProperties.java

Scott Gray
Oh ok I see, so we can either have this:
resource="ExampleUiLabels"
ExampleUiLabels_ru.xml
ExampleUiLabels_en.xml
but *not* ExampleUiLabels.xml

or this:
resource="ExampleUiLabels"
ExampleUiLabels_ru.properties
ExampleUiLabels_en.properties
ExampleUiLabels.properties

or this:
resource="ExampleUiLabels.xml"
ExampleUiLabels.xml

but no combination of the above, correct?

Regards
Scott

On 03/01/2008, Adrian Crum <[hidden email]> wrote:

>
> Scott Gray wrote:
> > Ok I understand what you're trying to achieve, not going to work with
> the
> > current code though, if the resource string ends with .xml we're only
> ever
> > going to be able to find ExampleUiLabels.xml, but if we take it out then
> > anything contained with ExampleUiLabels.xml will never be found.  In the
> > list for "ru" below, by the time you get to ExampleUiLabels.xml the file
> is
> > found but then is searched for the locale "".
> >
> > Regards
> > Scott
>
> Exactly! We can mix *.properties and *.xml files if the *.xml files are in
> the Java xml file format.
> By having the custom format, we have to choose one way or the other - we
> can't have both.
>
> I'm sure the custom xml format idea will be refined as time goes on. Maybe
> someone can come up with
> a better resolver strategy.
>
> It will be interesting to see how the community reacts to the two xml file
> formats. Personally, I
> don't have a strong leaning either way. The Java xml file format is a
> standard and operates the same
> as the *.properties file format, but on the other hand having all
> translations in a single file has
> benefits too.
>
> -Adrian
>
> >
> > On 03/01/2008, Adrian Crum <[hidden email]> wrote:
> >
> >>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 <[hidden email]> 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
> >>>>
> >>>>[hidden email] 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 | Threaded
Open this post in threaded view
|

Re: svn commit: r607823 - /ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilProperties.java

Adrian Crum
We can have resource="ExampleUiLabels" where ExampleUiLabels.xml is the OFBiz custom format that
contains ALL translations,

-or-

we can have resource="ExampleUiLabels" where properties files are any combination of Java xml format
files or *.properties files.

So, this would work:

ExampleUiLabels_ru.xml (Java xml format)
ExampleUiLabels_en.properties
ExampleUiLabels.xml (Java xml format)

-Adrian

Scott Gray wrote:

> Oh ok I see, so we can either have this:
> resource="ExampleUiLabels"
> ExampleUiLabels_ru.xml
> ExampleUiLabels_en.xml
> but *not* ExampleUiLabels.xml
>
> or this:
> resource="ExampleUiLabels"
> ExampleUiLabels_ru.properties
> ExampleUiLabels_en.properties
> ExampleUiLabels.properties
>
> or this:
> resource="ExampleUiLabels.xml"
> ExampleUiLabels.xml
>
> but no combination of the above, correct?
>
> Regards
> Scott
>
> On 03/01/2008, Adrian Crum <[hidden email]> wrote:
>
>>Scott Gray wrote:
>>
>>>Ok I understand what you're trying to achieve, not going to work with
>>
>>the
>>
>>>current code though, if the resource string ends with .xml we're only
>>
>>ever
>>
>>>going to be able to find ExampleUiLabels.xml, but if we take it out then
>>>anything contained with ExampleUiLabels.xml will never be found.  In the
>>>list for "ru" below, by the time you get to ExampleUiLabels.xml the file
>>
>>is
>>
>>>found but then is searched for the locale "".
>>>
>>>Regards
>>>Scott
>>
>>Exactly! We can mix *.properties and *.xml files if the *.xml files are in
>>the Java xml file format.
>>By having the custom format, we have to choose one way or the other - we
>>can't have both.
>>
>>I'm sure the custom xml format idea will be refined as time goes on. Maybe
>>someone can come up with
>>a better resolver strategy.
>>
>>It will be interesting to see how the community reacts to the two xml file
>>formats. Personally, I
>>don't have a strong leaning either way. The Java xml file format is a
>>standard and operates the same
>>as the *.properties file format, but on the other hand having all
>>translations in a single file has
>>benefits too.
>>
>>-Adrian
>>
>>
>>>On 03/01/2008, Adrian Crum <[hidden email]> wrote:
>>>
>>>
>>>>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 <[hidden email]> 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
>>>>>>
>>>>>>[hidden email] 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 | Threaded
Open this post in threaded view
|

Re: svn commit: r607823 - /ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilProperties.java

Scott Gray
Right but in this case ExampleUiLabels.xml would only be able to contain
single property values with a blank locale like this:
    <property key="ExampleType.description.REAL_WORLD">
        <value xml:lang="">Real World</value>
    </property>

Regards
Scott


On 03/01/2008, Adrian Crum <[hidden email]> wrote:

>
>
> So, this would work:
>
> ExampleUiLabels_ru.xml (Java xml format)
> ExampleUiLabels_en.properties
> ExampleUiLabels.xml (Java xml format)
>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r607823 - /ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilProperties.java

Adrian Crum
Correct. I'm sorry if I wasn't clear. Java XML file format only allows one locale per file.
Basically it works just like *.properties files.

The concept of having more than one locale in a single properties file is unique to OFBiz and its
custom format.

-Adrian

Scott Gray wrote:

> Right but in this case ExampleUiLabels.xml would only be able to contain
> single property values with a blank locale like this:
>     <property key="ExampleType.description.REAL_WORLD">
>         <value xml:lang="">Real World</value>
>     </property>
>
> Regards
> Scott
>
>
> On 03/01/2008, Adrian Crum <[hidden email]> wrote:
>
>>
>>So, this would work:
>>
>>ExampleUiLabels_ru.xml (Java xml format)
>>ExampleUiLabels_en.properties
>>ExampleUiLabels.xml (Java xml format)
>>
>>
>>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r607823 - /ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilProperties.java

Scott Gray
Ok got it (finally) thanks for persevering , perhaps we'll need to detail
this in a readme in the config folders otherwise we'll get endless questions
on the user list.  I'll take care of when I get a chance.

Regards
Scott

On 03/01/2008, Adrian Crum <[hidden email]> wrote:

>
> Correct. I'm sorry if I wasn't clear. Java XML file format only allows one
> locale per file.
> Basically it works just like *.properties files.
>
> The concept of having more than one locale in a single properties file is
> unique to OFBiz and its
> custom format.
>
> -Adrian
>
> Scott Gray wrote:
>
> > Right but in this case ExampleUiLabels.xml would only be able to contain
> > single property values with a blank locale like this:
> >     <property key="ExampleType.description.REAL_WORLD">
> >         <value xml:lang="">Real World</value>
> >     </property>
> >
> > Regards
> > Scott
> >
> >
> > On 03/01/2008, Adrian Crum <[hidden email]> wrote:
> >
> >>
> >>So, this would work:
> >>
> >>ExampleUiLabels_ru.xml (Java xml format)
> >>ExampleUiLabels_en.properties
> >>ExampleUiLabels.xml (Java xml format)
> >>
> >>
> >>
> >
> >
>
>
Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r607823 - /ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilProperties.java

Adrian Crum
Scott Gray wrote:
> Ok got it (finally) thanks for persevering , perhaps we'll need to detail
> this in a readme in the config folders otherwise we'll get endless questions
> on the user list.  I'll take care of when I get a chance.
>
> Regards
> Scott

Well, I'd still like to see the process change so it's less confusing. The only component being
affected right now is the Example component. Maybe we can come up with a better resolver strategy
before the custom xml format is more widely adopted.

In other words, the behavior you expected at the start should work. We just have to figure out how
to make it work that way.

-Adrian



Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r607823 - /ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilProperties.java

Scott Gray
I had an idea on that, I'll put it down in code and see if it looks any
good.  I'll send a patch here if works out.

Regards
Scott

On 03/01/2008, Adrian Crum <[hidden email]> wrote:

>
> Scott Gray wrote:
> > Ok got it (finally) thanks for persevering , perhaps we'll need to
> detail
> > this in a readme in the config folders otherwise we'll get endless
> questions
> > on the user list.  I'll take care of when I get a chance.
> >
> > Regards
> > Scott
>
> Well, I'd still like to see the process change so it's less confusing. The
> only component being
> affected right now is the Example component. Maybe we can come up with a
> better resolver strategy
> before the custom xml format is more widely adopted.
>
> In other words, the behavior you expected at the start should work. We
> just have to figure out how
> to make it work that way.
>
> -Adrian
>
>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r607823 - /ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilProperties.java

Adrian Crum
I was thinking about it too. Maybe around line 479 we could have something like "if bundle is null
and resource name doesn't contain '.xml', append '.xml' to resource name and call
UtilResourceBundle.getBundle(...) again."

-Adrian

Scott Gray wrote:

> I had an idea on that, I'll put it down in code and see if it looks any
> good.  I'll send a patch here if works out.
>
> Regards
> Scott
>
> On 03/01/2008, Adrian Crum <[hidden email]> wrote:
>
>>Scott Gray wrote:
>>
>>>Ok got it (finally) thanks for persevering , perhaps we'll need to
>>
>>detail
>>
>>>this in a readme in the config folders otherwise we'll get endless
>>
>>questions
>>
>>>on the user list.  I'll take care of when I get a chance.
>>>
>>>Regards
>>>Scott
>>
>>Well, I'd still like to see the process change so it's less confusing. The
>>only component being
>>affected right now is the Example component. Maybe we can come up with a
>>better resolver strategy
>>before the custom xml format is more widely adopted.
>>
>>In other words, the behavior you expected at the start should work. We
>>just have to figure out how
>>to make it work that way.
>>
>>-Adrian
>>
>>
>>
>>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: svn commit: r607823 - /ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/UtilProperties.java

Scott Gray
Here's my idea, it checks in this order:
ExampleUiLabels_ru.xml
ExampleUiLabels_ru.properties
ExampleUiLabels_ru
ExampleUiLabels.xml  (for ru locale)
ExampleUiLabels_en.xml
ExampleUiLabels_en.properties
ExampleUiLabels_en
ExampleUiLabels.xml (for en locale)
ExampleUiLabels.xml (for blank locale)
ExampleUiLabels.properties
ExampleUiLabels
ExampleUiLabels.xml (for blank locale again lol, that can be fixed)

I also added a static Set xmlPropertiesNotFound, so that we don't keep
checking the same xml url for the same locale

Don't worry, I won't be offended if you don't like it :-)

Regards
Scott


Index: framework/base/src/base/org/ofbiz/base/util/UtilProperties.java
===================================================================
--- framework/base/src/base/org/ofbiz/base/util/UtilProperties.java
(revision 608288)
+++ framework/base/src/base/org/ofbiz/base/util/UtilProperties.java
(working copy)
@@ -697,6 +697,11 @@
             if (url != null) {
                 return url;
             }
+            // Lastly check in ${resource}.xml (ie. ExampleUiLabels.xml)
because it can hold multiple locales
+            url = FlexibleLocation.resolveLocation(resource + ".xml");
+            if (url != null) {
+                return url;
+            }
         } catch (Exception e) {
             Debug.logInfo("Properties resolver: invalid URL - " +
e.getMessage(), module);
         }
@@ -867,10 +872,16 @@
         public ExtendedProperties(Properties defaults) {
             super(defaults);
         }
+        protected static Set<String> xmlPropertiesNotFound =
FastSet.newInstance();
         public ExtendedProperties(URL url, Locale locale) throws
IOException, InvalidPropertiesFormatException {
             InputStream in = new BufferedInputStream(url.openStream());
             if (url.getFile().endsWith(".xml")) {
-                xmlToProperties(in, locale, this);
+                if (xmlPropertiesNotFound.contains(url.toString() +
locale.toString())) {
+                    xmlToProperties(in, locale, this);
+                    if (UtilValidate.isEmpty(this)) {
+                        xmlPropertiesNotFound.add(url.toString() +
locale.toString());
+                    }
+                }
             } else {
                 load(in);
             }

On 03/01/2008, Adrian Crum <[hidden email]> wrote:

>
> I was thinking about it too. Maybe around line 479 we could have something
> like "if bundle is null
> and resource name doesn't contain '.xml', append '.xml' to resource name
> and call
> UtilResourceBundle.getBundle(...) again."
>
> -Adrian
>
> Scott Gray wrote:
>
> > I had an idea on that, I'll put it down in code and see if it looks any
> > good.  I'll send a patch here if works out.
> >
> > Regards
> > Scott
> >
> > On 03/01/2008, Adrian Crum <[hidden email]> wrote:
> >
> >>Scott Gray wrote:
> >>
> >>>Ok got it (finally) thanks for persevering , perhaps we'll need to
> >>
> >>detail
> >>
> >>>this in a readme in the config folders otherwise we'll get endless
> >>
> >>questions
> >>
> >>>on the user list.  I'll take care of when I get a chance.
> >>>
> >>>Regards
> >>>Scott
> >>
> >>Well, I'd still like to see the process change so it's less confusing.
> The
> >>only component being
> >>affected right now is the Example component. Maybe we can come up with a
> >>better resolver strategy
> >>before the custom xml format is more widely adopted.
> >>
> >>In other words, the behavior you expected at the start should work. We
> >>just have to figure out how
> >>to make it work that way.
> >>
> >>-Adrian
> >>
> >>
> >>
> >>
> >
> >
>
>