Fix tst-gettext test
[glibc.git] / catgets / xopen-msg.sed
blobd96a6d735831d725db40c25bafcf689a51c16948
1 # po2msg.sed - Convert Uniforum style .po file to X/Open style .msg file
2 # Copyright (C) 1995 Free Software Foundation, Inc.
3 # Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2, or (at your option)
8 # any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, see <http://www.gnu.org/licenses/>.
19 # The first directive in the .msg should be the definition of the
20 # message set number.  We use always set number 1.
22 1 {
23   i\
24 $set 1 # Automatically created by po2msg.sed
25   h
26   s/.*/0/
27   x
30 # We copy all comments into the .msg file.  Perhaps they can help.
32 /^#/ s/^#[      ]*/$ /p
34 # We copy the original message as a comment into the .msg file.
36 /^msgid/ {
37 # Does not work now
38 #  /"$/! {
39 #    s/\\$//
40 #    s/$/ ... (more lines following)"/
41 #  }
42   s/^msgid[     ]*"\(.*\)"$/$ Original Message: \1/
43   p
46 # The .msg file contains, other then the .po file, only the translations
47 # but each given a unique ID.  Starting from 1 and incrementing by 1 for
48 # each message we assign them to the messages.
49 # It is important that the .po file used to generate the cat-id-tbl.c file
50 # (with po-to-tbl) is the same as the one used here.  (At least the order
51 # of declarations must not be changed.)
53 /^msgstr/ {
54   s/msgstr[     ]*"\(.*\)"/\1/
55   x
56 # The following nice solution is by
57 # Bruno <Haible@ma2s2.mathematik.uni-karlsruhe.de>
58   td
59 # Increment a decimal number in pattern space.
60 # First hide trailing `9' digits.
61   :d
62   s/9\(_*\)$/_\1/
63   td
64 # Assure at least one digit is available.
65   s/^\(_*\)$/0\1/
66 # Increment the last digit.
67   s/8\(_*\)$/9\1/
68   s/7\(_*\)$/8\1/
69   s/6\(_*\)$/7\1/
70   s/5\(_*\)$/6\1/
71   s/4\(_*\)$/5\1/
72   s/3\(_*\)$/4\1/
73   s/2\(_*\)$/3\1/
74   s/1\(_*\)$/2\1/
75   s/0\(_*\)$/1\1/
76 # Convert the hidden `9' digits to `0's.
77   s/_/0/g
78   x
79 # Bring the line in the format `<number> <message>'
80   G
81   s/^[^\n]*$/& /
82   s/\(.*\)\n\([0-9]*\)/\2 \1/
83 # Clear flag from last substitution.
84   tb
85 # Append the next line.
86   :b
87   N
88 # Look whether second part is a continuation line.
89   s/\(.*\n\)"\(.*\)"/\1\2/
90 # Yes, then branch.
91   ta
92   P
93   D
94 # Note that `D' includes a jump to the start!!
95 # We found a continuation line.  But before printing insert '\'.
96   :a
97   s/\(.*\)\(\n.*\)/\1\\\2/
98   P
99 # We cannot use the sed command `D' here
100   s/.*\n\(.*\)/\1/
101   tb