lila/bin/translate
2013-05-31 12:25:07 +02:00

48 lines
1,012 B
Bash
Executable file

#!/bin/zsh
version=$(cat bin/.translate_version)
show() {
printf "Log translation %s\n" $version
git log -p t/$(echo $version)
}
next() {
printf "Increment translation version\n"
version=$(($version+1))
echo $version > bin/.translate_version
}
if [ "$1" = "set" ]; then
if [ "$2" ]; then
version="$2"
printf "Set version to %s\n" $2
echo $version > bin/.translate_version
fi
elif [ "$1" = "fetch" ]; then
printf "Fetch from version %s\n" $version
bin/cli i18n fetch $(echo $version)
elif [ "$1" = "s" ]; then
show
elif [ "$1" = "a" ]; then
printf "Apply translation %s\n" $version
git cherry-pick t/$(echo $version)
returncode=$?
if [ $returncode = 1 ]; then
git mergetool
elif [ $returncode = 0 ]; then
next
show
fi
elif [ "$1" = "n" ]; then
next
show
elif [ "$1" = "c" ]; then
printf "Commit resolved conflict\n"
(( prevVersion = version -1 ))
git clean -f
git commit -C t/$(echo $prevVersion)
fi
printf "current version: %s\n" $version