Re: XML properties files - brainstorm

Posted by David E Jones on
URL: http://ofbiz.116.s1.nabble.com/XML-properties-files-brainstorm-tp185922p185947.html


On Nov 26, 2007, at 11:10 AM, Adrian Crum wrote:

> David Jones has suggested in the past that we start moving away from  
> using properties files for UI labels and such, and use XML files  
> instead. That subject has come up again in https://issues.apache.org/jira/browse/OFBIZ-1425 
> .
>
> I would be interested in helping out with the implementation, but  
> I'd like to get input from the developer community first.
>
> -----
>
> Here are some of the suggestions David made:
>
> "If we do something like that, here or anywhere, we should use XML  
> and not properties files. XML is about 1E6 times better than  
> properties files (name/value pairs) for organizing this sort of  
> information. It is hierarchical so much easier to organize and you  
> can use real UTF-8 characters there instead of having to encode  
> everything and use a special tool or a translator to work on the  
> files."
>
> and
>
> "In XML there are standard ways of doing this, namely using the  
> xml:lang attribute on an element to specify the language of the  
> content in an element."
>
> -----
>
> I have been thinking about this for a while, and I was picturing a  
> refactoring of the resource handling code so that it can read xml  
> files in addition to *.properties files. The file format would be  
> invisible from a programmer's perspective. In other words, the  
> method call UtilProperties.getPropertyValue("SomeResource",  
> "SomeProperty") would still work even if the "SomeResource" resource  
> was in an XML file.
>
> Or we can just have a utility to retrieve resources from an XML file.
>
> Regardless of how the properties are retrieved, we still need to  
> come up with a strategy (or schema) for the xml file format. I'm not  
> an XML guru, so this is one area where I could use some help.
>
> Do we continue to keep each language in a separate file or should we  
> have all properties for all languages in a single file?
>
> Are there any other issues anyone can think of?
>
> Comments welcome.
I'd like to hear other comments too.

For my part I think it would be nice to have all languages in a single  
XML file. One nice thing about XML is that we can do that sort of  
thing. Some of the ideas around this and shortcomings of the  
ResourceBundle properties files are:

1. the problem where you can't get the US English labels if the server  
locale is set to anything other than en_US, because the "default"  
properties file (with no locale suffix) is the en_US one

2. there is no way to configure the default locale without renaming  
properties files (ie what if someone wants it_IT to be the default  
locale instead of en_US so that if no locale is specified that is what  
will show up, as if the properties file with no locale suffix had the  
Italian labels)

3. the properties files have to be ASCII encoded, so we have to escape  
an transform unicode characters; in an XML file we can just use a  
unicode/UTF-8 capable editor and go for it

4. it is easier to scan down a single file to see what has been  
translated, ie no special properties file tool (like the nice one in  
NetBeans) is needed

-David



smime.p7s (3K) Download Attachment