You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

31 lines
852 B

  1. #! /usr/bin/perl -w
  2. use strict;
  3. my $iso3166tab = 'debian/iso_3166.tab';
  4. # Get mapping of country names to country codes
  5. my %iso3166rev;
  6. open(ISO3166TAB, "< $iso3166tab") || die "Unable to read $iso3166tab";
  7. while (<ISO3166TAB>) {
  8. /^([A-Z]+)\t(.*)$/ or next;
  9. $iso3166rev{$2} = $1;
  10. }
  11. close ISO3166TAB;
  12. # Stringtable output is easier to handle.
  13. open SOURCESTRINGS, '-|:utf8', 'msgcat', '--stringtable-output', '-'
  14. or die "open msgcat for source: $!";
  15. open TARGETSTRINGS, '|-:utf8', 'msgcat', '--stringtable-input', '-s', '-'
  16. or die "open msgcat for target: $!";
  17. while (<SOURCESTRINGS>) {
  18. if (/^"(.+?)" = "(.*?)";$/) {
  19. if (exists $iso3166rev{$1}) {
  20. print TARGETSTRINGS qq{"$iso3166rev{$1}" = "$2";\n};
  21. }
  22. } else {
  23. print TARGETSTRINGS;
  24. }
  25. }
  26. close SOURCESTRINGS;
  27. close TARGETSTRINGS or die "close msgcat for target: $!";