* PO-mode help, please
@ 2005-02-21 13:15 Tim Morley (forstreku la legoman koloron de mia retadreso)
2005-02-22 19:51 ` Kevin Rodgers
0 siblings, 1 reply; 3+ messages in thread
From: Tim Morley (forstreku la legoman koloron de mia retadreso) @ 2005-02-21 13:15 UTC (permalink / raw)
Hi all.
I'm looking for some help in finding a solution to a problem involving
some gettext po-mode files. Any suggestions much appreciated.
Short description: I need to extract from a group of .po files every
record (including all related comments) that contains a certain string
within a comment.
Long description: I have twenty-odd .po files for a certain project.
Spread throughout these files there are various entries which are
tagged, via a comment, as "technical vocabulary" that needs sending to a
specialist for verification. I need to find and extract all of these
cases from the collection of files, to send to the aforementioned
specialists.
Obviously, a standard gettext record looks like this:
msgid "Absolute Record"
msgstr "Absoluta Rikordo"
[Whitespace before `msgid' and `msgstr' added by me for the purposes of
this mail only.]
I need to find each record that includes the comment below:
# FAKVORTO: MATEMATIKA
msgid "Absolute Value"
msgstr "Absoluta Valoro"
It may appear as one of several comments, in which case I need to copy
over all of the comments:
# Aux ALD (laux la franca AJT)? (Gian Piero SAVIO, 2004-04-02)
# 'ALDONI' estas plej klara; 'ALD' iom malpli, do konservu la unuan.
(Tim Morley, 2004-04-03)
# FAKVORTO: MATEMATIKA
msgid "ADD"
msgstr "ALDONI"
And the comments may not appear in any particular order:
# Nur la franca uzas verban terminon, cxiuj aliaj uzas substantivan
terminon. Atentu, "Combine" povus havi aritmetikan signifon, kies
preciza traduko estas "Kombinacio" (mi intertempe kontrolis en PIV1).
(Leo DC, 2004-08-13)
# Vi pravas, ke estas cxiutaga kaj matematika sencoj por tiu vorto.
Mi enmetos ambaux. (Tim Morley, 2004-09-23)
# FAKVORTO: MATEMATIKA
# PLURSENCAJXO
# Kombinajxo
msgid "Combination"
msgstr "Kunigado"
If somebody could suggest either an EMACS keyboard macro, or possibly a
SED or AWK script, that would spit out a text file containing all of the
above records from my collection of files, it would be a great help to me.
Thanks in advance for any help offered.
Regards,
Tim Morley
[remove `rapkolora' to make my email address valid]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: PO-mode help, please
2005-02-21 13:15 PO-mode help, please Tim Morley (forstreku la legoman koloron de mia retadreso)
@ 2005-02-22 19:51 ` Kevin Rodgers
2005-02-22 22:44 ` Tim Morley (forstreku la legoman koloron de mia retadreso)
0 siblings, 1 reply; 3+ messages in thread
From: Kevin Rodgers @ 2005-02-22 19:51 UTC (permalink / raw)
Tim Morley (forstreku la legoman koloron de mia retadreso) wrote:
> I need to find each record that includes the comment below:
> # FAKVORTO: MATEMATIKA
> msgid "Absolute Value"
> msgstr "Absoluta Valoro"
>
> It may appear as one of several comments, in which case I need to copy
> over all of the comments:
> # Aux ALD (laux la franca AJT)? (Gian Piero SAVIO, 2004-04-02)
> # 'ALDONI' estas plej klara; 'ALD' iom malpli, do konservu la unuan.
> (Tim Morley, 2004-04-03)
> # FAKVORTO: MATEMATIKA
> msgid "ADD"
> msgstr "ALDONI"
>
> And the comments may not appear in any particular order:
> # Nur la franca uzas verban terminon, cxiuj aliaj uzas substantivan
> terminon. Atentu, "Combine" povus havi aritmetikan signifon, kies
> preciza traduko estas "Kombinacio" (mi intertempe kontrolis en PIV1).
> (Leo DC, 2004-08-13)
> # Vi pravas, ke estas cxiutaga kaj matematika sencoj por tiu vorto.
> Mi enmetos ambaux. (Tim Morley, 2004-09-23)
> # FAKVORTO: MATEMATIKA
> # PLURSENCAJXO
> # Kombinajxo
> msgid "Combination"
> msgstr "Kunigado"
>
> If somebody could suggest either an EMACS keyboard macro, or possibly a
> SED or AWK script, that would spit out a text file containing all of the
> above records from my collection of files, it would be a great help
to me.
I think awk is the way to go:
awk '/^#/ {comment[c++] = $0}
/^# FAKVORTO: MATEMATIKA/ {verify = 1}
/^msgid/ {msgid = $0}
/^msgstr/ {if (verify == 1) {
for (l=0; l<c; l++)
print comment[l]
print msgid
print
}
c = 0
verify = 0}'
--
Kevin Rodgers
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: PO-mode help, please
2005-02-22 19:51 ` Kevin Rodgers
@ 2005-02-22 22:44 ` Tim Morley (forstreku la legoman koloron de mia retadreso)
0 siblings, 0 replies; 3+ messages in thread
From: Tim Morley (forstreku la legoman koloron de mia retadreso) @ 2005-02-22 22:44 UTC (permalink / raw)
Kevin Rodgers wrote:
> Tim Morley wrote:
> > I need to find each record that includes the comment below:
> > ...
> > If somebody could suggest either an EMACS keyboard macro, or possibly a
> > SED or AWK script, that would spit out a text file containing all of the
> > above records from my collection of files, it would be a great help
> to me.
>
> I think awk is the way to go:
>
> awk '/^#/ {comment[c++] = $0}
> /^# FAKVORTO: MATEMATIKA/ {verify = 1}
> /^msgid/ {msgid = $0}
> /^msgstr/ {if (verify == 1) {
> for (l=0; l<c; l++)
> print comment[l]
> print msgid
> print
> }
> c = 0
> verify = 0}'
>
Sterling work, sir! Thanks aplenty for that. All strings now extracted
and winging their way to our experts. :o)
Somebody buy that man a beer.
Tim
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2005-02-22 22:44 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-02-21 13:15 PO-mode help, please Tim Morley (forstreku la legoman koloron de mia retadreso)
2005-02-22 19:51 ` Kevin Rodgers
2005-02-22 22:44 ` Tim Morley (forstreku la legoman koloron de mia retadreso)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).