Blame catgets/xopen-msg.awk

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