lletters-media (0.1.9a-4) lang/translate-lln-dev.pl

Summary

 lang/translate-lln-dev.pl |  106 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 106 insertions(+)

    
download this patch

Patch contents

--- lletters-media-0.1.9a.orig/lang/translate-lln-dev.pl
+++ lletters-media-0.1.9a/lang/translate-lln-dev.pl
@@ -0,0 +1,106 @@
+#!/usr/bin/perl
+
+# A simple script to translate the images of Linux Letters and Numbers
+# <http://lln.sourceforge.net/> to a local language, in order to let
+# the young users learn their language.
+
+# The syntax of the table is quite simple: 
+#       english-name local-name 
+# for instance, for French: 
+#       Wolf  Loup
+
+# Copyright Stephane Bortzmeyer <bortzmeyer@sources.org>. Licence is
+# the licence of LLN itself.
+
+# Known bugs:
+# 1) after translation, some letters may be missing,
+# 2) Multiple names (Tiger.1 and Tiger.2) are not elegantly supported
+# Added by Rudy Godoy
+# 3) Accentuated or special characters in names may not be processed correctly
+# as it only creates symlinks (filesystem files)
+
+# Feel free to modify these
+#
+# This script was modified to fit package development purposes
+# DO NOT use it for userland purposes, instead use the one
+# which is under /usr/share/doc/lletters/translate-lln.pl
+# or in the binary package lletters. - Rudy Godoy.
+# 
+# Where are the actual image files
+$bdir = "../debian/lletters-media/usr/share/games/lletters/";
+$imgd = "images";
+
+# let's check arguments or environment variable
+if (! @ARGV) {
+  $locale = substr($ENV{'LANG'}, 0, 2);
+  make_table ($locale);
+} else {
+  $numArgs = $#ARGV +1;
+  foreach $argnum (0 .. $#ARGV) {
+    print "$ARGV[$argnum]\n";
+    $locale = substr($ARGV[$argnum], -2);
+    print "locale is: $locale\n";
+    make_table ($locale);
+  }
+}
+
+# creates the table(s) inside 
+# debian/lletters-media/usr/share/games/lleters/<ll> 
+
+sub make_table {
+  $locale = $_[0];
+  $table = "table-" . $locale;
+  print "table is: $table\n";
+  $localed = $locale . '/' . $imgd;
+  if (! -e $table) {
+	die "No such table found ($table) $!";
+  }
+# first make the LANG directory
+  $local_dir = $bdir . $locale;
+  if (! -d $local_dir) {
+     mkdir $local_dir, 0755 or die "Cannot create $local_dir: $!";
+  } else {
+     print "Directory $local_dir already exists, please remove it before run this script\n";
+     return;
+  }
+
+# second make the images directory
+  $local_dir .= "/images";
+  if (! -d $local_dir) {
+      mkdir $local_dir, 0755 or die "Cannot create $local_dir: $!";
+  }
+
+# Do not edit below this point
+  open (TABLE, "< $table") or die "Cannot open $table: $!";
+  while (<TABLE>) {
+    chomp;
+    $line = $_;
+    # Skip comments
+    $line =~ s/#.*$//;
+    if ($line =~ /^ *$/) {
+	next; # Skip empty lines	
+    }
+    ($english, $local) = split ('[ \t]', $line);
+    $table{$english} = $local;
+  }
+  close (TABLE);
+
+  opendir (DIR, "$bdir$imgd") or die "Cannot open $bdir$imgd: $!";
+  while ($file = readdir (DIR)) {
+      $files{$file} = 1;
+  }
+  closedir (DIR);
+  chdir($local_dir);
+  foreach $file (keys (%files)) {
+      $basename = $file;
+      $basename =~ s/\.([a-zA-Z]+)$//;
+      $type = $1;
+      if ($table{$basename}) {
+  	symlink (( '../../' . $imgd . '/' . $file), 
+		 ( $table{$basename} . ".$type")) or 
+	    die "Cannot symlink $table{$basename}.$type to $file: $!";
+#	print $table{$basename} . ".$type", " -> ", $file, "\n";
+      }
+  }
+  chdir('../../../../../../../../lang');
+}