Theodore Ts'o | c0b7e79 | 2005-05-09 20:39:02 -0400 | [diff] [blame] | 1 | #!/usr/bin/perl |
| 2 | |
Theodore Ts'o | 7ae1983 | 2005-06-19 09:45:36 -0400 | [diff] [blame] | 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).\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 | |
Theodore Ts'o | c0b7e79 | 2005-05-09 20:39:02 -0400 | [diff] [blame] | 63 | my $is_problem_file = 0; |
| 64 | my $save_msg; |
| 65 | my $msg_accum = ""; |
| 66 | my $msg; |
| 67 | my $expanded = 0; |
Theodore Ts'o | 7ae1983 | 2005-06-19 09:45:36 -0400 | [diff] [blame] | 68 | my $lines = 0; |
Theodore Ts'o | c0b7e79 | 2005-05-09 20:39:02 -0400 | [diff] [blame] | 69 | |
| 70 | sub 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; |
Theodore Ts'o | 7ae1983 | 2005-06-19 09:45:36 -0400 | [diff] [blame] | 90 | $msg =~ s/\@m/multiply-claimed/g; |
| 91 | $msg =~ s/\@n/invalid/g; |
Theodore Ts'o | c0b7e79 | 2005-05-09 20:39:02 -0400 | [diff] [blame] | 92 | $msg =~ s/\@o/orphaned/g; |
| 93 | $msg =~ s/\@p/problem in/g; |
JP Abgrall | e0ed740 | 2014-03-19 19:08:39 -0700 | [diff] [blame] | 94 | $msg =~ s/\@q/quota/g; |
Theodore Ts'o | c0b7e79 | 2005-05-09 20:39:02 -0400 | [diff] [blame] | 95 | $msg =~ s/\@r/root inode/g; |
| 96 | $msg =~ s/\@s/should be/g; |
| 97 | $msg =~ s/\@S/superblock/g; |
| 98 | $msg =~ s/\@u/unattached/g; |
| 99 | $msg =~ s/\@v/device/g; |
Theodore Ts'o | 75b5672 | 2008-08-27 19:00:50 -0400 | [diff] [blame] | 100 | $msg =~ s/\@x/extent/g; |
Theodore Ts'o | c0b7e79 | 2005-05-09 20:39:02 -0400 | [diff] [blame] | 101 | $msg =~ s/\@z/zero-length/g; |
| 102 | $msg =~ s/\@\@/@/g; |
| 103 | } |
| 104 | |
| 105 | |
| 106 | while (<>) { |
Theodore Ts'o | 7ae1983 | 2005-06-19 09:45:36 -0400 | [diff] [blame] | 107 | $lines++; |
| 108 | if ($lines == 6) { |
| 109 | print @translator_help; |
| 110 | } |
Theodore Ts'o | c0b7e79 | 2005-05-09 20:39:02 -0400 | [diff] [blame] | 111 | if (/^#: /) |
| 112 | { |
| 113 | $is_problem_file = (/^#: e2fsck\/problem/) ? 1 : 0; |
| 114 | } |
| 115 | $msg = ""; |
| 116 | if (/^msgid / && $is_problem_file) { |
| 117 | ($msg) = /^msgid "(.*)"$/; |
| 118 | $save_msgid = $_; |
| 119 | if ($msg =~ /\@/) { |
| 120 | $expanded++; |
| 121 | } |
| 122 | &do_expand(); |
| 123 | if ($msg ne "") { |
Theodore Ts'o | 7ae1983 | 2005-06-19 09:45:36 -0400 | [diff] [blame] | 124 | $msg_accum = $msg_accum . "#. \@-expanded: $msg\n"; |
Theodore Ts'o | c0b7e79 | 2005-05-09 20:39:02 -0400 | [diff] [blame] | 125 | } |
| 126 | next; |
| 127 | } |
| 128 | if (/^"/ && $is_problem_file) { |
| 129 | ($msg) = /^"(.*)"$/; |
| 130 | $save_msgid = $save_msgid . $_; |
| 131 | if ($msg =~ /\@/) { |
| 132 | $expanded++; |
| 133 | } |
| 134 | &do_expand(); |
Theodore Ts'o | 7ae1983 | 2005-06-19 09:45:36 -0400 | [diff] [blame] | 135 | $msg_accum = $msg_accum . "#. \@-expanded: $msg\n"; |
Theodore Ts'o | c0b7e79 | 2005-05-09 20:39:02 -0400 | [diff] [blame] | 136 | next; |
| 137 | } |
| 138 | if (/^msgstr / && $is_problem_file) { |
| 139 | if ($expanded) { |
| 140 | print $msg_accum; |
| 141 | } |
| 142 | print $save_msgid; |
| 143 | $msg_accum = ""; |
| 144 | $expanded = 0; |
| 145 | } |
| 146 | print $_; |
| 147 | } |