KeyID Build
From Apache OpenOffice Wiki
A KeyID build is a special build used mainly for translation-related QA work on localized builds. It helps to identify UI (User Interface) and OLH (Online Help) strings based on their KeyID. A KeyID is a unique 6-digits number that serves as identifier of the string in the Sun's translation database.
There is no functional difference between a regular build and a KeyID build. The difference between the two is that the KeyID build displays the KeyIDs of the strings in the UI and OLH.
See the illustrating screenshots taken on a French regular and KeyID build:
Making your own KeyID build
here is a script proposal which can be used to add KeyIDs of a new kind to an existing sdf file.
*NOTE* these KeyIDs are different from those in the database but might well get standard soon. *NOTE* gsicheck should be used with -k key to prevent errors regarding KeyIDs
:
eval 'exec perl -S $0 ${1+"$@"}'
if 0;
#*************************************************************************
#
# OpenOffice.org - a multi-platform office productivity suite
#
# $RCSfile: ,v $
#
# $Revision: $
#
# last change: $Author: $ $Date: $
#
# The Contents of this file are made available subject to
# the terms of GNU Lesser General Public License Version 2.1.
#
#
# GNU Lesser General Public License Version 2.1
# =============================================
# Copyright 2007 by Sun Microsystems, Inc.
# 901 San Antonio Road, Palo Alto, CA 94303, USA
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License version 2.1, as published by the Free Software Foundation.
#
# This library 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 for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307 USA
#
#*************************************************************************
#
# add keyids to sdf file
#
use Digest;
$infile = shift;
print_help() if ( !defined $infile );
exit 1 if ( !defined $infile );
$outfile = $infile;
$outfile =~ s/\.sdf$//i;
$outfile .= "_KeyID.sdf";
print "writing to $outfile\n";
$hashfunc = Digest->new("CRC-32");
$colisions = 0;
%hashcodes = ();
$count = 0;
open INFILE,"<$infile" || die "coudl not open $infile $! $^E\n";
open OUTFILE,">$outfile" || die "coudl not open $outfile $! $^E\n";
while ( <INFILE> )
{
$line = $_;
$hash = 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]*)/ )
{
$string="$1 $2 $4 $5 $6 $7 $8";
$hashfunc->reset();
$hashfunc->add($string);
$hash = $hashfunc->digest();
$hashp = makenumber( $hash );
if ( defined ($hashcodes{ $hashp } ) )
{
$colisions ++;
}
$hashcodes{ $hashp } = $line;
$count++;
print OUTFILE "$1\t$2\t$3\t$4\t$5\t$6\t$7\t$8\t$9\t$10\t".makekidstr($hashp,$11)."\t".makekidstr($hashp,$12)."\t$13\t".makekidstr($hashp,$14)."\t$15\n";
}
}
print "$count entries\n";
print "$colisions colisions\n";
close INFILE;
close OUTFILE;
sub makenumber
{
$h = shift;
# 1 2 3 4
# 1234567890123456789012345678901234567890
$symbols="0123456789abcdefghijklmnopqrstuvwxyz+-<=>";
$order = length($symbols);
$result = "";
while ( $h > 0 )
{
$result .= substr( $symbols, ($h % $order), 1 );
$h = int( $h / $order );
}
return reverse $result;
}
sub makekidstr
{
$kid = shift;
$str = shift;
if ( $str )
{
return "$kid.$str";
}
else
{
return "";
}
return "default";
}
sub print_help
{
print "\n\n";
print "keyidGen 0.1 for sdf files\n";
print "--------------------------\n";
print "Usage:\n";
print "keyidGen <infile>\n";
print " add keyids to the entries and write them to a file with\n";
print " _KeyID added to the name\n";
print "\n\n";
}