#!/usr/bin/perl my @translator_help = ( "#. The strings in e2fsck's problem.c can be very hard to translate,\n", "#. since the strings are expanded in two different ways. First of all,\n", "#. there is an \@-expansion, where strings like \"\@i\" are expanded to\n", "#. \"inode\", and so on. In order to make it easier for translators, the\n", "#. e2fsprogs po template file has been enhanced with comments that show\n", "#. the \@-expansion, for the strings in the problem.c file.\n", "#.\n", "#. Translators are free to use the \@-expansion facility if they so\n", "#. choose, by providing translations for strings in e2fsck/message.c.\n", "#. These translation can completely replace an expansion; for example,\n", "#. if \"bblock\" (which indicated that \"\@b\" would be expanded to \"block\")\n", "#. is translated as \"ddatenverlust\", then \"\@d\" will be expanded to\n", "#. \"datenverlust\". Alternatively, translators can simply not use the\n", "#. \@-expansion facility at all.\n", "#.\n", "#. The second expansion which is done for e2fsck's problem.c messages is\n", "#. a dynamic %-expansion, which expands %i as an inode number, and so\n", "#. on. A table of these expansions can be found below. Note that\n", "#. %-expressions that begin with \"%D\" and \"%I\" are two-character\n", "#. expansions; so for example, \"%Iu\" expands to the inode's user id\n", "#. ownership field (inode->i_uid). Also the \"%B\" expansion is special:\n", "#. it can expand to either the string \"indirect block\" (possibly preceded\n", "#. by the word \"double\" or \"triple\"), or the string \"block #\" immediately\n", "#. followed by an integer indicating a block sequence number.\n", "#. \n", "#. %b block number\n", "#. %B \"indirect block\" | \"block #\" string | string+integer\n", "#. %c block number\n", "#. %Di -> ino inode number\n", "#. %Dn -> name string\n", "#. %Dr -> rec_len\n", "#. %Dl -> name_len\n", "#. %Dt -> filetype\n", "#. %d inode number\n", "#. %g integer\n", "#. %i inode number\n", "#. %Is -> i_size\n", "#. %IS -> i_extra_isize\n", "#. %Ib -> i_blocks\n", "#. %Il -> i_links_count\n", "#. %Im -> i_mode\n", "#. %IM -> i_mtime\n", "#. %IF -> i_faddr\n", "#. %If -> i_file_acl\n", "#. %Id -> i_size_high\n", "#. %Iu -> i_uid\n", "#. %Ig -> i_gid\n", "#. %It file type\n", "#. %j inode number\n", "#. %m \n", "#. %N \n", "#. %p ext2fs_get_pathname of directory \n", "#. %P ext2fs_get_pathname of ->ino with as\n", "#. the containing directory. (If dirent is NULL\n", "#. then return the pathname of directory )\n", "#. %q ext2fs_get_pathname of directory \n", "#. %Q ext2fs_get_pathname of directory with as\n", "#. the containing directory.\n", "#. %s miscellaneous string\n", "#. %S backup superblock\n", "#. %X hexadecimal format\n", "#.\n"); my $is_problem_file = 0; my $save_msg; my $msg_accum = ""; my $msg; my $expanded = 0; my $lines = 0; sub do_expand { $msg =~ s/\@a/extended attribute/g; $msg =~ s/\@A/error allocating/g; $msg =~ s/\@b/block/g; $msg =~ s/\@B/bitmap/g; $msg =~ s/\@c/compress/g; $msg =~ s/\@C/conflicts with some other fs block/g; $msg =~ s/\@i/inode/g; $msg =~ s/\@I/illegal/g; $msg =~ s/\@j/journal/g; $msg =~ s/\@D/deleted/g; $msg =~ s/\@d/directory/g; $msg =~ s/\@e/entry/g; $msg =~ s/\@E/entry '%Dn' in %p (%i)/g; $msg =~ s/\@f/filesystem/g; $msg =~ s/\@F/for inode %i (%Q) is/g; $msg =~ s/\@g/group/g; $msg =~ s/\@h/HTREE directory inode/g; $msg =~ s/\@l/lost+found/g; $msg =~ s/\@L/is a link/g; $msg =~ s/\@m/multiply-claimed/g; $msg =~ s/\@n/invalid/g; $msg =~ s/\@o/orphaned/g; $msg =~ s/\@p/problem in/g; $msg =~ s/\@q/quota/g; $msg =~ s/\@r/root inode/g; $msg =~ s/\@s/should be/g; $msg =~ s/\@S/superblock/g; $msg =~ s/\@u/unattached/g; $msg =~ s/\@v/device/g; $msg =~ s/\@x/extent/g; $msg =~ s/\@z/zero-length/g; $msg =~ s/\@\@/@/g; } while (<>) { $lines++; if ($lines == 6) { print @translator_help; } if (/^#: /) { $is_problem_file = (/^#: e2fsck\/problem/) ? 1 : 0; } $msg = ""; if (/^msgid / && $is_problem_file) { ($msg) = /^msgid "(.*)"$/; $save_msgid = $_; if ($msg =~ /\@/) { $expanded++; } &do_expand(); if ($msg ne "") { $msg_accum = $msg_accum . "#. \@-expanded: $msg\n"; } next; } if (/^"/ && $is_problem_file) { ($msg) = /^"(.*)"$/; $save_msgid = $save_msgid . $_; if ($msg =~ /\@/) { $expanded++; } &do_expand(); $msg_accum = $msg_accum . "#. \@-expanded: $msg\n"; next; } if (/^msgstr / && $is_problem_file) { if ($expanded) { print $msg_accum; } print $save_msgid; $msg_accum = ""; $expanded = 0; } print $_; }