Re: Can one awk script call another?
- From: Tim Morley <t_morley@xxxxxxxxxxxxx>
- Date: Wed, 11 Jul 2007 00:14:31 GMT
Ed,
Thanks for the very quick reply. Sorry for not being clear enough; I'll try again.
I have a couple of hundred gettext .po files, actually from the OpenOffice.org translation effort, which contain lines like this:
msgid ""
"_: used/in/source/file1.c"
"my dog"
msgstr ""
msgid ""
"_: used/in/source/file2.c"
"my dog"
msgstr ""
msgid ""
"_: used/in/source/file3.c"
"my dog"
msgstr ""
Each of these entries contains a line containing `msgid ""', followed by a line containing a path to some source code file, followed by a line containing a word/phrase in English, followed by a line containing `msgstr ""'. There are multiple entries with different file paths, but identical English strings to translate.
What I need to do is to fill in a translation of the English word/phrase so that the file looks like this:
msgid ""
"_: used/in/source/file1.c"
"my dog"
msgstr "mon chien"
msgid ""
"_: used/in/source/file2.c"
"my dog"
msgstr "mon chien"
msgid ""
"_: used/in/source/file3.c"
"my dog"
msgstr "mon chien"
Now, lower down in the same file that contains the above entries, there is also an entry like this:
#~ msgid "my dog"
#~ msgstr "mon chien"
which contains the information I need to complete the earlier entries. (The #~ prefix is gettext file format notation for "an obsolete translation", i.e. one that's no longer used in the current version of the program, but it still contains the information that I want).
Does that make the situation clearer? I hope so.
If you want the actual data I'm working with, have a look here:
http://homepage.ntlworld.com/tim.morley2/OOoEo/
The file dlg.po contains the translation data (search that file for the several appearances of the string "~Host name" to see what I'm talking about).
My two awk scripts are also on the same web page. They can be called like this:
~$ ./find_untranslated_msgstr.awk dlg.po
This (currently) sends to STDOUT just the parts of the input file that are changed by the script; they are changed by adding a token of the form `xxxx1xxxx' (then `xxxx2xxxx', `xxxx3xxxx', etc.) to each entry conforming to the description at the top of this message.
The other script is this:
~$ ./find_existing_translation.awk -v eng="\"~Host name\"" dlg.po
"Nomo de gastiga komputilo"
~$
i.e. when given an English phrase, it searches through the lines that start with #~ in the input file, and returns the translation found there if possible.
I suspect there's an obvious way of doing this that I haven't thought of, but I've spent a couple of days trying to think of it without much success.
Thanks in advance for your suggestions.
Tim
.
- Follow-Ups:
- Re: Can one awk script call another?
- From: Ed Morton
- Re: Can one awk script call another?
- References:
- Can one awk script call another?
- From: Tim Morley
- Re: Can one awk script call another?
- From: Ed Morton
- Can one awk script call another?
- Prev by Date: Re: Can one awk script call another?
- Next by Date: Re: nested field separators
- Previous by thread: Re: Can one awk script call another?
- Next by thread: Re: Can one awk script call another?
- Index(es):
Relevant Pages
|