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