views:

56

answers:

1

Hello,

I have a PO file with a content like:

msgid "or"
msgstr "or-translation"

msgid "orand"
msgstr "orand-translation"

I need to obtain the translation of a given msgid. Using the command "msggrep -K -e 'orand' template2.pot" I get the translation for 'orand', and this is ok.

But when I use "msggrep -K -e 'or' template2.pot" if returns both translation ('or' and 'orand'). The command "msggrep -K -e '^or' template2.pot" work as expected, returning both translations, but "msggrep -K -e '^or$' template2.pot" just fail becouse it returns nothing. Seems like the '$' character breaks msggrep regular-expression parser.

I have tried with other msggrep flags (like -F, -E...) but all of them reads testing patterns from a file, and it is unacceptable for my actual needs. I'm using msggrep 0.14.6 (and I can't update to a more recent library).

Does someone knows how can I get the translation for 'orand' using msggrep?

Thanks in advance.

+1  A: 

You can use an end-of-word check instead:

msggrep -K -e 'or\b' template2.pot

Which makes sure there is a word boundary after 'or', so it won't match 'orand'.

Welbog
Thanks for your answer. It is a 'nasty' solution (msgid like '.or.' would be matched on '\bor\b'), but it is better than nothing :)
Sergio Cinos