1#!/usr/bin/perl 2 3my @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).\n", 25 "#. \n", 26 "#. %b <blk> block number\n", 27 "#. %B <blkcount> integer\n", 28 "#. %c <blk2> block number\n", 29 "#. %Di <dirent> -> ino inode number\n", 30 "#. %Dn <dirent> -> name string\n", 31 "#. %Dr <dirent> -> rec_len\n", 32 "#. %Dl <dirent> -> name_len\n", 33 "#. %Dt <dirent> -> filetype\n", 34 "#. %d <dir> inode number\n", 35 "#. %g <group> integer\n", 36 "#. %i <ino> inode number\n", 37 "#. %Is <inode> -> i_size\n", 38 "#. %IS <inode> -> i_extra_isize\n", 39 "#. %Ib <inode> -> i_blocks\n", 40 "#. %Il <inode> -> i_links_count\n", 41 "#. %Im <inode> -> i_mode\n", 42 "#. %IM <inode> -> i_mtime\n", 43 "#. %IF <inode> -> i_faddr\n", 44 "#. %If <inode> -> i_file_acl\n", 45 "#. %Id <inode> -> i_dir_acl\n", 46 "#. %Iu <inode> -> i_uid\n", 47 "#. %Ig <inode> -> i_gid\n", 48 "#. %j <ino2> inode number\n", 49 "#. %m <com_err error message>\n", 50 "#. %N <num>\n", 51 "#. %p ext2fs_get_pathname of directory <ino>\n", 52 "#. %P ext2fs_get_pathname of <dirent>->ino with <ino2> as\n", 53 "#. the containing directory. (If dirent is NULL\n", 54 "#. then return the pathname of directory <ino2>)\n", 55 "#. %q ext2fs_get_pathname of directory <dir>\n", 56 "#. %Q ext2fs_get_pathname of directory <ino> with <dir> as\n", 57 "#. the containing directory.\n", 58 "#. %s <str> miscellaneous string\n", 59 "#. %S backup superblock\n", 60 "#. %X <num> hexadecimal format\n", 61 "#.\n"); 62 63my $is_problem_file = 0; 64my $save_msg; 65my $msg_accum = ""; 66my $msg; 67my $expanded = 0; 68my $lines = 0; 69 70sub do_expand { 71 $msg =~ s/\@a/extended attribute/g; 72 $msg =~ s/\@A/error allocating/g; 73 $msg =~ s/\@b/block/g; 74 $msg =~ s/\@B/bitmap/g; 75 $msg =~ s/\@c/compress/g; 76 $msg =~ s/\@C/conflicts with some other fs block/g; 77 $msg =~ s/\@i/inode/g; 78 $msg =~ s/\@I/illegal/g; 79 $msg =~ s/\@j/journal/g; 80 $msg =~ s/\@D/deleted/g; 81 $msg =~ s/\@d/directory/g; 82 $msg =~ s/\@e/entry/g; 83 $msg =~ s/\@E/entry '%Dn' in %p (%i)/g; 84 $msg =~ s/\@f/filesystem/g; 85 $msg =~ s/\@F/for inode %i (%Q) is/g; 86 $msg =~ s/\@g/group/g; 87 $msg =~ s/\@h/HTREE directory inode/g; 88 $msg =~ s/\@l/lost+found/g; 89 $msg =~ s/\@L/is a link/g; 90 $msg =~ s/\@m/multiply-claimed/g; 91 $msg =~ s/\@n/invalid/g; 92 $msg =~ s/\@o/orphaned/g; 93 $msg =~ s/\@p/problem in/g; 94 $msg =~ s/\@r/root inode/g; 95 $msg =~ s/\@s/should be/g; 96 $msg =~ s/\@S/superblock/g; 97 $msg =~ s/\@u/unattached/g; 98 $msg =~ s/\@v/device/g; 99 $msg =~ s/\@z/zero-length/g; 100 $msg =~ s/\@\@/@/g; 101} 102 103 104while (<>) { 105 $lines++; 106 if ($lines == 6) { 107 print @translator_help; 108 } 109 if (/^#: /) 110 { 111 $is_problem_file = (/^#: e2fsck\/problem/) ? 1 : 0; 112 } 113 $msg = ""; 114 if (/^msgid / && $is_problem_file) { 115 ($msg) = /^msgid "(.*)"$/; 116 $save_msgid = $_; 117 if ($msg =~ /\@/) { 118 $expanded++; 119 } 120 &do_expand(); 121 if ($msg ne "") { 122 $msg_accum = $msg_accum . "#. \@-expanded: $msg\n"; 123 } 124 next; 125 } 126 if (/^"/ && $is_problem_file) { 127 ($msg) = /^"(.*)"$/; 128 $save_msgid = $save_msgid . $_; 129 if ($msg =~ /\@/) { 130 $expanded++; 131 } 132 &do_expand(); 133 $msg_accum = $msg_accum . "#. \@-expanded: $msg\n"; 134 next; 135 } 136 if (/^msgstr / && $is_problem_file) { 137 if ($expanded) { 138 print $msg_accum; 139 } 140 print $save_msgid; 141 $msg_accum = ""; 142 $expanded = 0; 143 } 144 print $_; 145} 146