Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Thu 19 Sep 2019, 09:20
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
Development of 'trans_tray' (translation program)
Post new topic   Reply to topic View previous topic :: View next topic
Page 6 of 7 [100 Posts]   Goto page: Previous 1, 2, 3, 4, 5, 6, 7 Next
Author Message
stemsee

Joined: 27 Jun 2013
Posts: 2459
Location: In The Way

PostPosted: Sun 08 Sep 2019, 13:05    Post subject:  

Hi Fred

I love the way this is expanding!

Without testing .....

But....transd2....does it autodetect input languages? Specifically needs two different input languages, and the reverse in the other pane, so cn > en, en > cn. So cycle-read is perfect because only one translation occurs at a time....and to skip a cycle just input nothing or something small for one wasted translation. Cycle read was exactly what I was thinking.

strans....looks very versatile. But changing source target language should not, IMO, clear previous texts.

stemsee

EDIT: yes, basically nailed and more!

New idea, distributive translations. Initially the idea is to write text in your native language and translate to one or many, but for each language to appear in its own independent window/gui. Later this could be piped down ssh tunnel, and we will have created a one to many languages chat app. Each receiving their own language and sending out in all other languages = group chat/news feed.
2019-09-08-192246_702x634_scrot.png
 Description   even detects unaccented pinyin! Its better than perfect!
 Filesize   54.99 KB
 Viewed   352 Time(s)

2019-09-08-192246_702x634_scrot.png

Back to top
View user's profile Send private message MSN Messenger 
stemsee

Joined: 27 Jun 2013
Posts: 2459
Location: In The Way

PostPosted: Mon 09 Sep 2019, 07:36    Post subject:  

Im struggling to get romanisation in the results..."translit"
2019-09-09-123443_723x110_scrot.png
 Description   
 Filesize   12.89 KB
 Viewed   301 Time(s)

2019-09-09-123443_723x110_scrot.png

Back to top
View user's profile Send private message MSN Messenger 
stemsee

Joined: 27 Jun 2013
Posts: 2459
Location: In The Way

PostPosted: Mon 09 Sep 2019, 08:22    Post subject:  

trans2
saveall could be both texts in one trans- file....accumulatively ' >>./trans_tray/savedtexts/trans-*'
Code:
#!/bin/bash

function trans_dialogue () {

mkdir -p $HOME/.trans_tray/{geometry,savedtexts,icons} 2> /dev/null
mkdir /tmp/trans_tray 2> /dev/null

export LANGUAGES='Afrikaans - af!Albanian - sq!Amharic - am!Arabic - ar!Armenian - hy!Azerbaijani - az!Basque - eu!Belarusian - be!Bengali - bn!Bosnian - bs!Bulgarian - bg!Cantonese - yue!Catalan - ca!Cebuano - ceb!Chichewa - ny!Chinese(Simple) - zh-CN!Chinese(Trad) - zh-TW!Corsican - co!Croatian - hr!Czech - cs!Danish - da!Dutch - nl!English - en!Esperanto - eo!Estonian - et!Fijian - fj!Filipino - tl!Finnish - fi!French - fr!Frisian - fy!Galician - gl!Georgian - ka!German - de!Greek - el!Gujarati - gu!Haitian-Creole - ht!Hausa - ha!Hawaiian - haw!Hebrew - he!Hindi - hi!Hmong - hmn!Hmong-Daw - mww!Hungarian - hu!Icelandic - is!Igbo - ig!Indonesian - id!Irish - ga!Italian - it!Japanese - ja!Javanese - jv!Kannada - kn!Kazakh - kk!Khmer - km!Klingon - tlh!Korean - ko!Kurdish - ku!Kyrgyz - ky!Lao - lo!Latin - la!Latvian - lv!Lithuanian - lt!Luxembourgish - lb!Macedonian - mk!Malagasy - mg!Malay - ms!Malayalam - ml!Maltese - mt!Maori - mi!Marathi - mr!Mongolian - mn!Myanmar - my!Nepali - ne!Norwegian - no!Pashto - ps!Persian - fa!Polish - pl!Portuguese - pt!Punjabi - pa!Queretaro-Otomi - otq!Roman - rm!Romanian - ro!Russian - ru!Samoan - sm!Scots-Gaelic - gd!Serbian(Cyr) - sr-Cyrl!Serbian(Latin) - sr-Latn!Sesotho - st!Shona - sn!Sindhi - sd!Sinhala - si!Slovak - sk!Slovenian - sl!Somali - so!Spanish - es!Sundanese - su!Swahili - sw!Swedish - sv!Tahitian - ty!Tajik - tg!Tamil - ta!Tatar - tt!Telugu - te!Thai - th!Tongan - to!Turkish - tr!Udmurt - udm!Ukrainian - uk!Urdu - ur!Uzbek - uz!Vietnamese - vi!Welsh - cy!Xhosa - xh!Yiddish - yi!Yoruba - yo!Yucatec-Maya - yua!Zulu - zu'


export run_acmd='@bash -c "run_dtrans1 %1 %2 %3 %4"'
export run_bcmd='@bash -c "run_dtrans2 %1 %2 %3 %4"'

export fpipe="/tmp/trans_tray/run_trans.$RANDOM"
mkfifo "$fpipe"
export dpipe="/tmp/trans_tray/run_trans.$RANDOM"
mkfifo "$dpipe"

trap "rm -f $fpipe $dpipe" EXIT

fkey=$(($RANDOM * $$))

function run_trans_save {
[ ! -f /tmp/trans_tray/run_trans ] && exit
DATE=$(date +"%Y%m%d_%H%M%S")
cp -a /tmp/trans_tray/run_trans  $HOME/.trans_tray/savedtexts/trans-$DATE
yad --title="Translation saved" --borders=6 --window-icon=$ICON --text="  <b>Saved to ~/.trans_tray/savedtexts/trans-$DATE </b>" --geometry=500x35-40-70 --undecorated --timeout 5 --no-buttons
bash -c refresh
}
export -f run_trans_save

function run_dtrans1
{
    echo "4:@disable@"
export TLANG1="$1"
export _TLANG1=$(echo "$1" | awk '{print $1}')
echo $TLANG1 > $HOME/.trans_tray/.trans_target_lang3
[ -z "$TLANG1" ] && export TLANG1="English - en"
[ -z "$_TLANG1" ] && export _TLANG1="English"
export ENGINE=$(cat $HOME/.trans_tray/_trans_engine_2 2> /dev/null)
[ -z "$ENGINE" ] && ENGINE=google

[ -n "$2" ] && export TTEXT="$2" || exit

# echo -e '\f' >> "$fpipe"
echo -e "$TLANG1!$LANGUAGES" >> $fpipe
echo -e ""  >> "$fpipe"

T_TEXT=$(for ex in $ENGINE
do
#echo "icon:/tmp/$ex.svg" >$PIPE
echo "----- $ex translate -----"
echo -e "$TTEXT" | trans -e $ex -b -tl $(echo $TLANG1 | awk '{print $NF}') | tee /tmp/trans_tray/run_trans; done)

T_TEXT=$(while read -r line; do printf "%s" "$line\n"; done <<< "$T_TEXT")
printf "%s\n" "$T_TEXT" >> $fpipe
 
  echo "$run_acmd" >> $fpipe
    echo "4:$run_acmd"
}; export -f run_dtrans1

function run_dtrans2
{
    echo "4:@disable@"
export TLANG2="$1"
export _TLANG2=$(echo "$1" | awk '{print $1}')
echo $TLANG2 > $HOME/.trans_tray/.trans_target_lang4
[ -z "$TLANG2" ] && export TLANG2="English - en"
[ -z "$_TLANG2" ] && export _TLANG2="English"
export ENGINE=$(cat $HOME/.trans_tray/_trans_engine_2 2> /dev/null)
[ -z "$ENGINE" ] && ENGINE=google

[ -n "$2" ] && export TTEXT="$2" || exit

#echo -e '\f' >> "$dpipe"
echo -e "$TLANG2!$LANGUAGES" >> $dpipe
echo -e ""  >> "$dpipe"
 
T_TEXT=$(for ex in $ENGINE
do
#echo "icon:/tmp/$ex.svg" >$PIPE
echo "----- $ex translate -----"
echo -e "$TTEXT" | trans -e $ex -b -tl $(echo $TLANG2 | awk '{print $NF}') | tee /tmp/trans_tray/run_trans; done)

T_TEXT=$(while read -r line; do printf "%s" "$line\n"; done <<< "$T_TEXT")
printf "%s\n" "$T_TEXT" >> $dpipe
 
  echo "$run_bcmd" >> $dpipe
    echo "4:$run_bcmd"
}; export -f run_dtrans2

clear_all () {
echo -e '\f' > $fpipe
TLANG=$(cat $HOME/.trans_tray/.trans_target_lang3 2> /dev/null)
[ -z "$TLANG" ] && export TLANG="English - en"
echo -e "$TLANG!$LANGUAGES"  >> $fpipe
echo -e ""  >> $fpipe
echo -e ""  >> $fpipe
   echo "$run_acmd" >> $fpipe

   echo -e "\f"  >> $dpipe
TLANG=$(cat $HOME/.trans_tray/.trans_target_lang4 2> /dev/null)
[ -z "$TLANG" ] && export TLANG="English - en"
echo -e "$TLANG!$LANGUAGES"  >> $dpipe
echo -e ""  >> $dpipe
echo -e ""  >> $dpipe
   echo "$run_bcmd" >> $dpipe

}; export -f clear_all
clearAB (){

   echo -e '\f' > $fpipe
TLANG=$(cat $HOME/.trans_tray/.trans_target_lang3 2> /dev/null)
[ -z "$TLANG" ] && export TLANG="English - en"
echo -e "$TLANG!$LANGUAGES"  >> $fpipe
echo -e ""  >> $fpipe
echo -e ""  >> $fpipe
   echo "$run_acmd" >> $fpipe
}; export -f clearAB
ClearBA (){
   echo -e "\f"  >> $dpipe
TLANG=$(cat $HOME/.trans_tray/.trans_target_lang4 2> /dev/null)
[ -z "$TLANG" ] && export TLANG="English - en"
echo -e "$TLANG!$LANGUAGES"  >> $dpipe
echo -e ""  >> $dpipe
echo -e ""  >> $dpipe
   echo "$run_bcmd" >> $dpipe
}; export -f ClearBA
export TLANG1=$(cat $HOME/.trans_tray/.trans_target_lang3 2> /dev/null)
export _TLANG1=$(cat $HOME/.trans_tray/.trans_target_lang3 2> /dev/null | awk '{print $1}')
[ -z "$TLANG1" ] && export TLANG1="English - en"
[ -z "$_TLANG1" ] && export _TLANG1="English"

export TLANG2=$(cat $HOME/.trans_tray/.trans_target_lang4 2> /dev/null)
export _TLANG2=$(cat $HOME/.trans_tray/.trans_target_lang4 2> /dev/null | awk '{print $1}')
[ -z "$TLANG2" ] && export TLANG2="English - en"
[ -z "$_TLANG2" ] && export _TLANG2="English"

exec 5<> $fpipe
exec 6<> $dpipe

echo -e '\f' >&5
echo -e "$TLANG1!$LANGUAGES" >> $fpipe
echo -e "" >&5
echo -e "" >&5
echo "$run_acmd" >&5

echo -e '\f' >&6
echo -e "$TLANG2!$LANGUAGES" >> $dpipe
echo -e "" >&6
echo -e "" >&6
echo "$run_bcmd" >&6

yad --plug="$fkey" --tabnum=1 --listen --form --cycle-read --field="Target language:CB" --field="Input/paste:TXT"  --field="translation:TXT"  --field="Translate!gtk-refresh:fbtn" <&5 &

yad --plug="$fkey" --tabnum=2 --listen --form --cycle-read --field="Target language:CB" --field="Input/paste:TXT"  --field="translation:TXT"  --field="Translate!gtk-refresh:fbtn" <&6 &
yad --key=$fkey --title="dialogue mode" --width=700 --height=600 --paned --tab=AB --tab=BA --orient=hori --button="SaveAB:bash -c saveAB" --button="ClearAB:bash -c clearAB"  --button="SaveBA:bash -c saveBA" --button="ClearBA:bash -c ClearBA" --button="SaveAll:bash -c saveall" --button="Clear All!gtk-clear:bash -c clear_all" --button="Close!gtk-close:1"
#rm -f /tmp/trans_tray/run_trans
}; export -f trans_dialogue

trans_dialogue
2019-09-09-132213_719x634_scrot.png
 Description   
 Filesize   53.28 KB
 Viewed   295 Time(s)

2019-09-09-132213_719x634_scrot.png

Back to top
View user's profile Send private message MSN Messenger 
stemsee

Joined: 27 Jun 2013
Posts: 2459
Location: In The Way

PostPosted: Mon 09 Sep 2019, 08:56    Post subject:  

For Fred

Saving not implemented.

edit reuploaded

surely trap * exit should be
Code:
trap "rm -rf /tmp/trans_tray" EXIT
TT5.sfs.gz
Description 
gz

 Download 
Filename  TT5.sfs.gz 
Filesize  84 KB 
Downloaded  12 Time(s) 
Back to top
View user's profile Send private message MSN Messenger 
fredx181


Joined: 11 Dec 2013
Posts: 4088
Location: holland

PostPosted: Mon 09 Sep 2019, 16:08    Post subject:  

Hi stemsee, I'll try soon (but may take a few days, real life is calling atm Wink Rolling Eyes )

Fred

_________________
Dog Linux website
Tinylinux blog by wiak
Back to top
View user's profile Send private message 
stemsee

Joined: 27 Jun 2013
Posts: 2459
Location: In The Way

PostPosted: Mon 09 Sep 2019, 16:14    Post subject:  

hi Fred

One important thing......trans2, really needs to be able to select keyboard layout for each pane, or system.

stemsee
Back to top
View user's profile Send private message MSN Messenger 
fredx181


Joined: 11 Dec 2013
Posts: 4088
Location: holland

PostPosted: Tue 10 Sep 2019, 15:56    Post subject:  

Hi stemsee,
OK. I will add the save options for the dialogue mode and merge with the main script.

Quote:
One important thing......trans2, really needs to be able to select keyboard layout for each pane, or system.

Any ideas how ?
I'm not sure btw if that should be part of the program.

Fred

_________________
Dog Linux website
Tinylinux blog by wiak
Back to top
View user's profile Send private message 
stemsee

Joined: 27 Jun 2013
Posts: 2459
Location: In The Way

PostPosted: Tue 10 Sep 2019, 18:56    Post subject:  

Hi Fred

Of course system wide keyboard layouts should be setup with key combos to switch. But for temporary changes we could use
Code:
setxkbmap us


Simple keyboard layout selector.

Only select to choose and leave open.
Code:
export KBD='us              USA
gb              United Kingdom
pt              Portugal
es              Spain
nl              Netherlands
dk              Denmark
cn              China
ca              Canada
fr              France
de              Germany
gr              Greece
it              Italy
jp              Japan
se              Sweden
ch              Switzerland
fi              Finland
no              Norway
pl              Poland
ro              Romania
ru              Russia
hu              Hungary
is              Iceland
il              Israel
br              Brazil
ad              Andorra
af              Afghanistan
ara             Arabic
al              Albania
am              Armenia
az              Azerbaijan
by              Belarus
be              Belgium
bd              Bangladesh
in              India
ba              Bosnia and Herzegovina
bg              Bulgaria
ma              Morocco
mm              Myanmar
cd              Congo, Democratic Republic of the
cz              Czechia
hr              Croatia
ge              Georgia
bt              Bhutan
ee              Estonia
ir              Iran
iq              Iraq
fo              Faroe Islands
gh              Ghana
gn              Guinea
kg              Kyrgyzstan
kh              Cambodia
kz              Kazakhstan
la              Laos
latam           Latin American
lt              Lithuania
lv              Latvia
mao             Maori
me              Montenegro
mk              Macedonia
mt              Malta
mn              Mongolia
rs              Serbia
si              Slovenia
sk              Slovakia
sy              Syria
tj              Tajikistan
lk              Sri Lanka
th              Thailand
tr              Turkey
tw              Taiwan
ua              Ukraine
uz              Uzbekistan
vn              Vietnam
kr              Korea, Republic of
nec_vndr/jp     Japan (PC-98xx Series)
ie              Ireland
pk              Pakistan
mv              Maldives
za              South Africa
epo             Esperanto
np              Nepal
ng              Nigeria
et              Ethiopia
sn              Senegal
brai            Braille
tm              Turkmenistan
ml              Mali
tz              Tanzania'
echo "$KBD" | yad --window-icon=/tmp/trans_tray/all.svg --on-top --no-focus \
--item-separator=" " --geometry=80x600+10+40 --title="Keyboard Layout" \
--list --column="Select to Change" --select-action="bash -c 'setxkbmap $(echo "%s" | cut -f1 -d' ')'" &

Last edited by stemsee on Tue 10 Sep 2019, 23:11; edited 1 time in total
Back to top
View user's profile Send private message MSN Messenger 
stemsee

Joined: 27 Jun 2013
Posts: 2459
Location: In The Way

PostPosted: Tue 10 Sep 2019, 22:41    Post subject:  

فقشىسé
екфты2
trans2
Code:
#!/bin/bash

function trans_dialogue () {
mkdir -p $HOME/.trans_tray/{geometry,savedtexts,icons} 2> /dev/null
mkdir /tmp/trans_tray 2> /dev/null

export LANGUAGES='Afrikaans - af!Albanian - sq!Amharic - am!Arabic - ar!Armenian - hy!Azerbaijani - az!Basque - eu!Belarusian - be!Bengali - bn!Bosnian - bs!Bulgarian - bg!Cantonese - yue!Catalan - ca!Cebuano - ceb!Chichewa - ny!Chinese(Simple) - zh-CN!Chinese(Trad) - zh-TW!Corsican - co!Croatian - hr!Czech - cs!Danish - da!Dutch - nl!English - en!Esperanto - eo!Estonian - et!Fijian - fj!Filipino - tl!Finnish - fi!French - fr!Frisian - fy!Galician - gl!Georgian - ka!German - de!Greek - el!Gujarati - gu!Haitian-Creole - ht!Hausa - ha!Hawaiian - haw!Hebrew - he!Hindi - hi!Hmong - hmn!Hmong-Daw - mww!Hungarian - hu!Icelandic - is!Igbo - ig!Indonesian - id!Irish - ga!Italian - it!Japanese - ja!Javanese - jv!Kannada - kn!Kazakh - kk!Khmer - km!Klingon - tlh!Korean - ko!Kurdish - ku!Kyrgyz - ky!Lao - lo!Latin - la!Latvian - lv!Lithuanian - lt!Luxembourgish - lb!Macedonian - mk!Malagasy - mg!Malay - ms!Malayalam - ml!Maltese - mt!Maori - mi!Marathi - mr!Mongolian - mn!Myanmar - my!Nepali - ne!Norwegian - no!Pashto - ps!Persian - fa!Polish - pl!Portuguese - pt!Punjabi - pa!Queretaro-Otomi - otq!Roman - rm!Romanian - ro!Russian - ru!Samoan - sm!Scots-Gaelic - gd!Serbian(Cyr) - sr-Cyrl!Serbian(Latin) - sr-Latn!Sesotho - st!Shona - sn!Sindhi - sd!Sinhala - si!Slovak - sk!Slovenian - sl!Somali - so!Spanish - es!Sundanese - su!Swahili - sw!Swedish - sv!Tahitian - ty!Tajik - tg!Tamil - ta!Tatar - tt!Telugu - te!Thai - th!Tongan - to!Turkish - tr!Udmurt - udm!Ukrainian - uk!Urdu - ur!Uzbek - uz!Vietnamese - vi!Welsh - cy!Xhosa - xh!Yiddish - yi!Yoruba - yo!Yucatec-Maya - yua!Zulu - zu'
export run_acmd='@bash -c "run_dtrans1 %1 %2 %3 %4"'
export run_bcmd='@bash -c "run_dtrans2 %1 %2 %3 %4"'
export fpipe="/tmp/trans_tray/run_trans.$RANDOM"
export KBD='us              USA
gb              United Kingdom
pt              Portugal
es              Spain
nl              Netherlands
dk              Denmark
cn              China
ca              Canada
fr              France
de              Germany
gr              Greece
it              Italy
jp              Japan
se              Sweden
ch              Switzerland
fi              Finland
no              Norway
pl              Poland
ro              Romania
ru              Russia
hu              Hungary
is              Iceland
il              Israel
br              Brazil
ad              Andorra
af              Afghanistan
ara             Arabic
al              Albania
am              Armenia
az              Azerbaijan
by              Belarus
be              Belgium
bd              Bangladesh
in              India
ba              Bosnia and Herzegovina
bg              Bulgaria
ma              Morocco
mm              Myanmar
cd              Congo, Democratic Republic of the
cz              Czechia
hr              Croatia
ge              Georgia
bt              Bhutan
ee              Estonia
ir              Iran
iq              Iraq
fo              Faroe Islands
gh              Ghana
gn              Guinea
kg              Kyrgyzstan
kh              Cambodia
kz              Kazakhstan
la              Laos
latam           Latin American
lt              Lithuania
lv              Latvia
mao             Maori
me              Montenegro
mk              Macedonia
mt              Malta
mn              Mongolia
rs              Serbia
si              Slovenia
sk              Slovakia
sy              Syria
tj              Tajikistan
lk              Sri Lanka
th              Thailand
tr              Turkey
tw              Taiwan
ua              Ukraine
uz              Uzbekistan
vn              Vietnam
kr              Korea, Republic of
nec_vndr/jp     Japan (PC-98xx Series)
ie              Ireland
pk              Pakistan
mv              Maldives
za              South Africa
epo             Esperanto
np              Nepal
ng              Nigeria
et              Ethiopia
sn              Senegal
brai            Braille
tm              Turkmenistan
ml              Mali
tz              Tanzania'
echo "$KBD" | yad --window-icon=/tmp/trans_tray/all.svg --on-top --no-focus \
--item-separator=" " --geometry=100x600+10+40 --title="Keyboard Layout" \
--list --column="Select to Change" --no-buttons $ONTOP --select-action="bash -c 'setxkbmap $(echo "%s" | cut -f1 -d' ')'" &

mkfifo "$fpipe"
export dpipe="/tmp/trans_tray/run_trans.$RANDOM"
mkfifo "$dpipe"
trap "rm -f $fpipe $dpipe" EXIT
fkey=$(($RANDOM * $$))
function run_trans_save {
[ ! -f /tmp/trans_tray/run_trans ] && exit
DATE=$(date +"%Y%m%d_%H%M%S")
cp -a /tmp/trans_tray/run_trans  $HOME/.trans_tray/savedtexts/trans-$DATE
yad --title="Translation saved" --borders=6 --window-icon=$ICON --text="  <b>Saved to ~/.trans_tray/savedtexts/trans-$DATE </b>" --geometry=500x35-40-70 --undecorated --timeout 5 --no-buttons
bash -c refresh
}
export -f run_trans_save

function run_dtrans1
{
    echo "4:@disable@"
export TLANG1="$1"
export _TLANG1=$(echo "$1" | awk '{print $1}')
echo $TLANG1 > $HOME/.trans_tray/.trans_target_lang3
[ -z "$TLANG1" ] && export TLANG1="English - en"
[ -z "$_TLANG1" ] && export _TLANG1="English"
export ENGINE=$(cat $HOME/.trans_tray/_trans_engine_2 2> /dev/null)
[ -z "$ENGINE" ] && ENGINE=google

[ -n "$2" ] && export TTEXT="$2" || exit

# echo -e '\f' >> "$fpipe"
echo -e "$TLANG1!$LANGUAGES" >> $fpipe
echo -e ""  >> "$fpipe"

T_TEXT=$(for ex in $ENGINE
do
#echo "icon:/tmp/$ex.svg" >$PIPE
echo "----- $ex translate -----"
echo -e "$TTEXT" | trans -e $ex -b -tl $(echo $TLANG1 | awk '{print $NF}') | tee /tmp/trans_tray/run_trans; done)

T_TEXT=$(while read -r line; do printf "%s" "$line\n"; done <<< "$T_TEXT")
printf "%s\n" "$T_TEXT" >> $fpipe
 
  echo "$run_acmd" >> $fpipe
    echo "4:$run_acmd"
}; export -f run_dtrans1

function run_dtrans2
{
    echo "4:@disable@"
export TLANG2="$1"
export _TLANG2=$(echo "$1" | awk '{print $1}')
echo $TLANG2 > $HOME/.trans_tray/.trans_target_lang4
[ -z "$TLANG2" ] && export TLANG2="English - en"
[ -z "$_TLANG2" ] && export _TLANG2="English"
export ENGINE=$(cat $HOME/.trans_tray/_trans_engine_2 2> /dev/null)
[ -z "$ENGINE" ] && ENGINE=google

[ -n "$2" ] && export TTEXT="$2" || exit

#echo -e '\f' >> "$dpipe"
echo -e "$TLANG2!$LANGUAGES" >> $dpipe
echo -e ""  >> "$dpipe"
 
T_TEXT=$(for ex in $ENGINE
do
#echo "icon:/tmp/$ex.svg" >$PIPE
echo "----- $ex translate -----"
echo -e "$TTEXT" | trans -e $ex -b -tl $(echo $TLANG2 | awk '{print $NF}') | tee /tmp/trans_tray/run_trans; done)

T_TEXT=$(while read -r line; do printf "%s" "$line\n"; done <<< "$T_TEXT")
printf "%s\n" "$T_TEXT" >> $dpipe
 
  echo "$run_bcmd" >> $dpipe
    echo "4:$run_bcmd"
}; export -f run_dtrans2

clear_all () {
echo -e '\f' > $fpipe
TLANG=$(cat $HOME/.trans_tray/.trans_target_lang3 2> /dev/null)
[ -z "$TLANG" ] && export TLANG="English - en"
echo -e "$TLANG!$LANGUAGES"  >> $fpipe
echo -e ""  >> $fpipe
echo -e ""  >> $fpipe
   echo "$run_acmd" >> $fpipe

   echo -e "\f"  >> $dpipe
TLANG=$(cat $HOME/.trans_tray/.trans_target_lang4 2> /dev/null)
[ -z "$TLANG" ] && export TLANG="English - en"
echo -e "$TLANG!$LANGUAGES"  >> $dpipe
echo -e ""  >> $dpipe
echo -e ""  >> $dpipe
   echo "$run_bcmd" >> $dpipe

}; export -f clear_all
clearAB (){

   echo -e '\f' > $fpipe
TLANG=$(cat $HOME/.trans_tray/.trans_target_lang3 2> /dev/null)
[ -z "$TLANG" ] && export TLANG="English - en"
echo -e "$TLANG!$LANGUAGES"  >> $fpipe
echo -e ""  >> $fpipe
echo -e ""  >> $fpipe
   echo "$run_acmd" >> $fpipe
}; export -f clearAB
ClearBA (){
   echo -e "\f"  >> $dpipe
TLANG=$(cat $HOME/.trans_tray/.trans_target_lang4 2> /dev/null)
[ -z "$TLANG" ] && export TLANG="English - en"
echo -e "$TLANG!$LANGUAGES"  >> $dpipe
echo -e ""  >> $dpipe
echo -e ""  >> $dpipe
   echo "$run_bcmd" >> $dpipe
}; export -f ClearBA
export TLANG1=$(cat $HOME/.trans_tray/.trans_target_lang3 2> /dev/null)
export _TLANG1=$(cat $HOME/.trans_tray/.trans_target_lang3 2> /dev/null | awk '{print $1}')
[ -z "$TLANG1" ] && export TLANG1="English - en"
[ -z "$_TLANG1" ] && export _TLANG1="English"

export TLANG2=$(cat $HOME/.trans_tray/.trans_target_lang4 2> /dev/null)
export _TLANG2=$(cat $HOME/.trans_tray/.trans_target_lang4 2> /dev/null | awk '{print $1}')
[ -z "$TLANG2" ] && export TLANG2="English - en"
[ -z "$_TLANG2" ] && export _TLANG2="English"

exec 5<> $fpipe
exec 6<> $dpipe

#echo -e '\f' >&5
echo -e "$TLANG1!$LANGUAGES" >> $fpipe
echo -e "" >&5
echo -e "" >&5
echo "$run_acmd" >&5

#echo -e '\f' >&6
echo -e "$TLANG2!$LANGUAGES" >> $dpipe
echo -e "" >&6
echo -e "" >&6
echo "$run_bcmd" >&6

yad --plug="$fkey" --tabnum=1 --listen --form --cycle-read --field="Target language:CB" --field="Input/paste:TXT"  --field="translation:TXT"  --field="Translate!gtk-refresh:fbtn" <&5 &
yad --plug="$fkey" --tabnum=2 --listen --form --cycle-read --field="Target language:CB" --field="Input/paste:TXT"  --field="translation:TXT"  --field="Translate!gtk-refresh:fbtn" <&6 &
yad --key=$fkey --title="dialogue mode" --width=700 --height=600 --paned --tab=AB --tab=BA --orient=hori --button="SaveAB:bash -c saveAB" --button="ClearAB:bash -c clearAB"  --button="SaveBA:bash -c saveBA" --button="ClearBA:bash -c ClearBA" --button="SaveAll:bash -c saveall" --button="ClearAll!gtk-clear:bash -c clear_all" --button="Close!gtk-close:1"
#rm -f /tmp/trans_tray/run_trans
}; export -f trans_dialogue

trans_dialogue
2019-09-11-035706_347x708_scrot.png
 Description   
 Filesize   52.65 KB
 Viewed   219 Time(s)

2019-09-11-035706_347x708_scrot.png

Back to top
View user's profile Send private message MSN Messenger 
fredx181


Joined: 11 Dec 2013
Posts: 4088
Location: holland

PostPosted: Wed 11 Sep 2019, 09:50    Post subject:  

Hi stemsee, thanks, how about adding the keyboard-layout GUI to the tray menu ?
And can you give example(s) when it's needed for you to change keyboard-layout ?
e_èdit nevermind je comprend stemçềè Smile

Fred

_________________
Dog Linux website
Tinylinux blog by wiak

Last edited by fredx181 on Wed 11 Sep 2019, 11:09; edited 1 time in total
Back to top
View user's profile Send private message 
vovchik


Joined: 23 Oct 2006
Posts: 1504
Location: Ukraine

PostPosted: Wed 11 Sep 2019, 09:55    Post subject:  

Dear fredx181 and stemsee,

Great idea. I would also save the system layout first, e.g.:

Code:
LAYOUTS=$(setxkbmap -query | grep layout | cut -d' ' -f6)


and restore afterwards or have a button:

Code:
setxkbmap -option grp:lalt_lshift_toggle "$LAYOUTS"


What do you think?

With kind regards,
vovchik
Back to top
View user's profile Send private message 
fredx181


Joined: 11 Dec 2013
Posts: 4088
Location: holland

PostPosted: Wed 11 Sep 2019, 11:16    Post subject:  

Hi vovchik, yes good idea to save and restore system layout, thanks !

Fred

_________________
Dog Linux website
Tinylinux blog by wiak
Back to top
View user's profile Send private message 
fredx181


Joined: 11 Dec 2013
Posts: 4088
Location: holland

PostPosted: Wed 11 Sep 2019, 11:59    Post subject:  

So far I have kb-layout as script (attached), at start it saves the system layout and when closing the window it will be restored.
(so this means that the window needs to stay open to preserve the chosen layout)
I'm uncertain how to handle this, maybe better to save the layout at start of trans_tray (and also restore when exiting trans_tray.

Fred
2019-09-11-175218_552x703_scrot_452x576.png
 Description   
 Filesize   208.34 KB
 Viewed   167 Time(s)

2019-09-11-175218_552x703_scrot_452x576.png

kb-layout.gz
Description  fake .gz
gz

 Download 
Filename  kb-layout.gz 
Filesize  1.68 KB 
Downloaded  12 Time(s) 

_________________
Dog Linux website
Tinylinux blog by wiak
Back to top
View user's profile Send private message 
stemsee

Joined: 27 Jun 2013
Posts: 2459
Location: In The Way

PostPosted: Wed 11 Sep 2019, 20:53    Post subject:  

Hi all

With trans2, there could be switching between two layouts and these should always appear at the top of the keyboard layouts list ($layoutab, $layoutba) for easy switching....maybe we could implement in'app keycodes for switching between the two more quickly. And remember the two selected layouts across reboots, aswell as restoring system defaults in /etc

adding to preferences to start with paned dialogue and strans, or manually as part of a popup menu, maybe is a good idea-

trans_tray starts and ends with my X, so it needs to start and restore with opening ad closing of keyboard layout gui, imo. EDIT yes, as you have it already is perfect.

Also, on my system, some of the layouts in the list do not seem to work!

I hope we can make a definitive list of layout codes including variations.....future proofing....or add code to let the user edit the list to change order of layouts according to their preferences.

stemsee
Back to top
View user's profile Send private message MSN Messenger 
fredx181


Joined: 11 Dec 2013
Posts: 4088
Location: holland

PostPosted: Thu 12 Sep 2019, 13:50    Post subject:  

Hi All, here's new trans_tray (5), some additions and changes:

- Added "Dialogue mode" to menu, for easy translating to two different languages, side by side. (thanks stemsee)
- Added to Preferences: choice for texteditor and switch for showing keyboard-layout variants.
(see also below)
- Added "Set keyboard layout" to menu, default is a standard list, but can be changed in Preferences to a list of "variants". (thanks stemsee and vovchik)
- Translate webpage will now remember which browser used last time
EDIT: And added to saved-texts option "rename"

@stemsee
Quote:
With trans2, there could be switching between two layouts and these should always appear at the top of the keyboard layouts list ($layoutab, $layoutba) for easy switching....maybe we could implement in'app keycodes for switching between the two more quickly. And remember the two selected layouts across reboots, aswell as restoring system defaults in /etc


Didn't became that convenient as you suggested (I think you'd like to see setting keyboard-layout to be part of the Dialogue GUI), but anyway it's a start (can always be changed to different construction).
It does remember last used, btw (shows on top of list next time).

Fred
trans_tray5.gz
Description  fake .gz
gz

 Download 
Filename  trans_tray5.gz 
Filesize  78.31 KB 
Downloaded  12 Time(s) 

_________________
Dog Linux website
Tinylinux blog by wiak
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 6 of 7 [100 Posts]   Goto page: Previous 1, 2, 3, 4, 5, 6, 7 Next
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.1343s ][ Queries: 13 (0.0077s) ][ GZIP on ]