Whamcloud - gitweb
po: add help text to e2fsprogs.pot explaining ix-nay on positional indicators
[tools/e2fsprogs.git] / po / at-expand.pl
1 #!/usr/bin/perl
2
3 my @translator_help = (
4  "#. The strings in e2fsck's problem.c can be very hard to translate,\n",
5  "#. since the strings are expanded in two different ways.  First of all,\n",
6  "#. there is an \@-expansion, where strings like \"\@i\" are expanded to\n",
7  "#. \"inode\", and so on.  In order to make it easier for translators, the\n",
8  "#. e2fsprogs po template file has been enhanced with comments that show\n",
9  "#. the \@-expansion, for the strings in the problem.c file.\n",
10  "#.\n",
11  "#. Translators are free to use the \@-expansion facility if they so\n",
12  "#. choose, by providing translations for strings in e2fsck/message.c.\n",
13  "#. These translation can completely replace an expansion; for example,\n",
14  "#. if \"bblock\" (which indicated that \"\@b\" would be expanded to \"block\")\n",
15  "#. is translated as \"ddatenverlust\", then \"\@d\" will be expanded to\n",
16  "#. \"datenverlust\".  Alternatively, translators can simply not use the\n",
17  "#. \@-expansion facility at all.\n",
18  "#.\n",
19  "#. The second expansion which is done for e2fsck's problem.c messages is\n",
20  "#. a dynamic %-expansion, which expands %i as an inode number, and so\n",
21  "#. on.  A table of these expansions can be found below.  Note that\n",
22  "#. %-expressions that begin with \"%D\" and \"%I\" are two-character\n",
23  "#. expansions; so for example, \"%Iu\" expands to the inode's user id\n",
24  "#. ownership field (inode->i_uid).  Also the \"%B\" expansion is special:\n",
25  "#. it can expand to either the string \"indirect block\" (possibly preceded\n",
26  "#. by the word \"double\" or \"triple\"), or the string \"block #\" immediately\n",
27  "#. followed by an integer indicating a block sequence number.\n",
28  "#.\n",
29  "#. Please note that the %-expansion for most e2fsck's problem.c should not\n",
30  "#. use positional indicators such as %1$c, since although they look like c-style\n",
31  "#. format strings, they are NOT c-style format strings, and the positional\n",
32  "#. indicators (which BTW are GNU extensions and so won't work on other Unix\n",
33  "#. gettext implementations) won't work with e2fsck's print_e2fsck_message()\n",
34  "#. function found in e2fsck/message.c\n",
35  "#.\n",
36  "#.    %b      <blk>                   block number\n",
37  "#.    %B      \"indirect block\" | \"block #\"<blkcount>      string | string+integer\n",
38  "#.    %c      <blk2>                  block number\n",
39  "#.    %Di     <dirent> -> ino         inode number\n",
40  "#.    %Dn     <dirent> -> name        string\n",
41  "#.    %Dr     <dirent> -> rec_len\n",
42  "#.    %Dl     <dirent> -> name_len\n",
43  "#.    %Dt     <dirent> -> filetype\n",
44  "#.    %d      <dir>                   inode number\n",
45  "#.    %g      <group>                 integer\n",
46  "#.    %i      <ino>                   inode number\n",
47  "#.    %Is     <inode> -> i_size\n",
48  "#.    %IS     <inode> -> i_extra_isize\n",
49  "#.    %Ib     <inode> -> i_blocks\n",
50  "#.    %Il     <inode> -> i_links_count\n",
51  "#.    %Im     <inode> -> i_mode\n",
52  "#.    %IM     <inode> -> i_mtime\n",
53  "#.    %IF     <inode> -> i_faddr\n",
54  "#.    %If     <inode> -> i_file_acl\n",
55  "#.    %Id     <inode> -> i_size_high\n",
56  "#.    %Iu     <inode> -> i_uid\n",
57  "#.    %Ig     <inode> -> i_gid\n",
58  "#.    %It     <str>                   file type\n",
59  "#.    %j      <ino2>                  inode number\n",
60  "#.    %m      <com_err error message>\n",
61  "#.    %N      <num>\n",
62  "#.    %p              ext2fs_get_pathname of directory <ino>\n",
63  "#.    %P              ext2fs_get_pathname of <dirent>->ino with <ino2> as\n",
64  "#.                            the containing directory.  (If dirent is NULL\n",
65  "#.                            then return the pathname of directory <ino2>)\n",
66  "#.    %q              ext2fs_get_pathname of directory <dir>\n",
67  "#.    %Q              ext2fs_get_pathname of directory <ino> with <dir> as\n",
68  "#.                            the containing directory.\n",
69  "#.    %s      <str>                   miscellaneous string\n",
70  "#.    %S              backup superblock\n",
71  "#.    %X      <num>   hexadecimal format\n",
72  "#.\n");
73
74 my $is_problem_file = 0;
75 my $save_msg;
76 my $msg_accum = "";
77 my $msg;
78 my $expanded = 0;
79 my $lines = 0;
80
81 sub do_expand {
82     $msg =~ s/\@a/extended attribute/g;
83     $msg =~ s/\@A/error allocating/g;
84     $msg =~ s/\@b/block/g;
85     $msg =~ s/\@B/bitmap/g;
86     $msg =~ s/\@c/compress/g;
87     $msg =~ s/\@C/conflicts with some other fs block/g;
88     $msg =~ s/\@i/inode/g;
89     $msg =~ s/\@I/illegal/g;
90     $msg =~ s/\@j/journal/g;
91     $msg =~ s/\@D/deleted/g;
92     $msg =~ s/\@d/directory/g;
93     $msg =~ s/\@e/entry/g;
94     $msg =~ s/\@E/entry '%Dn' in %p (%i)/g;
95     $msg =~ s/\@f/filesystem/g;
96     $msg =~ s/\@F/for inode %i (%Q) is/g;
97     $msg =~ s/\@g/group/g;
98     $msg =~ s/\@h/HTREE directory inode/g;
99     $msg =~ s/\@l/lost+found/g;
100     $msg =~ s/\@L/is a link/g;
101     $msg =~ s/\@m/multiply-claimed/g;
102     $msg =~ s/\@n/invalid/g;
103     $msg =~ s/\@o/orphaned/g;
104     $msg =~ s/\@p/problem in/g;
105     $msg =~ s/\@q/quota/g;
106     $msg =~ s/\@r/root inode/g;
107     $msg =~ s/\@s/should be/g;
108     $msg =~ s/\@S/superblock/g;
109     $msg =~ s/\@u/unattached/g;
110     $msg =~ s/\@v/device/g;
111     $msg =~ s/\@x/extent/g;
112     $msg =~ s/\@z/zero-length/g;
113     $msg =~ s/\@\@/@/g;
114 }
115
116
117 while (<>) {
118     $lines++;
119     if ($lines == 6) {
120         print @translator_help;
121     }
122     if (/^#: /)
123     {
124         $is_problem_file = (/^#: e2fsck\/problem/) ? 1 : 0;
125     }
126     $msg = "";
127     if (/^msgid / && $is_problem_file) {
128         ($msg) = /^msgid "(.*)"$/;
129         $save_msgid = $_;
130         if ($msg =~ /\@/) {
131             $expanded++;
132         }
133         &do_expand();
134         if ($msg ne "") {
135             $msg_accum = $msg_accum . "#. \@-expanded: $msg\n";
136         }
137         next;
138     }
139     if (/^"/ && $is_problem_file) {
140         ($msg) = /^"(.*)"$/;
141         $save_msgid = $save_msgid . $_;
142         if ($msg =~ /\@/) {
143             $expanded++;
144         }
145         &do_expand();
146         $msg_accum = $msg_accum . "#. \@-expanded: $msg\n";
147         next;
148     }
149     if (/^msgstr / && $is_problem_file) {
150         if ($expanded) {
151             print $msg_accum;
152         }
153         print $save_msgid;
154         $msg_accum = "";
155         $expanded = 0;
156     }
157     print $_;
158 }