diff options
author | Andras Timar <atimar@novell.com> | 2011-04-15 21:34:28 +0200 |
---|---|---|
committer | Andras Timar <atimar@novell.com> | 2011-04-15 21:34:28 +0200 |
commit | 8a610e16fb0f4b5c53e86e2b443145a8d46d59f2 (patch) | |
tree | 897da561406b3ce021ef05090bf75913fe41a980 | |
parent | cf97e6633268b64dea8f09d9e2bc7fdc37642824 (diff) |
Various translation checks for LibreOffice
* gsicheck
* readmecheck which is a modified gsicheck
* doublecheck from Gregor Hartmann (OOo) see also #i112478#
-rwxr-xr-x | doublecheck.pl | 176 | ||||
-rwxr-xr-x | translationscheck.sh | 22 |
2 files changed, 198 insertions, 0 deletions
diff --git a/doublecheck.pl b/doublecheck.pl new file mode 100755 index 0000000..12a8e97 --- /dev/null +++ b/doublecheck.pl @@ -0,0 +1,176 @@ +: +eval 'exec perl -wS $0 ${1+"$@"}' + if 0; +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* +# +# doublecheck - Checks sdf files for identical translations where they have to be unique. +# + +use strict; + +my ($source); +my (%languages, %languages_seen, %Stores, $smodule, $help, $lineOK, $module, $gid, $lid, $lang, $found, $text, $Store_ref, $error, $file, $line, $sfile, $sgid, $slid, $goodlangs ); + +# this string should contain only languages that are known to be well translated i.e. no newly translated languages or even in pregress +$goodlangs = "de fr ja es ko"; + +%languages = (); +%languages_seen = (); +%Stores = (); + +if ( !exists $ENV{ "WITH_LANG" } || !$ENV{ "WITH_LANG" } ) +{ + print "\$WITH_LANG not set or empty: nothing to do\n"; + exit 0; +} + +foreach ( split( " ", $ENV{ "WITH_LANG" } ) ) +{ + $languages{ $_ } = 1; +} + +$smodule = $sfile = $sgid = $slid = ".*"; + + +&get_options; + +if ( ! $source ) +{ + print "Error: No sdf_filename defined\n\n"; + $help = "Yes"; +} +if ( !$help ) +{ + + $found = 0; + open SOURCE, "<$source"; + while ( <SOURCE> ) + { + analyze_line( $_ ); + + $languages_seen{ $lang } = 1 if ( $lineOK ); + + if ( $lineOK && $module =~ $smodule && $file =~ $sfile && $gid =~ $sgid && $lid =~ $slid ) + { + $found += 1; + if ( exists $languages{ $lang } ) + { + if ( !exists $Stores{ $lang } ) + { + my %S = (); + $Stores{ $lang } = \%S; + } + $Store_ref = $Stores{ $lang }; + if ( exists $$Store_ref{ $text } ) + { + print "Entry double for LANG=$lang in file $source\n"; + print $$Store_ref{ $text }; + print $line; + $error = 1; + } + else + { + $$Store_ref{ $text } = $line; + } + } + } + } + close SOURCE; + +# print "$found strings found in $source for -m $smodule -f $sfile -g $sgid -l $slid\n"; + foreach my $goodlang ( split( " ", $goodlangs ) ) + { + if ( exists $languages_seen{ $goodlang } && exists $languages{ $goodlang } && !exists $Stores{ $goodlang } ) + { + die "no sting found to check for language $lang in $source for -m $smodule -f $sfile -g $sgid -l $slid. Maybe the strings have been relocated."; + } + } + die "errors found" if ( $error ); + +} +else +{ + print "\n\n"; + print "doubleckeck v.1.0\n"; + print "---------------------\n"; + print "Usage:\n"; + print "doubleckeck [-m <module>] [-f <filepath>] [-g <GID>] [-l <LID>] <sdf_filename>\n"; + print "doubleckeck --help\n"; + print "\n"; + print "------------------------------------------------------------------------------\n"; + print "Checks sdf files for identical translations where they have to be unique.\n"; + print "The switches -m, -f, -g and -l are treated as perl regular expressions.\n"; + print "They default to .*\n"; + print "All Languages in \$WITH_LANG are checked.\n"; + print "\n\n"; +} + + + +sub get_options { + my ($arg,$has_source); + $has_source = 0; + while ($arg = shift @ARGV) { + $arg =~ /^-m$/ and $smodule = shift @ARGV and next; + $arg =~ /^-f$/ and $sfile = shift @ARGV and next; + $arg =~ /^-g$/ and $sgid = shift @ARGV and next; + $arg =~ /^-l$/ and $slid = shift @ARGV and next; + $arg =~ /^--help$/ and $help = 1 and next; #show help + + if ( !$has_source ) + { + $source = $arg; + $has_source = 1; + } + else + { + die "only one file can be parsed"; + } + } +} + + +sub analyze_line { + + ($line) = @_; + + $lineOK = 0; + if ( $line =~ /^([^\t]*)\t([^\t]*)\t[^\t]*\t[^\t]*\t([^\t]*)\t([^\t]*)\t[^\t]*\t[^\t]*\t[^\t]*\t([^\t]*)\t([^\t]*)\t[^\t]*\t[^\t]*\t[^\t]*\t[^\t]*/ ) + { + $module = $1; + $file = $2; + $gid = $3; + $lid = $4; + + $lang = $5; + $text = $6; + + $lineOK = 1; + } +} + diff --git a/translationscheck.sh b/translationscheck.sh new file mode 100755 index 0000000..5373e5e --- /dev/null +++ b/translationscheck.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +OOBUILDDIR='/home/timar/libreoffice-3-4/' +MY_PATH=`pwd` +. $OOBUILDDIR/LinuxX86Env.Set.sh + +base=`dirname $0` + +#for i in `ls -1 $SRC_ROOT/translations/source` +for i in hu +do + po2oo -i $SRC_ROOT/translations/source/$i -t $SRC_ROOT/translations/unxlngi6.pro/misc/sdf-template/en-US.sdf -o $i.sdf -l $i + gsicheck -c -wef $i.err $i.sdf >$i.log + READMETMP=$(mktemp) + grep "^readlic" $i.sdf | grep -v " en-US " | sed -e "s/</\\\</g" -e "s/>/\\\>/g" -e 's/"/\\\"/g' > $READMETMP + gsicheck -c -l "" $READMETMP | sed -e "s/\\\>/>/g" -e "s/\\\</</g" -e 's/\\\"/"/g' >> $i.log + WITH_LANG=$i $base/doublecheck.pl -m formula -f source.core.resource.core_resource.src -g RID_STRLIST_FUNCTION_NAMES $i.sdf >>$i.log || exit 1 + WITH_LANG=$i $base/doublecheck.pl -m scaddins -f source.analysis.analysis_funcnames.src -g RID_ANALYSIS_FUNCTION_NAMES $i.sdf >>$i.log || exit 1 + WITH_LANG=$i $base/doublecheck.pl -m scaddins -f source.datefunc.datefunc.src -g RID_DATE_FUNCTION_NAMES $i.sdf >> $i.log || exit 1 + WITH_LANG=$i $base/doublecheck.pl -m sw -f source.ui.utlui.poolfmt.src -g "STR_POOLNUMRULE_.*" $i.sdf >> $i.log || exit 1 + WITH_LANG=$i $base/doublecheck.pl -m sw -f source.ui.utlui.poolfmt.src -g "STR_POOLCOLL_.*" $i.sdf >> $i.log || exit 1 +done |