Ignore:
Timestamp:
2016-01-07T19:25:04+01:00 (9 years ago)
Author:
holgermappt
Message:

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

Location:
applications/editors/josm/plugins/photoadjust/i18n
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/photoadjust/i18n/README

    r30180 r31960  
    5050* It is not possible to add the translations of the plugin description
    5151  to the manifest.
     52
     53See Language String Changes
     54---------------------------
     55To see what language strings changed in data/*.lang run this:
     56svn diff --diff-cmd i18n/diff_lang.pl --force data
     57
     58To see just removed or modified strings:
     59svn diff --diff-cmd i18n/diff_lang.pl --force data | grep ^- | grep -v '^--- data/'
     60
     61To display changes of a single file with tkdiff:
     62svn diff --diff-cmd i18n/diff_lang.pl --extensions --tkdiff --force data/<lang>.lang
  • applications/editors/josm/plugins/photoadjust/i18n/i18nlib.pm

    r30180 r31960  
    182182}
    183183
     184### Load a JOSM language file.  The format is two byte string length, then the
     185### string.  Length 0x0000 means the string was not in the PO file, i.e. there
     186### is no translation (there are no empty strings).  Length 0xfffe (65534)
     187### means the string is the same as the original string.  Length 0xffff ends
     188### the string list.
     189###
     190### Args:
     191###     filename (str): Path to language file.
     192###
     193### Returns:
     194###     array: List of decoded strings.
     195sub loadLangFile {
     196  my ($filename) = @_;
     197  my @strings;
     198  open(my $langFd, $filename) or die "Cannot open file $filename: $!";
     199  binmode($langFd);
     200  my $buffer;
     201  my $length;
     202  while (1) {
     203    read($langFd, $buffer, 2);
     204    $length = unpack("n", $buffer);
     205    die "Unable to read string length" unless ($buffer);
     206    if ($length == 0) {
     207      push(@strings, "");
     208    }
     209    elsif ($length == 0xfffe) {
     210      push(@strings, "(see original string)");
     211    }
     212    elsif ($length == 0xffff) {
     213      last;
     214    }
     215    else {
     216      read($langFd, $buffer, $length);
     217      push(@strings, $buffer);
     218    }
     219  }
     220  close($langFd);
     221  return @strings;
     222}
     223
    1842241;
Note: See TracChangeset for help on using the changeset viewer.