source: git/lib/generate-po-todo@ 8377f15

RELEASE/1.2 debug-ci debug-ci-sanitisers faster-cavernlog log-select main stereo stereo-2025 walls-data walls-data-hanging-as-warning warn-only-for-hanging-survey
Last change on this file since 8377f15 was fa56920, checked in by Olly Betts <olly@…>, 12 years ago

lib/Makefile.am,lib/generate-po-todo: Add script and makefile target
to pick out the messages from each po file which need attention.

  • Property mode set to 100755
File size: 1.6 KB
Line 
1#!/usr/bin/perl -w
2require 5.008;
3use bytes;
4use strict;
5use POSIX;
6use Locale::PO;
7
8use integer;
9
10if (@ARGV == 0 || $ARGV[0] eq '--help') {
11 print STDERR "Syntax: $0 PO_FILE...\n";
12 exit (@ARGV != 0);
13}
14
15for my $po_file (@ARGV) {
16 my $todo = $po_file;
17 if (!($todo =~ s/\.po$/.todo/)) {
18 print STDERR "$po_file: doesn't end '.po'\n";
19 next;
20 }
21 my $po = Locale::PO->load_file_asarray($po_file);
22 if (!defined $po) {
23 print STDERR "$po_file: Bad!\n";
24 next;
25 }
26 my $c = 0;
27 open TODO, '>', $todo or die $!;
28 foreach my $po_entry (@{$po}) {
29 my $msgid = $po_entry->msgid;
30 my $msgstr = $po_entry->msgstr;
31 ($msgid eq '""' || $msgstr eq '""' || $po_entry->fuzzy) or next;
32 $msgstr =~ s/\\n(..)/\\n"\n"$1/g;
33 if ($msgid eq '""') {
34 print TODO "msgid $msgid\n";
35 print TODO "msgstr \"\"\n$msgstr\n";
36 next;
37 }
38 if (defined $po_entry->automatic) {
39 my $automatic = "\n" . $po_entry->automatic;
40 $automatic =~ s/\n/\n#. /g;
41 while ($automatic =~ s/\n#. \n/\n#.\n/g) { }
42 print TODO $automatic;
43 }
44 my $ref = $po_entry->reference;
45 if (defined $ref) {
46 $ref = "\n" . $ref;
47 $ref =~ s/\n/\n#: /mg;
48 print TODO $ref;
49 }
50 my $fuzzy = $po_entry->fuzzy;
51 my $c_format = $po_entry->c_format;
52 if ($fuzzy || $c_format) {
53 print TODO "\n#";
54 print TODO ", fuzzy" if $fuzzy;
55 print TODO ", c-format" if $c_format;
56 }
57 print TODO "\n";
58 print TODO "#~ " if $po_entry->obsolete;
59 print TODO "msgid $msgid\n";
60 print TODO "#~ " if $po_entry->obsolete;
61 print TODO "msgstr $msgstr\n";
62 ++$c;
63 }
64 close TODO or die $!;
65 ($c == 0) and unlink $todo;
66}
Note: See TracBrowser for help on using the repository browser.