On Mon, Dec 21, 2009 at 1:35 AM, Clinton Gormley <[email protected]>wrote:
> > > As Andy said, this already works in Locale::Maketext::Lexicon, > specifically: > > http://search.cpan.org/~drtech/Locale-Maketext-Lexicon-0.77/lib/Locale/Maketext/Extract/Plugin/TT2.pm<http://search.cpan.org/%7Edrtech/Locale-Maketext-Lexicon-0.77/lib/Locale/Maketext/Extract/Plugin/TT2.pm> > Doesn't that extract text from just loc() tags? Sorry, I was not clear . I'm not trying to extract text form loc() calls, but from quoted strings in general. I already have a tool to find the loc() text. For example: $ cat test.tt [% loc( 'in loc' ); string = 'plain string'; some_macro( 'passed in text' ); %] This is plain text a loc('123') file That template has text entered in a number of ways. I'm not concerned with text outside of a template block (the "This is plain text" part). I already have a way to extract out my loc() text. $ xgettext.pl test.tt $ fgrep msgid messages.po msgid "" msgid "123" msgid "in loc" I'm after the opposite, really. What I'm after is the strings "plain string" and "passed in text" above. (BTW - Should that loc('123') be extracted??) I assume Template::Parser knows when it has quoted text. My concern is we have loc() that is called on variables. For example, that "some_macro()" above might do something and need to localize the passed-in text -- so inside the macro it calls loc( text ). Yes, probably should call "some_macro( loc( 'passed in text' ) )", but that's a different issue. Take a dozen developers and five or so years and see what comes out... ;) Anyway, if I could extract all the quoted text via the parser ('in loc', 'passed in string', and 'plain string' above) then I could compare that with what I've extracted via my other tool that just finds loc(). The idea is then I could report on strings that I need to check to make sure they are indeed localized. I can add additional functions to my existing script to extract more than just loc(), for example I can tell it to also look for some_macro(), but that won't catch simple variable assignment. In my templates, I use l(...) for phrases that should be translated > immediately, and loc(...) for "delayed translation", eg: > > labels = { > foo => loc('Foo [_1]', value), ## just marks for extraction > bar => loc('Bar [_1]', value), ## just marks for extraction > }; > > label = labels.$current; > > l(label,value); ## does actual translation, not extracted > Sorry, I don't get that delayed part. What do you mean? -- Bill Moseley [email protected]
_______________________________________________ templates mailing list [email protected] http://mail.template-toolkit.org/mailman/listinfo/templates
