#!/bin/ksh -p # I18N Guidelines and Techniques PATH=$PATH:/set/dist/sparc-S2/bin #D='echo DEBUG: ' D= runprog=yes #runprog=no changesfile=/tmp/i18n-java-changes.$$ progdir=${0%/*} dotelfile=$progdir/i18n.el prog=$progdir/i18n-checker xemacs_command="xemacs -q -l $dotelfile" xemacs_exit_command='gnudoit (i18n-exit)' if [ $runprog = "yes" ]; then updateprog='rm -f' else updateprog='touch' fi progname=${0##*/} function log { echo "$@" echo " " "$@" >> $changesfile } function donothing { # all done now. that was easy :-) # search for 'D' to see how this is used. echo > /dev/null } function usage { cat < x load-file $dotelfile Usage: $progname [ -nx ] -p property-file [ i18n-checker_options ] [-?] [-??] javafile ... -nx Use an existing xemacs. Must have $dotelfile loaded -p property-file Override default properties file. i18n-checker_options Options passed to i18n-checker. -? View this message. -?? See arguments for the i18n-checker program. =============================================================================== EOF exit 1 } wrapperfuncs=" I18N.getDefaultProperty I18N.putDefaultProperty I18N.getProperty I18N.getMessage I18N.getNonLocalizedString I18N.getBoolean I18N.getInt I18N.getInteger I18N.getColor I18N.putProperty I18N.removeProperty I18N.putPropertyList I18N.getPropertyList I18N.getFont I18N.getURL I18N.fmtMsg I18N.getMsg Globals.getDefaultProperty Globals.putDefaultProperty Globals.getProperty Globals.getMessage Globals.getNonLocalizedString Globals.getBoolean Globals.getInt Globals.getInteger Globals.getColor Globals.putProperty Globals.removeProperty Globals.putPropertyList Globals.getPropertyList Globals.getFont Globals.getURL Globals.fmtMsg Globals.getMsg Global.fmtMsg Global.getMsg System.getProperty System.loadLibrary UserTextButton UserLabel UserCheckbox UserImageButton UserTextField UserTextArea UserMenuBar Benchmark.find Benchmark.mark Benchmark Debug.g.println Debug.g.print Yg.debug " bogusfuncs="" wrapperargs= for i in $wrapperfuncs do wrapperargs="$wrapperargs -w $i" done for i in $bogusfuncs do wrapperargs="$wrapperargs -b $i" done if [ $# = 0 ]; then usage fi start_emacs=yes args= dousage=no checking=no dash_p_arg= for i do case $i in -nx) start_emacs= ;; -[woeEsSP]) args="$args $i $2" shift ;; -p) dash_p_arg=$2 args="$args $i $2" shift ;; -c) checking=yes start_emacs= D='donothing' args="$args $i" ;; -?) dousage=yes ;; -??) dousage=i18n-checker ;; -*) echo "${progname}: Confused about argument '$i'." usage exit 1 ;; *) break # end of arguments ;; esac shift done workspace=`workspace name` if [ -z "$workspace" ]; then echo "${progname}: Must be run within a teamware workspace." exit 1 fi propsmkdir=$workspace/makefiles propsmkfile=properties.mk propsmk=$propsmkdir/$propsmkfile firstjavafile=$1 javafiles= for i in $* do case $i in *.java) javafiles="$javafiles $i" ;; *.c) javafiles="$javafiles $i" ;; *) echo "${progname}: Confused about type of file $i" exit 1 ;; esac done if [ -z "$javafiles" -a "$dousage" == "no" -a "$checking" != "yes" ]; then echo "${progname}: You must specify at least one java file." usage fi if [ -z "$dash_p_arg" ]; then # this is just to get the last two path elements out of firstjavafile # we add PWD in case it has less than two to start with dash_p_dir=$PWD/$firstjavafile dash_p_dir=${dash_p_dir%/*} scratch=${dash_p_dir%/*/*} # scratch now equals the part we don't want scratch2=${dash_p_dir#$scratch/} # scratch2 is part we want but has slash part1=${scratch2%/*} part2=${scratch2#*/} dash_p_arg=$workspace/properties/${part1}.${part2}.$$-messages.properties args="$args -p $dash_p_arg" fi if [ -f "$dash_p_arg" -a "$dousage" == "no" -a "$checking" != "yes" ]; then echo "${progname}: $dash_p_arg exists. How did that happen?" exit 1 fi if [ "$dousage" = "yes" ]; then usage elif [ "$dousage" = "i18n-checker" ]; then $prog $wrapperargs $args -? exit 1 fi for j in $javafiles do base=${j##*/} dir=${j%/*} if [ "$dir" = "$j" ] then dir=. fi (cd $dir $D sccs edit -s $base $updateprog ${base}-i18n ) done if [ -n "$start_emacs" ]; then $xemacs_command & echo "Waiting 20 seconds for xemacs startup..." sleep 20 echo "Done waiting for xemacs" fi if [ $runprog = "yes" ]; then $prog $wrapperargs $args $javafiles fi if [ -n "$start_emacs" ]; then $xemacs_exit_command & fi if [ "$checking" != "yes" ]; then for j in $javafiles do dir=${j%/*} base=${j##*/} if [ "$dir" = "$j" ] then dir=. fi (cd $dir if cmp -s ${base}-i18n $base; then # nothing to do - just cleanup log "No changes made to ${base}." rm -f ${base}-i18n sccs unedit ${base} > /dev/null else # we made changes - figure out if we need to add an import statement if egrep '[ ]*import[ ]*sun.jpro.i18n.I18N' ${base}-i18n > /dev/null; then # do nothing - already have import log "Changes made to ${base}. You must check it back in." else # must add import log "Changes made to ${base}. You must check it back in." sed 's/^[ ]*package[ ].*$/&\ \ import sun.jpro.i18n.I18N;/' \ < ${base}-i18n > ${base}-i18n-2 rm -f ${base}-i18n mv ${base}-i18n-2 ${base}-i18n fi $D mv ${base}-i18n $base # $D sccs delget -s -y"strings automatically i18n'ed by $progname" $base $D chmod 644 $base fi ) done if [ -s $dash_p_arg ]; then propsdir=${dash_p_arg%/*} propsbase=${dash_p_arg##*/} if [ "$propsdir" = "$dash_p_arg" ] then propsdir=. fi (cd $propsdir $D sccs create $propsbase > /dev/null # no -s for sccs create ) log "SCCS created $dash_p_arg." sed 's!^PROPERTY_FILES = .*$!&\ $(PROPERTY_JAVA_DIR)/'$propsbase' \\!' $propsmk > ${propsmk}-tmp (cd $propsmkdir $D sccs edit -s $propsmkfile $D mv ${propsmk}-tmp $propsmk $D sccs delget -s -y"automatically added props file $propsbase" $propsmk ) log "Modified ${propsmk}." else log "No messages created in this run. No properties file created." rm -f $dash_p_arg fi cat << EOF =============================================================================== IMPORTANT OUTPUT BEGINS HERE PLEASE READ =============================================================================== You should now build the workspace and test the parts of the program you have modified. If all goes well you can do your putback. Please include in the putback message a line of the form I18N'ed messages for files file1.java file2.java ... and include all files that were affected. Please don't just say .../foo/*.java as that makings grepping for a specific file name difficult. If things don't build correctly or run correctly please: - don't panic - investigate to figure up what is wrong - if it is your error, fix it =============================================================================== EOF fi if [ -s $changesfile ]; then echo "Summary of run:" cat $changesfile echo '===============================================================================' fi rm -f $changesfile