From: kruland2607 Date: Sun, 8 Jan 2012 02:23:06 +0000 (+0000) Subject: moving to core/ X-Git-Tag: upstream/12.03~1^2~174 X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=746dc4db372980f08b14799732c653744d944986;p=debian%2Fopenrocket moving to core/ git-svn-id: https://openrocket.svn.sourceforge.net/svnroot/openrocket/trunk@297 180e2498-e6e9-4542-8430-84ac67f01cd8 --- diff --git a/core/scripts/checkTranslations.sh b/core/scripts/checkTranslations.sh new file mode 100755 index 00000000..bbbf91c2 --- /dev/null +++ b/core/scripts/checkTranslations.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +# +# Perform all tests for the translation files. +# +# Usage: +# ./scripts/checkTranslations.sh +# + + +# Test that keys used in Java files are present in English messages +find src/ -name "*.java" -exec ./scripts/verifyTranslationKeys.pl l10n/messages.properties {} + + diff --git a/core/scripts/renameTranslationKeys.sh b/core/scripts/renameTranslationKeys.sh new file mode 100644 index 00000000..2a7314da --- /dev/null +++ b/core/scripts/renameTranslationKeys.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +# +# Rename translation keys in translation files. +# +# Usage: +# renameTranslationKeys.sh +# +# The mapping files contain " " key pairs. +# Empty lines and lines starting with "#" are ignored. +# All translation files are modified at once. +# + +TRANSLATIONS=messages*.properties + +cat "$@" | while read line; do + + if echo "$line" | grep -q "^\s*$\|^\s*#"; then + continue + fi + + if ! echo "$line" | egrep -q "^\s*[a-zA-Z0-9._-]+\s+[a-zA-Z0-9._-]+\s*$"; then + echo "Invalid line: $line" + fi + + from="`echo $line | cut -d" " -f1`" + to="`echo $line | cut -d" " -f2`" + + sed -i "s/^${from}\s*=\s*/${to} = /" $TRANSLATIONS + +done diff --git a/core/scripts/verifyTranslationKeys.pl b/core/scripts/verifyTranslationKeys.pl new file mode 100755 index 00000000..f084f062 --- /dev/null +++ b/core/scripts/verifyTranslationKeys.pl @@ -0,0 +1,67 @@ +#!/usr/bin/perl + +# +# Verify that keys used in Java files are present in the translation file. +# +# Usage: +# verifyTranslationKeys.pl +# +# For example: +# find src/ -name "*.java" -exec ./scripts/verifyTranslationKeys.pl l10n/messages.properties {} + +# + + + +# Read the translation file +my %keys; +print "Reading translation keys...\n"; +while ($str = <>) { + if ($ARGV!~/\.properties/) { + last; + } + + if ($str=~/^\s*($|[#!])/) { + next; + } + + if ($str=~/^([a-zA-Z0-9._-]+)\s*=/) { + $keys{$1} = 1; + } else { + print "ERROR: Invalid line in $ARGV: $str"; + } +} + + +# Read Java files +my $oldFile = $ARGV; +my $class=""; +print "Reading Java files...\n"; +while ($str = <>) { + + # Check for new file + if ($ARGV != $oldFile) { + $class = ""; + } + + # Check for irregular translator definition (exclude /l10n/ and /startup/) + if ($str =~ / Translator / && + $str !~ /private static final Translator trans = Application.getTranslator\(\);/ && + $ARGV !~ /\/(l10n|startup)\//) { + print "ERROR: Unusual translator usage in file $ARGV: $str"; + } + + # Check for new class definition + if ($str =~ /^[\sa-z]*class ([a-zA-Z0-9]+) /) { + $class = $1; + } + + # Check for translator usage + if ($str =~ /trans\.get\(\"([^\"]+)\"\)/) { + $key = $1; + if (!(exists $keys{$key}) && + !(exists $keys{$class . "." . $key})) { + print "ERROR: Missing translation for '$key' in file $ARGV\n"; + } + } + +} diff --git a/scripts/checkTranslations.sh b/scripts/checkTranslations.sh deleted file mode 100755 index bbbf91c2..00000000 --- a/scripts/checkTranslations.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash - -# -# Perform all tests for the translation files. -# -# Usage: -# ./scripts/checkTranslations.sh -# - - -# Test that keys used in Java files are present in English messages -find src/ -name "*.java" -exec ./scripts/verifyTranslationKeys.pl l10n/messages.properties {} + - diff --git a/scripts/renameTranslationKeys.sh b/scripts/renameTranslationKeys.sh deleted file mode 100644 index 2a7314da..00000000 --- a/scripts/renameTranslationKeys.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash - -# -# Rename translation keys in translation files. -# -# Usage: -# renameTranslationKeys.sh -# -# The mapping files contain " " key pairs. -# Empty lines and lines starting with "#" are ignored. -# All translation files are modified at once. -# - -TRANSLATIONS=messages*.properties - -cat "$@" | while read line; do - - if echo "$line" | grep -q "^\s*$\|^\s*#"; then - continue - fi - - if ! echo "$line" | egrep -q "^\s*[a-zA-Z0-9._-]+\s+[a-zA-Z0-9._-]+\s*$"; then - echo "Invalid line: $line" - fi - - from="`echo $line | cut -d" " -f1`" - to="`echo $line | cut -d" " -f2`" - - sed -i "s/^${from}\s*=\s*/${to} = /" $TRANSLATIONS - -done diff --git a/scripts/verifyTranslationKeys.pl b/scripts/verifyTranslationKeys.pl deleted file mode 100755 index f084f062..00000000 --- a/scripts/verifyTranslationKeys.pl +++ /dev/null @@ -1,67 +0,0 @@ -#!/usr/bin/perl - -# -# Verify that keys used in Java files are present in the translation file. -# -# Usage: -# verifyTranslationKeys.pl -# -# For example: -# find src/ -name "*.java" -exec ./scripts/verifyTranslationKeys.pl l10n/messages.properties {} + -# - - - -# Read the translation file -my %keys; -print "Reading translation keys...\n"; -while ($str = <>) { - if ($ARGV!~/\.properties/) { - last; - } - - if ($str=~/^\s*($|[#!])/) { - next; - } - - if ($str=~/^([a-zA-Z0-9._-]+)\s*=/) { - $keys{$1} = 1; - } else { - print "ERROR: Invalid line in $ARGV: $str"; - } -} - - -# Read Java files -my $oldFile = $ARGV; -my $class=""; -print "Reading Java files...\n"; -while ($str = <>) { - - # Check for new file - if ($ARGV != $oldFile) { - $class = ""; - } - - # Check for irregular translator definition (exclude /l10n/ and /startup/) - if ($str =~ / Translator / && - $str !~ /private static final Translator trans = Application.getTranslator\(\);/ && - $ARGV !~ /\/(l10n|startup)\//) { - print "ERROR: Unusual translator usage in file $ARGV: $str"; - } - - # Check for new class definition - if ($str =~ /^[\sa-z]*class ([a-zA-Z0-9]+) /) { - $class = $1; - } - - # Check for translator usage - if ($str =~ /trans\.get\(\"([^\"]+)\"\)/) { - $key = $1; - if (!(exists $keys{$key}) && - !(exists $keys{$class . "." . $key})) { - print "ERROR: Missing translation for '$key' in file $ARGV\n"; - } - } - -}