Re: Language selection tool
Posted: 04 Oct 2016, 01:49
Code: Select all
$ ./tr-pot.sh file-to-translate.pot pt
$ ./tr-pot.sh file-to-translate.pot pt -m
english: Development locales
current: locais de desenvolvimento
change?
english: You files: /tmp/language-files
current: Você arquivos: / tmp / língua-files
change? y
pt text? Seus arquivos: /tmp/language-files
May you share your script? I feel it may help to get people translating (also a translation needed/wanted listbrokenman wrote:I have a script here I use for auto translations, but inevitably the files need a human eye.
Code: Select all
#!/bin/bash
# Script to auto translate msgstr "" tags in a .po file
# using google translator
#
# Run this script with the argument file.po
# Example: script.sh myfile.po
# Author: brokenman <brokenman@porteus.org
# Date: Jan 2013
L1=$2
L2=$3
[ $# -ne 3 ] && { echo "You need two arguments. $0 file.po en pt"; exit; }
! which trans && { echo "You need to download trans. wget git.io/trans"; exit; }
translate(){
#/usr/local/bin/trans -shell -brief -s $L2 -t $L3 "$EN" | tail -n1
trans -b :${L2} "$EN"
}
[ -z $1 ] && { echo; echo "You must supply a .po file!"; exit; }
SAVEIFS=$IFS
IFS=$(echo -en "\n\b")
for a in `grep -rne msgid $1`; do
EN=`awk -F'"' '{print$2}' <<<$a`
if [[ -z $EN ]]; then continue; fi
echo -e "Translating \""$EN"\""
declare -i NUMBER=`awk -F: '{print$1}' <<<$a`
(( NUMBER++ ))
TR=`translate "$EN"`
echo "$TR"
sed -i "$NUMBER s|\"\"|\"$TR\"|" $1
unset ID EN TR NUMBER
done
IFS=$SAVEIFS
I think this should read:brokenman wrote:Code: Select all
# Run this script with the argument file.po # Example: script.sh myfile.po [...] [ $# -ne 3 ] && { echo "You need two arguments. $0 file.po en pt"; exit; }
Code: Select all
# Run this script with the arguments infile.po outfile.po
# Example: script.sh myfile.po english.po
Code: Select all
# Run this script with the arguments infile.po <L1> <L2> (Where L1 is first language and L2 is target language)
# Example: script.sh myfile.po en pt
Code: Select all
echo Examples:
echo script.sh myfile.po en pt
echo Translate myfile.po from English into Portuguese
echo
echo script.sh myfile.po de en
echo Translate myfile.po from German into English
echo
echo Cave! Know that Google Translate always translates into English first, then into the target language, therefore often the translation gets bad when the target (or source) language is not English. Often if you are apt in English, use English as target language and translate manually from there.
Code: Select all
echo "Cave! Know that Google Translate always translates into English first, then into the target language, therefore often the translation gets bad when the target (or source) language is not English. Often if you are "|fold -sw 80
Code: Select all
export COLUMNS
And hopefully that will included in the final version?brokenman wrote:Thanks Rava. I've added the suggestion lines to my local copy.
If Porteus, by default, exports the COLUMNS, then all scripts running with Porteus could use that info. Of course that means that the script writers have to know about it, but if they do, many users would appreciate it, since many people use >80 columns, me thinks...brokenman wrote:Do you suggest that it ships with Porteus?
I want it system-wide exported.brokenman wrote:Now I'm confused. Are you talking about including the script in Porteus or just exporting the variable system wide? I disagree with exporting the COLUMN variable as this is a thing many coders want to set for themselves.