Changeset c584ed2 in git


Ignore:
Timestamp:
18/09/11 02:59:19 (8 years ago)
Author:
Olly Betts <olly@…>
Branches:
add-show-splays, line_contents, master, stereo, svn/github/master, svn/origin/master, svn/tags/1.2.0, svn/tags/1.2.1, svn/tags/1.2.2, svn/tags/1.2.3, svn/tags/1.2.4, svn/tags/1.2.5, svn/trunk, travis-osx
Children:
cba86532
Parents:
bbb97b1
Message:

configure.in,lib/Makefile.am,lib/po-to-msg.pl: Fix .msg file
generation to work when srcdir != builddir. Drop the "dontextract"
mechanism which automatically generates headers to allows building a
version with translations for the messages for errors in loading the
messages file, as it doesn't seem worth the effort to get it working
again. It's easy to write such a header by hand if you really want
to do this.

git-svn-id: file:///home/survex-svn/survex/trunk@3648 4b37db11-9a0c-4f06-9ece-9ab7cdaee568

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • ChangeLog

    rbbb97b1 rc584ed2  
     1Sun Sep 18 01:56:18 GMT 2011  Olly Betts <olly@survex.com>
     2
     3        * configure.in,lib/Makefile.am,lib/po-to-msg.pl: Fix .msg file
     4          generation to work when srcdir != builddir.  Drop the "dontextract"
     5          mechanism which automatically generates headers to allows building a
     6          version with translations for the messages for errors in loading the
     7          messages file, as it doesn't seem worth the effort to get it working
     8          again.  It's easy to write such a header by hand if you really want
     9          to do this.
     10
    111Fri Sep 16 14:26:43 GMT 2011  Olly Betts <olly@survex.com>
    212
  • configure.in

    rbbb97b1 rc584ed2  
    11dnl Process this file with autoconf to produce a configure script
    2 
    3 dnl CFLAGS=-DDEFAULTLANG=fr to build with French as the default language.
    42
    53dnl Need autoconf 2.50 or later for AC_ARG_VAR.  2.59 has been around for
     
    6260AC_SUBST(PKGDOCDIR)
    6361AC_SUBST(PKGDOCDIR_EXPANDED)
    64 
    65 DEFAULTLANG=en
    66 AC_ARG_ENABLE(defaultlang,
    67 [  --enable-defaultlang=LANG Set the default language for messages to LANG],
    68 [case $enableval in
    69  yes|no) # until we support Norwegian...
    70   AC_MSG_ERROR([configure: Syntax: configure --enable-defaultlang=LANGUAGE]) ;;
    71 esac
    72 DEFAULTLANG="$enableval"
    73 AC_DEFINE_UNQUOTED(DEFAULTLANG, [$enableval], [Default language for messages])
    74 ]
    75 )
    76 AC_SUBST(DEFAULTLANG)
    7762
    7863AC_ARG_ENABLE(testprogs,
  • lib/Makefile.am

    rbbb97b1 rc584ed2  
    1111 es.po fr.po it.po pt.po pt_BR.po sk.po ro.po
    1212
    13 msg_files = ca.msg de.msg de_CH.msg de_DE.msg en.msg en_US.msg\
    14  es.msg fr.msg it.msg pt.msg pt_BR.msg sk.msg ro.msg
    15 
    16 hdr_files = ca.h de.h de_CH.h de_DE.h en.h en_US.h\
    17  es.h fr.h it.h pt.h pt_BR.h sk.h ro.h
     13msg_files = $(po_files:.po=.msg) en.msg
    1814
    1915EXTRA_DIST = survex.pot $(po_files) codes.po\
    2016 named-entities.txt po-to-msg.pl checkshortcut.pl\
    21  $(hdr_files) survex.keys.in\
     17 survex.keys.in\
    2218 English_GB.isl Romanian-7-5.1.11.isl\
    2319 afm2txf.pl\
    2420 INSTALL.OSX
    2521
    26 MAINTAINERCLEANFILES = $(msg_files) $(hdr_files) *.todo aven.txf
     22MAINTAINERCLEANFILES = $(msg_files) *.todo aven.txf
    2723
    2824dist_pkgdata_DATA = print.ini bcra3.svx bcra5.svx $(msg_files) aven.txf
     
    3127dist_apps_DATA = survex-aven.desktop survex-svxedit.desktop
    3228
    33 BUILT_SOURCES = defaultlang.h
    34 
    35 # BUILT_SOURCES are automatically removed by maintainer-clean, but we want it
    36 # removed by distclean
    37 DISTCLEANFILES = defaultlang.h
    38 
    39 $(msg_files) $(hdr_files): survex.pot $(po_files) po-to-msg.pl
    40         srcdir=$(srcdir) LANG=C perl $(srcdir)/po-to-msg.pl $(po_files)
     29$(msg_files): survex.pot $(po_files) po-to-msg.pl
     30        LANG=C perl $(srcdir)/po-to-msg.pl $(po_files)
    4131
    4232survex.pot: codes.po
    4333        perl -pe 's/^msgstr ".*/msgstr ""/' codes.po > survex.pot~
    4434        mv survex.pot~ survex.pot
    45 
    46 defaultlang.h:
    47         -rm -f defaultlang.h
    48         ln -s $(srcdir)/$(DEFAULTLANG).h defaultlang.h
    4935
    5036mimedir = $(datadir)/mime-info
  • lib/po-to-msg.pl

    rbbb97b1 rc584ed2  
    77use integer;
    88
    9 # messages >= this value are written to a header file
    10 my $dontextract_threshold = 1000;
    11 
    129# Magic identifier (12 bytes)
    1310my $magic = "Svx\nMsg\r\n\xfe\xff\0";
     
    1512# being used for parity).  Contains a zero byte so more likely
    1613# to be flagged as data (e.g. by perl's "-B" test).
     14
     15my $srcdir = $0;
     16$srcdir =~ s!/[^/]+$!!;
    1717
    1818my $major = 0;
     
    3131my %msgs = ();
    3232${$msgs{'en'}}[0] = '©';
    33 my %dontextract = ();
    3433
    3534# my %uses = ();
    3635
    37 my $num_list = Locale::PO->load_file_asarray("codes.po");
     36my $num_list = Locale::PO->load_file_asarray("$srcdir/codes.po");
    3837my $curmsg = -1;
    3938foreach my $po_entry (@{$num_list}) {
     
    4544    my $key = $po_entry->msgid;
    4645    my $msg = c_unescape($po_entry->dequote($key));
    47     if ($msgno >= $dontextract_threshold) {
    48         if (${$dontextract{'en'}}[$msgno - $dontextract_threshold]) {
    49             print STDERR "Warning: already had message $msgno for language 'en'\n";
    50         }
    51         ${$dontextract{'en'}}[$msgno - $dontextract_threshold] = $msg;
    52     } else {
    53         if (${$msgs{'en'}}[$msgno]) {
    54             print STDERR "Warning: already had message $msgno for language 'en'\n";
    55         }
    56         ${$msgs{'en'}}[$msgno] = $msg;
    57     }
    58 }
    59 
    60 for my $language (@ARGV) {
     46    if (${$msgs{'en'}}[$msgno]) {
     47        print STDERR "Warning: already had message $msgno for language 'en'\n";
     48    }
     49    ${$msgs{'en'}}[$msgno] = $msg;
     50}
     51
     52for my $po_file (@ARGV) {
     53    my $language = $po_file;
    6154    $language =~ s/\.po$//;
    6255
    63     my $po_hash = Locale::PO->load_file_ashash("$language.po");
     56    my $po_hash = Locale::PO->load_file_ashash("$srcdir/$po_file");
    6457
    6558    foreach my $po_entry (@{$num_list}) {
     
    7164            my $msg = c_unescape($po_entry->dequote($ent->msgstr));
    7265            next if $msg eq '';
    73             if ($msgno >= $dontextract_threshold) {
    74                 if (${$dontextract{$language}}[$msgno - $dontextract_threshold]) {
    75                     print STDERR "Warning: already had message $msgno for language $language\n";
    76                 }
    77                 ${$dontextract{$language}}[$msgno - $dontextract_threshold] = $msg;
    78             } else {
    79                 if (${$msgs{$language}}[$msgno]) {
    80                     print STDERR "Warning: already had message $msgno for language $language\n";
    81                 }
    82                 ${$msgs{$language}}[$msgno] = $msg;
     66            if (${$msgs{$language}}[$msgno]) {
     67                print STDERR "Warning: already had message $msgno for language $language\n";
    8368            }
     69            ${$msgs{$language}}[$msgno] = $msg;
    8470        }
    8571    }
    8672
    8773#       local $_;
    88 #       open FINDUSES, "grep -no '*/$msgno\\>' ../src/*.cc ../src/*.c ../src/*.h|" or die $!;
     74#       open FINDUSES, "grep -no '*/$msgno\\>' \Q$srcdir\E/../src/*.cc \Q$srcdir\E../src/*.c \Q$srcdir\E/../src/*.h|" or die $!;
    8975#       while (<FINDUSES>) {
    9076#          push @{$uses{$msgno}}, $1 if /^([^:]*:\d+):/;
     
    163149}
    164150
    165 my $num_dontextract = -1;
    166 foreach $lang (@langs) {
    167    my $aref = $dontextract{$lang};
    168    if (defined(@$aref)) {
    169        $num_dontextract = scalar @$aref if scalar @$aref > $num_dontextract;
    170    }
    171 }
    172 
    173 if (0) { # disable for now until this is sorted in the po based framework
    174 foreach $lang (@langs) {
    175    my $fnm = $lang;
    176    $fnm =~ s/(_.*)$/\U$1/;
    177    open OUT, ">$fnm.h" or die $!;
    178    print OUT "#define N_DONTEXTRACTMSGS ", $num_dontextract, "\n";
    179    print OUT "static unsigned char dontextractmsgs[] =";
    180 
    181    my $missing = 0;
    182    for my $n (0 .. $num_dontextract - 1) {
    183       print OUT "\n";
    184 
    185       my $aref = $dontextract{$lang};
    186 
    187       my $parentaref;
    188       my $mainlang = $lang;
    189       $parentaref = $dontextract{$mainlang} if $mainlang =~ s/_.*$//;
    190 
    191       my $msg = $$aref[$n];
    192       if (!defined $msg) {
    193          $msg = $$parentaref[$n] if defined $parentaref;
    194          if (!defined $msg) {
    195             $msg = ${$dontextract{'en'}}[$n];
    196             # don't report if we have a parent (as the omission will be reported there)
    197             if (defined $msg && $msg ne '' && !defined $parentaref) {
    198                ++$missing;
    199             } else {
    200                $msg = '';
    201             }
    202          }
    203       } else {
    204          if ($lang ne 'en') {
    205              sanity_check("Message $n in language $lang", $msg, $$aref[$n]);
    206          }
    207       }
    208       $msg =~ s/\\/\\\\/g;
    209       $msg =~ s/"/\\"/g;
    210       $msg =~ s/\t/\\t/g;
    211       $msg =~ s/\n/\\n/g;
    212       $msg =~ s/\r/\\r/g;
    213       if ($msg =~ /^ / || $msg =~ / $/) {
    214          $msg =~ s/\\"/\\\\\\"/g;
    215          $msg = '\\"'.$msg.'\\"';
    216       }
    217       print OUT "   /*", $dontextract_threshold + $n, "*/ \"$msg\\0\"";
    218    }
    219    print OUT ";\n";
    220    close OUT or die $!;
    221 
    222    if ($missing) {
    223        print STDERR "Warning: $lang: $missing missing \"don't extract\" message(s)\n";
    224    }
    225 }
    226 }
    227 
    228151sub sanity_check {
    229152   my ($where, $msg, $orig) = @_;
Note: See TracChangeset for help on using the changeset viewer.