Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
81da2439
Kaydet (Commit)
81da2439
authored
Eyl 16, 2011
tarafından
Andras Timar
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
rewrite keyidGen.pl
it creates 4 letter key IDs (same as in pot/po files)
üst
8c49b1eb
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
65 additions
and
104 deletions
+65
-104
keyidGen.pl
l10ntools/scripts/keyidGen.pl
+65
-104
No files found.
l10ntools/scripts/keyidGen.pl
Dosyayı görüntüle @
81da2439
...
@@ -31,15 +31,10 @@ eval 'exec perl -S $0 ${1+"$@"}'
...
@@ -31,15 +31,10 @@ eval 'exec perl -S $0 ${1+"$@"}'
# add keyids to sdf file
# add keyids to sdf file
#
#
use
Compress
::
Zlib
();
my
$infile
=
$ARGV
[
0
];
if
(
!
$infile
)
{
die
"Usage: $0 <infile> [<outfile>]\n"
;}
print
"\nkeyidGen version 1.0 \n\n"
;
my
$outfile
=
$ARGV
[
1
];
my
(
$
infile
,
$
outfile
,
$
dbimport
);
get_options
();
print_help
()
if
(
!
defined
$
infile
||
$
help
);
exit
1
if
(
!
defined
$
infile
);
if
(
!
defined
$outfile
)
if
(
!
defined
$outfile
)
{
{
$outfile
=
$infile
;
$outfile
=
$infile
;
...
@@ -47,139 +42,105 @@ if ( ! defined $outfile )
...
@@ -47,139 +42,105 @@ if ( ! defined $outfile )
$outfile
.=
"_KeyID.sdf"
;
$outfile
.=
"_KeyID.sdf"
;
}
}
$
collisions
=
0
;
%
hashcodes
=
();
$
count
=
0
;
print
"writing to $outfile\n"
;
print
"writing to $outfile\n"
;
open
INFILE
,
"<$infile"
||
die
"could not open $infile $! $^E\n"
;
open
INFILE
,
"<$infile"
||
die
"could not open $infile $! $^E\n"
;
open
OUTFILE
,
">$outfile"
||
die
"could not open $outfile $! $^E\n"
;
open
OUTFILE
,
">$outfile"
||
die
"could not open $outfile $! $^E\n"
;
while
(
<
INFILE
>
)
while
(
<
INFILE
>
)
{
{
$
line
=
$
_
;
chomp
;
chomp
$
line
;
if
(
/^([^\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]*)$/
)
$
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"
;
my
$prj
=
defined
$1
?
$1
:
''
;
$
hashp
=
makeID
(
$
string
);
my
$file
=
defined
$2
?
$2
:
''
;
my
$dummy
=
defined
$3
?
$3
:
''
;
if
(
defined
(
$
hashcodes
{
$
hashp
}
)
)
my
$type
=
defined
$4
?
$4
:
''
;
{
my
$gid
=
defined
$5
?
$5
:
''
;
$
collisions
++
unless
$
hashcodes
{
$
hashp
}
eq
$
string
;
my
$lid
=
defined
$6
?
$6
:
''
;
}
my
$helpid
=
defined
$7
?
$7
:
''
;
$
hashcodes
{
$
hashp
}
=
$
string
;
my
$platform
=
defined
$8
?
$8
:
''
;
$
count
++
;
my
$width
=
defined
$9
?
$9
:
''
;
if
(
$
dbimport
)
my
$lang
=
defined
$10
?
$10
:
''
;
{
my
$text
=
defined
$11
?
$11
:
''
;
my
(
$
pre
,
$
post
,
$
old
);
my
$helptext
=
defined
$12
?
$12
:
''
;
$
pre
=
"$1\t$2\t"
;
my
$quickhelptext
=
defined
$13
?
$13
:
''
;
$
post
=
"\t$4\t$5\t$6\t$7\t$8\t$9\t$10\t$11\t$12\t$13\t$14\t$15\n"
;
my
$title
=
defined
$14
?
$14
:
''
;
$
old
=
$
3
;
my
$timestamp
=
defined
$15
?
$15
:
''
;
$
old
=~
s
/
;{
0
,
1
}
keyid
:......
;{
0
,
1
}
//
;
@path
=
split
(
"\\\\"
,
$file
);
$
old
=~
s
/^
0
$
//
;
$key
=
$path
[
-
3
]
.
"_"
.
$path
[
-
2
]
.
"_"
.
$path
[
-
1
]
.
"#"
.
$gid
.
"."
;
if
(
$
old
ne
""
)
{
$
old
.
=
";"
;
}
if
(
length
(
$lid
))
{
$key
.=
$lid
.
"."
;}
print
OUTFILE
"$pre${old}keyid:$hashp$post"
;
if
(
length
(
$type
))
{
$key
.=
$type
.
"."
;}
}
# replace non-word characters to _ just as in po files in source keys
else
$key
=~
s
|
[
^\
w
#\./]|_|g;
{
# ISO 639 private use code
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"
;
$lang
=
"qtz"
;
}
if
(
$text
ne
""
)
{
$text
=
makekeyidstr
(
keyidgen
(
$key
.
"text"
),
$text
);}
if
(
$quickhelptext
ne
""
)
{
$quickhelptext
=
makekeyidstr
(
keyidgen
(
$key
.
"quickhelptext"
),
$quickhelptext
);}
if
(
$title
ne
""
)
{
$title
=
makekeyidstr
(
keyidgen
(
$key
.
"title"
),
$title
);}
print
OUTFILE
"$prj\t$file\t$dummy\t$type\t$gid\t$lid\t$helpid\t$platform\t$width\t$lang\t$text\t$helptext\t$quickhelptext\t$title\t$timestamp\n"
;
}
}
}
}
print
"$count entries\n"
;
print
"$collisions collisions\n"
;
close
INFILE
;
close
INFILE
;
close
OUTFILE
;
close
OUTFILE
;
sub
makeID
sub
keyidgen
{
{
my
(
$
String
)
=
shift
;
my
$key
=
shift
;
my
(
$
hash
);
my
$crc
=
crc24
(
$key
);
#
hardcoded
to
prevent
windows
installer
to
choke
on
bad
directoryname
:-((
my
$symbols
=
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz#_"
;
if
(
$
String
eq
"scp2 source\\ooo\\directory_ooo.ulf LngText STR_DIR_KAPITEL "
)
my
$keyid
=
""
;
while
(
length
(
$keyid
)
<
4
)
{
{
return
"keyid1"
;
$keyid
.=
substr
(
$symbols
,
$crc
&
63
,
1
);
$crc
=
$crc
>>
6
;
}
}
return
$keyid
;
$
hash
=
Compress
::
Zlib
::
crc32
(
$
String
,
undef
);
return
makenumber
(
$
hash
);
}
}
sub
makenumber
sub
crc24
{
{
$
h
=
shift
;
my
$CRC24_INIT
=
0x00b704ce
;
#
1
2
3
4
my
$CRC24_POLY
=
0x00864cfb
;
#
1234567890123456789012345678901234567890
my
$key
=
shift
;
$
symbols
=
"0123456789abcdefghijklmnopqrstuvwxyz+-[=]"
;
my
$key_length
=
length
(
$key
);
$
order
=
length
(
$
symbols
);
my
$crc
=
$CRC24_INIT
;
$
result
=
""
;
my
$position
=
0
;
while
(
length
(
$
result
)
<
6
)
while
(
$position
<
$key_length
)
{
{
$
result
.
=
substr
(
$
symbols
,
(
$
h
%
$
order
),
1
);
$crc
^=
(
unpack
(
"C"
,
substr
(
$key
,
$position
,
1
))
<<
16
);
$
h
=
int
(
$
h
/
$
order
);
my
$i
;
for
(
$i
=
0
;
$i
<
8
;
$i
++
)
{
$crc
<<=
1
;
$crc
^=
$CRC24_POLY
if
(
$crc
&
0x01000000
)
}
$position
++
;
}
}
die
"makenumber failed because number is too big (this cannot be so this is a strange error)"
if
$
h
>
0
;
return
$crc
&
0x00ffffff
;
return
reverse
$
result
;
}
}
sub
makekidstr
sub
makek
ey
idstr
{
{
$
k
id
=
shift
;
my
$key
id
=
shift
;
$
str
=
shift
;
my
$str
=
shift
;
if
(
$str
ne
""
)
if
(
$str
ne
""
)
{
{
# special handling for strings starting with font descriptions like {&Tahoma8} (win system integration)
# special handling for strings starting with font descriptions like {&Tahoma8} (win system integration)
if
(
$
str
=~
s
/^
(
\
{
\
&
[
^
\
}]
+
\
})
//
)
if
(
$str
=~
s/^(\{
[\&\\]
[^\}]+\})//
)
{
{
return
"$1$kid‖$str"
;
return
"$1$k
ey
id‖$str"
;
}
}
else
else
{
{
return
"$kid‖$str"
;
return
"$k
ey
id‖$str"
;
}
}
}
}
else
else
{
{
return
""
;
return
""
;
}
}
# return "default";
}
sub
print_help
{
print
"\n\n"
;
print
"keyidGen 0.5 for sdf files\n"
;
print
"--------------------------\n"
;
print
"Usage:\n"
;
print
"keyidGen <infile> [<outfile>] [-dbimport]\n"
;
print
" add keyids to the entries and write them to a file with\n"
;
print
" _KeyID added to the name\n"
;
print
" -dbimport Add KeyID to a new column instead of to the strings.\n"
;
print
" This is needed to import the IDs into tha database.\n"
;
print
"\n\n"
;
}
sub
get_options
{
my
(
$
arg
,
$
has_infile
);
while
(
$
arg
=
shift
@
ARGV
)
{
$
arg
=~
/^-
dbimport
$
/
and
$
dbimport
=
1
and
next
;
$
arg
=~
/^-
help
$
/
and
$
help
=
1
and
next
;
#
show
help
if
(
!
$
has_infile
)
{
$
infile
=
$
arg
;
$
has_infile
=
1
;
}
else
{
$
outfile
=
$
arg
;
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment