Show addkey.tcl syntax highlighted
#!/usr/bin/env tclsh
# Written by: Alexandre Hamelin (ahamelin users sourceforge net)
# Date: Sept 2, 2003
# Usage: ./addkey.tcl
#
# Small utility to add a new message key to a language file. When the key is
# added, the language file is sorted before it is written back to the disk.
# If the key already exists in the target language file, the associated message
# will be replaced. In the latter case, the old message will be printed on
# screen first.
#
# $Id: addkey.tcl 1604 2003-12-25 21:27:23Z ahamelin $
proc prompt {msg} {
puts -nonewline "$msg"
flush stdout
return [gets stdin]
}
proc die {msg} {
puts "error: $msg"
exit 1
}
set key [prompt "Specify a key (^C to abort): "]
set lang [prompt "Language for this key (en, fr_ca, etc.): "]
if {[catch {open lang$lang "r"} fd]} {
puts "TIP: This utility should be run from within the lang directory."
die $fd
}
# Read the content of the language file.
set lines [list]
gets $fd version
while { [gets $fd line] >= 0 } {
lappend lines $line
}
close $fd
# See whether the key exists or not.
set k [lsearch $lines "$key *"]
if {$k > -1} {
# Print the old message if the key existed.
set keytext [lindex $lines $k]
puts "-- Old message: [string repeat "-" 54]"
puts [string range $keytext [expr [string first " " $keytext]+1] end]
puts [string repeat "-" 70]
}
set msg [prompt "Enter the text for this key (<Enter> to end):\n"]
if {$k > -1} {
# Replace the text of an existing key.
lset lines $k "$key $msg"
} else {
# Add a new key.
lappend lines "$key $msg"
}
# Sort the content.
set lines [lsort $lines]
#puts stderr "WARNING: Original language file (lang$lang) will be truncated."
#puts stderr " Please press enter to continue."
#gets stdin
# Write the new language file.
if {[catch {open lang$lang "w"} fd]} {
die "$fd"
}
puts $fd $version
puts $fd [join $lines "\n"]
close $fd
See more files for this project here
A very nice MSN compatible messenger application, aMSN Messenger is a multiplatform MSN messenger clone. Works pretty much like its Windows based counterpart. Perfect for keeping in touch with those friends who have not yet seen the light. Works on linux
Project homepage:
http://sourceforge.net/projects/amsn
Programming language(s): C,C++,PHP,Tcl,XML
License: other
LANG-HOWTO
addkey.tcl
complete.pl
convert.tcl
genlangfiles.c
genpage.c
lang1.tmpl
lang2.tmpl
lang3.tmpl
langal
langast
langca
langca_VC
langchk.sh
langcs
langcy
langda
langde
langee
langel
langen
langes
langeu
langfi
langfr
langfr_CA
langfri
langglg
langgr2
langhu
langid
langis
langit
langko
langlt
langmk
langnl
langno
langoc
langpl
langpt
langpt_BR
langro
langru
langsk
langsl
langsr
langsv
langtr
langzh-CN
langzh-TW
missing.py
sortlang