#!/usr/bin/perl ## ## *********************************************************** ## ## This script is usefull (not for all perhaps) to start ## translating AbiWord (www.abisource.com) interface. ## ## The script generates the zero translated strings file. ## All strings are commented and include English version of strings. ## So, a translator can easily replace string and then uncomment it. ## ## Running the script put in command line: ## 1. SHORTCUT_FOR_A_NEW_LANGUAGE (for example: xx-XX) ## 2. ENCODING (for example: UTF-8) ## 3. YES or NO for preserving English shortcuts (sugested: NO) ## ## *********************************************************** ## ## time and date ## my($RetTime, $StartTimeArg, $sec, $minute, $hour, $mday, $mon, $year); ($sec,$minute,$hour,$mday,$mon,$year) = localtime(); if ($mday < 10) {$day = "0" . "$mday";} else {$day = "$mday";} $mon++; # month is 0 based. if ($mon < 10) {$month = "0" . "$mon";} else {$month = "$mon";} $year = $year + 1900; $datetime = "$day-" . "$month-" . "$year " . "$hour:" . "$minute"; print STDERR "\nStarted at "; printf STDERR ("%02d-%02d-%02d %02d:%02d", $mday,$mon,$year,$hour,$minute); print STDERR "\n"; ## ## input and output ## if ($#ARGV == 2) { ($newlang, $encoding, $shortcuts) = @ARGV; $strings_file = ".\/@ARGV[0].strings"; $shortcuts =~ tr/A-Z/a-z/; if ($shortcuts eq "yes" ) { $shortcuts = "YES"; } else { $shortcuts = "NO"; } print STDERR "\nINPUT\n"; print STDERR " files: @srcfiles\n"; print STDERR " language: $newlang\n"; print STDERR " encoding: $encoding\n"; print STDERR " coping shortcuts: $shortcuts\n"; print STDERR "OUTPUT\n"; print STDERR " strings file: $strings_file\n"; print STDERR "\n"; } else { print "\nHELP\n"; print " Stopped! Please enter three (no more, no less) paramaters!\n"; die " Try once again...\n\n"; } ## ## two classes of en-US strings from _Id.h files ## @srcfiles = ("./ap_String_Id.h", "./xap_String_Id.h"); foreach my $file (@srcfiles) { open(CLASS, "< $file" ) or die "Cannot open $file"; $file =~ /\.\/(.*)_String_Id.h/; $string_class = $1; $string_class =~ tr/a-z/A-Z/; unshift(@srclang, $string_class); while () { next unless /^\s*dcl\((.*)\s*,\s*\"(.*)\"/; my ($dlg,$string) = ($1,$2); ## ## some important replacing if ($shortcuts eq "YES" ) { $string =~ s/&/&\;/; } else { $string =~ s/&//; } $string =~ s/>/>\;/g; $string =~ s/ $strings_file") or die "Cannot write to strings file: $strings_file"; print NEW "<\?xml version=\"1.0\" encoding=\"$encoding\"\?>\n"; print NEW "\n"; print NEW "\n"; print NEW "\n"; print NEW "\n"; print NEW "\n"; print NEW "\n"; print NEW "\n\n"; print NEW "\n"; print NEW "\n"; print NEW "\n"; print NEW "\n\n"; $total = 0; foreach $string_class (@srclang) { print NEW "\n"; } print NEW "\n"; close NEW; print STDERR "STATS for lang $newlang:\n"; print STDERR " total $total strings.\n\n"; ## ## ##