Community « Discussion forum « Localization support board « First tests of localizations have been positive «
Comment: First tests of localizations have been positive
| << Previous | Next >> |
Great! I see this is going on!
Started out on my own, in bash, to translate this yacs, but this sounds way better.
Since i took some hurdles (read: welcome in qoute hell!) i like to share the script with you anyhow:
Since i took some hurdles (read: welcome in qoute hell!) i like to share the script with you anyhow:
#!/bin/bash
#-------------------------------------------------------
# transyacs.sh
# a small script to help localize YACS and others who
# use 'the poor mans localization' method :)
# run in the top-level directory, you will get an extra file
# for each translation, like: about.php and about.php_nl
#
#
# unpack the yacs zip file, cd to it and run this script
# translate, and send back in!
#
# share and enjoy!
#
# Vincent Kersten, GPLv2 licence, vince(a)puscii(dot)nl
# http://www.latinovac.org/ (no yacs yet! booh!)
#--------------------------------------------------------
# the only thing to change in the script:
translate_to="nl" # language you want to
# translate to
# use two letter codes
translate_from="en" # root-language; this should
# catch all translations
translationstring='$local' # to identify the localization string
separator="_" # the character _before_
# the root-language country code
# (see $label and $label2 below)
label="${separator}${translate_from}"
label2="${separator}${translate_to}"
#--------------------------------------------------------
################# no more editables below
set -f # no shell globbing
t="$IFS"
IFS="
" # here is just a newline, no whitespace
for filename in $(find . -name '*php' ); do
destination="${filename}${label2}"
# create/empty file
: > "$destination" || exit 1
linenumber=0
found=0
part=""
echo "################ $filename"
for line in $(cat "$filename"); do
(( linenumber++ ))
echo "$line">>"$destination"
#print comments
echo "$line" | grep -E "^ \*|^//"
#check for multiple line statements
if [[ $(echo -E "$line" | grep "$label") ]]; then
found=1
fi
if [ $found = 1 ]; then
# find the end of the sentence
if [[ $(echo -E "$line" | grep -E ';$') ]]; then
part="${part}${line}"
insertafterline="$linenumber"
sentence="$part"
# start translation
left="$(echo -E "$sentence" | cut -d= -f1)"
right="$(echo -E "$sentence" | cut -d= -f2-99)"
echo "______________________________________________________"
echo -E "$right"
echo "------------------ ${translate_from} -> ${translate_to} --------------------------"
read answer
echo -E "${left/$label/$label2} = ${answer}">>"$destination"
# reset values
part=""
found=0
# line continues
else
part="${part}${line}"
fi
fi
done #file
done # all files
exit
This comment has inspired:
by Vincent on Oct. 30 2006
