[html-formfu] *_loc: extraction

Andreas Marienborg omega at palle.net
Tue Feb 12 13:36:38 GMT 2008


On Feb 12, 2008, at 12:55 PM, Carl Franks wrote:

> On 12/02/2008, Andreas Marienborg <omega at palle.net> wrote:
>>
>> On Feb 12, 2008, at 11:05 AM, Andreas Marienborg wrote:
>>
>>> I use xgettext.pl to extract my .po-files from .pm, .js and .tt. I
>>> would also like to extract .yml (forms).
>>>
>>> Has anyone else already done that? If not, I'll try to cook up a  
>>> patch
>>
>> I like talking to myself:
>>
>> http://rt.cpan.org/Ticket/Display.html?id=33166
>
> Without knowing anything about Locale-Maketext-Lexicon... would it
> support some way of using YAML(::Syck)? to read the file, and then
> traversing the data structure? - as it'd be a lot more robust than
> using a regex
>
> For example, how would it handle single- or double-quoted strings?
>    label_loc: 'foo bar'
>    label_loc: "foo o'reilly"
> Or the really funky stuff:
>    label_loc: |
>      string with
>      embedded newline
>

It works by using regexeses. For a more permanent and extensible fix,  
it should prolly be rewritten to some sort of pluggable parser of some  
sort.  It for now only handles the really easy ones without quotes,  
but as there seems to be some problems with my latest patch, I will  
need to write more testcases and a new patch, so I'll see about quotes  
etc as well then :/

> Anyway, to be honest, I find the whole lexicon approach a bit  
> backwards.
> As far as I can see, it means if you need to change a string in the
> 'native' language that you've used as a ke, it means you need to go
> through all the other language files, and change the corresponding
> key/string.

>
> That's why I prefer using a made-up string as the key, such as
> 'constraint_required' - it says what it is, not what it says (um,
> yeah, I think that's right)
>

I use IDs for my localization, not natural language, so I guess it all  
comes down to preference :)


- andreas




More information about the HTML-FormFu mailing list