lyonplus / gettext-commons

Automatically exported from code.google.com/p/gettext-commons
GNU Lesser General Public License v2.1
0 stars 0 forks source link

Support for JSF #59

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Gettext-commons doesn't seem to support JSF.

How hard it would be to add special taglib for those?

The project jhorstmann does something about this, but it doesn/t seem to be 
updated anymore:
https://github.com/jhorstmann/i18n

Original issue reported on code.google.com by agervais...@gmail.com on 11 Jun 2014 at 5:22

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Hi,

It seems that JFS read .properties files, and gettext-commons can generate 
properties from PO using the maven instruction 
<outputFormat>properties</outputFormat>

-Nicolas Fortin
IRSTV FR CNRS 2488

Original comment by nico.de...@gmail.com on 5 Feb 2015 at 9:41

GoogleCodeExporter commented 8 years ago
Yeah, JSF can even read .class as well as outputFormat but the point of using 
.po file is the ability to parse all the "key" required from a source(say a 
.java or a .xhtml for this particuliar case) and to store them into a ".pot". A 
tool similar to GNU-Gettext, or the software of jhorstmann(which use a maven 
plugin to parse the file) is rather handy.

Currently there's seem to be a work-around but, it's still incredibly messy:
1- Let's say we use:
xgettext.exe -k_ --files-from=sourceList.txt -o outCatalog.pot
Usually that command lookout for the file specified in "sourceList.txt" and 
search for of occurence of '_(myTranslationKey)', then grab the key of 
"myTranslationKey" and store it into a .pot file.

2- Then in JSF it is easy to create your own xhtml tag with a Composite 
Components(simple tutorial here: 
http://www.abnsoft.info/2012/01/24/jsf-composite-components-example/) with a 
custom taglib(http://stackoverflow.com/a/7080174/2141964) to bind function 

Sadly, xgettext isn't designed to parse .xhtml or .jsf efficiently since it is 
uncommon syntax different than "<%_('myTranslationKey')%>" (similar to jsp and 
few other) and there's might be a bunch of header where xgettext may attempt to 
parse and fail.

So at this point, my workaround to solve this problem(instead of hacking 
xgettext to add a custom way to fetch a value for a key) would be:
3- Create a preparser before running xgettext, so it can efficiently fetch all 
the key to store from .xhtml into a comprenhensive format for xgettext.

Of course, I'm sure there is a way to use exclusively .properties files and add 
a new key manually every time it is required to so, but that's not we want to 
do. But that's completely break the devlopper workflow.

Original comment by agervais...@gmail.com on 10 Feb 2015 at 4:32