source: osm/applications/editors/josm/plugins/photoadjust/i18n/diff_lang.pl

Last change on this file was 31960, checked in by holgermappt, 9 years ago

Added scripts that read the JOSM *.lang language files.

  • Property svn:executable set to *
File size: 1.8 KB
Line 
1#! /usr/bin/perl -w
2###
3### diff_lang.pl - Show differences of a JOSM language file.
4###
5### Syntax examples:
6### diff_lang.pl -u -L "data/en.lang (revision 12345)"
7### -L "data/en.lang (working copy)"
8### .svn/pristine/42/423b7dfb6a014d6c0d3ec3ce96a10e2df665266a.svn-base
9### data/en.lang
10### diff_lang.pl --tkdiff -L "data/en.lang (revision 12345)"
11### -L "data/en.lang (working copy)"
12### .svn/pristine/42/423b7dfb6a014d6c0d3ec3ce96a10e2df665266a.svn-base
13### data/en.lang
14
15use strict;
16use utf8;
17use File::Basename;
18use File::Temp qw/ tempfile /;
19push(@INC, dirname($0));
20require i18nlib;
21
22my @diffArgs;
23my @files;
24my $tkdiff = 0;
25#print "Arguments: ", join(" ", @ARGV), "\n";
26for (my $idx = 0; $idx <= $#ARGV; $idx++) {
27 my $arg = $ARGV[$idx];
28 if ($arg eq "-u") {
29 push(@diffArgs, $arg);
30 }
31 elsif ($arg eq "-L") {
32 push(@diffArgs, $arg, $ARGV[++$idx]);
33 }
34 elsif ($arg eq "--tkdiff") {
35 $tkdiff = 1;
36 }
37 elsif ($arg =~ m/^-/) {
38 #die "Unknown option '$arg'.\n";
39 ### Assume that diff knows this option and that it has no argument.
40 push(@diffArgs, $arg);
41 }
42 else {
43 push(@files, $arg);
44 }
45 #print "$idx: $ARGV[$idx]\n";
46}
47
48if ($#files != 1) {
49 print "Files:\n", join("\n", @files), "\n";
50 die sprintf("Expected two file arguments, got %d arguments.\n", $#files + 1);
51}
52
53my $separator = "\n\n";
54my @strings = loadLangFile($files[0]);
55my ($fh1, $tmpfile1) = tempfile();
56#binmode($fh1, ":utf8");
57print $fh1 join($separator, @strings), "\n";
58close($fh1);
59@strings = loadLangFile($files[1]);
60my ($fh2, $tmpfile2) = tempfile();
61#binmode($fh2, ":utf8");
62print $fh2 join($separator, @strings), "\n";
63close($fh2);
64
65push(@diffArgs, $tmpfile1, $tmpfile2);
66my @diffCmd;
67if ($tkdiff) {
68 push(@diffCmd, "tkdiff");
69}
70else {
71 push(@diffCmd, "diff");
72}
73push(@diffCmd, @diffArgs);
74#print "Command: ", join(" ", @diffCmd), "\n";
75system(@diffCmd);
Note: See TracBrowser for help on using the repository browser.