1 # xopen-msg.awk - Convert Uniforum style .po file to X/Open style .msg file
2 # Copyright (C) 2012-2023 Free Software Foundation, Inc.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2, or (at your option)
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, see <https://www.gnu.org/licenses/>.
18 # The first directive in the .msg should be the definition of the
19 # message set number. We use always set number 1.
22 print "$set 1 # Automatically created by xopen-msg.awk"
27 # The .msg file contains, other then the .po file, only the translations
28 # but each given a unique ID. Starting from 1 and incrementing by 1 for
29 # each message we assign them to the messages.
30 # It is important that the .po file used to generate the ../intl/msg.h file
31 # (with po2test.awk) is the same as the one used here. (At least the order
32 # of declarations must not be changed.)
34 function output_message
() {
35 # Ignore messages containing <PRI.*> which would have to be replaced
36 # by the correct format depending on the word size
37 if (msg
&& msg !~
/<PRI.
*>/) {
38 if (msgtype ==
"msgid") {
39 # We copy the original message as a comment into the .msg file.
40 gsub(/\n/, "\n$ ", msg
)
41 printf "$ Original Message: %s\n", msg
43 gsub(/\n/, "\\\n", msg
)
44 printf "%d %s\n", ++num
, msg
51 # Output collected message
53 # Collect next message
55 sub(/^msg
(id
|str
)[ \t]*"/, "", $0)
61 /^
"POT-Creation-Date: [0-9-]+ [0-9:+-]+\\n"/ {
62 # Ignore POT-Creation-Date to match what is done in intl/Makefile.
67 # Append to current message
75 # Output last collected message