Page 4 of 6

Posted: Wed 04 Sep 2019, 08:40
by stemsee
Hi Fred

It would be nice to add renaming to the popup list menu, and save location. but renaming should be limited to the suffix or a copy, otherwise savedtexts preview wont pick it up. I say this because now I am looking for song lyrics on the internet and the quickest way to copy and save is by selecting and clicking the tray icon for translation, but they are in English and the translation is set to english so nothing gets done, which is good in this case. Howabout adding a notepad mode without translation for such use?? In which case instead of prefix 'trans' use 'note'.

stemsee

Posted: Wed 04 Sep 2019, 18:30
by fredx181
Hi stemsee, following up on your code I've made some additions/changes.
- Dialog to choose default editor (to be used when clicking 'edit')
- Close double-click menu when clicked on item (perhaps personal, for me very annoying if it stays open (needing extra click to un-focus)
- Sync content of main text-info window when edit made by using external editor.

What to with the 'copy' and 'print' option I'm not sure of.

Code: Select all

mkdir /tmp/trans_tray
function savedtranstexts (){
rm -f /tmp/trans_tray/fresh
   rm -f /tmp/trans_tray/TP
   export stxtp=/tmp/trans_tray/TP
   mkfifo -m 755 $stxtp
   exec 4<> $stxtp
   rm -f /tmp/trans_tray/PT
   export ptxts=/tmp/trans_tray/PT
   mkfifo -m 755 $ptxts
   exec 6<> $ptxts

function refresh (){
  [ -f /tmp/trans_tray/fresh ] && exit
   [ ! -f /tmp/trans_tray/fresh ] && touch /tmp/trans_tray/fresh
   while [ -e "$ptxts" ]
   do
      echo -e '\f' >$ptxts
      echo "$(for f in $HOME/.trans_tray/savedtexts/trans-*_*; do [[ -f "${f}" ]] && echo "${f##*/}"; done)" >$ptxts

sleep 2
   done
exit
}; export -f refresh

function delete (){
rm -f /tmp/trans_tray/fresh
rm -f $HOME/.trans_tray/savedtexts/$(cat /tmp/trans_tray/sel-file)
refresh &
echo -e '\f' >$stxtp
rm -f /tmp/trans_tray/sel-file
}; export -f delete

function menu_action () {
MENU_PID=$(cat /tmp/trans_tray/sttmenu_pid)
  # figure out what was selected
  case "$2" in
     "edit") kill $MENU_PID;
EDITOR=$(cat $HOME/.trans_tray/text-editor 2> /dev/null)
[ -z "$EDITOR" ] && EDITOR="internal editor"

if [ "$EDITOR" = "internal editor" ]; then
 cd "$HOME/.trans_tray/savedtexts"
             cat "$1" | yad --window-icon="/tmp/trans_tray/all.svg" --width=600 --height=400 --title="Edit: $1" --editable --text-info --listen --wrap --on-top > /tmp/Trans-Text-tmp
              if [ $? -eq 0 ]
              then
                  mv /tmp/Trans-Text-tmp "$1"
                  rm -f /tmp/Trans-Text-tmp
                  echo -e '\f' >/tmp/trans_tray/TP
                  cat  "$1" >/tmp/trans_tray/TP
                  echo -e '\n' >/tmp/trans_tray/TP
               fi
else
cd "$HOME/.trans_tray/savedtexts"
$EDITOR "$1"
       echo -e '\f' >/tmp/trans_tray/TP
       cat  "$1" >/tmp/trans_tray/TP
       echo -e '\n' >/tmp/trans_tray/TP
fi
               ;;
     "print") kill $MENU_PID; yad --text "Print action activated" --mouse $ONTOP;;
     "delete") kill $MENU_PID; bash -c delete;;
     "refresh") kill $MENU_PID; bash -c refresh;;
     "select editor") kill $MENU_PID;
 EDITOR=$(yad --center --window-icon="/tmp/trans_tray/all.svg" --title="Select editor" --form --field="Select or type texteditor:CBE" "internal editor!geany!leafpad!mousepad!gedit!kwrite!kate!joe!pluma" $ONTOP)
EDITOR="`echo $EDITOR | cut -d "|" -f 1`"
[ -z "$EDITOR" ] && exit
echo $EDITOR > $HOME/.trans_tray/text-editor;;
     "copy") kill $MENU_PID; cd "$HOME/.trans_tray/savedtexts"
      yad --window-icon="/tmp/trans_tray/all.svg" $ONTOP --mouse --file --width=600 --height=400 --save --text="Copy to location / rename";;
   esac     
}; export -f menu_action

function menu (){
   yad  --list --width=200 --height=160 --mouse \
        --column action --no-headers "delete" "edit" "refresh" "copy" "print" "select editor" \
        --close-on-unfocus $ONTOP --no-buttons --undecorated \
        --select-action="bash -c \"menu_action "$1" "%s"\"" &
 echo $! > /tmp/trans_tray/sttmenu_pid
}; export -f menu

trap "rm -f $stxtp $ptxts" EXIT

yad --plug=$$ --tabnum=1 --list --text="Double click raises menu" --item-separator=" " --listen --column="Saved Trans" \
    $(for f in $HOME/.trans_tray/savedtexts/trans-*_*; do [[ -f "${f}" ]] && echo "${f##*/}"; done) \
   --dclick-action="bash -c \"menu "%s"\"" \
    --select-action="bash -c \"echo -e '\f' >/tmp/trans_tray/TP ; cd "$HOME/.trans_tray/savedtexts" ; echo "%s" >/tmp/trans_tray/sel-file; cat  "%s" >/tmp/trans_tray/TP ; echo -e '\n' >/tmp/trans_tray/TP \"" <&6  &

yad --plug=$$ --tabnum=2 --editable --text-info --wrap --listen <&4 &

WINDOWTITLE="Saved-Texts"
yad --center --window-icon=gtk-save --width=700 --height=540 $ONTOP --no-buttons --paned --splitter=180 --key=$$ --title="$WINDOWTITLE" --tab="Selector" --tab="Preview" --orient=horizontal
exit
}; export -f savedtranstexts
EDIT: A little later edited code, refresh in delete function didn't work, works now but possibly can be improved.
EDIT2: The while loop in refresh hangs after closing the main dialog, should be killed but don't know how yet, or maybe better remove that feature.
EDIT3: Edited the code above so it shouldn't leave hanging process now (e.g. bash -c refresh while loop).

Fred

Posted: Thu 05 Sep 2019, 03:02
by stemsee
hi Fred

Better add refresh to save code! Or leave it as a manual thing.

'Print' I am looking into it.

stemsee

Posted: Thu 05 Sep 2019, 11:24
by fredx181
stemsee wrote:hi Fred

Better add refresh to save code! Or leave it as a manual thing.

'Print' I am looking into it.

stemsee
Hi stemsee, edited the code in my previous post, see at EDIT3.
Btw, I'm not sure that I like the constant refreshing, it causes flickering. IMO better without the while loop, to manually refresh.

Fred

Posted: Thu 05 Sep 2019, 13:12
by stemsee
Hi Fred

the flashing is annoying.

added to save functions because that's when refresh is needed, no need for manual refresh, unless creating files manually!!!

I know I'm getting lazy supplying code :lol:

Code: Select all

t_save () {
DATE=$(date +"%Y%m%d_%H%M%S")
. $HOME/.trans_tray/prefs
   if [ "$SAVE_CLOSE" = "TRUE" ]; then
   sayonara
   mv -f /tmp/trans_tray/run_trans_edit  $HOME/.trans_tray/savedtexts/trans-$DATE
   else
   cp -a /tmp/trans_tray/run_trans  $HOME/.trans_tray/savedtexts/trans-$DATE
   fi
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 4 --no-buttons $ONTOP
[ -e "$stxtp" && -e "$ptxts" ] && bash -c refresh
}; export -f t_save
and

Code: Select all

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
[ -e "$stxtp" && -e "$ptxts" ] && bash -c refresh
}
export -f run_trans_save
EDIT: one useful feature we should add, is the ability to have dual paned type input text from english (or some native language) with translation to say spanish (or to many), and main trans window also open translating from Spanish to English (or to many). This would be conversation/dialogue mode.

maybe in dual pane mode it could switch/reverse the two languages after pressing translate button. So to summarize, select two languages A and B. Then have the ability to translate A > B and B > A. Simultaneously in two windows or alternating in one window.

Only needs to have two different target language files/variables!

Posted: Thu 05 Sep 2019, 13:54
by stemsee
incorrect

Posted: Thu 05 Sep 2019, 19:24
by fredx181
stemsee wrote:added to save functions because that's when refresh is needed, no need for manual refresh
Yes, good idea, then refresh works for me being outside the savedtranstexts function with path to pipes (instead of variables):

Code: Select all

function refresh (){
      echo -e '\f' >/tmp/trans_tray/PT
      echo "$(for f in $HOME/.trans_tray/savedtexts/trans-*_*; do [[ -f "${f}" ]] && echo "${f##*/}"; done)" >/tmp/trans_tray/PT
}; export -f refresh
And also in save functions by using path to pipes:

Code: Select all

[[ -e "/tmp/trans_tray/TP" && -e "/tmp/trans_tray/PT" ]] && refresh
Here's attached trans_tray4 with newest experiments for testing.
Also Yandex included, but I still have my doubts about it.

Does Yandex work for anyone ?
(for me it works only 1 out of 10 times)
stemsee wrote:EDIT: one useful feature we should add, is the ability to have dual paned type input text from english (or some native language) with translation to say spanish (or to many), and main trans window also open translating from Spanish to English (or to many). This would be conversation/dialogue mode.
Sounds complicated, I'm not even sure to understand what you mean exactly :) :roll:

Fred

Posted: Fri 06 Sep 2019, 08:15
by stemsee
Scenario .... youre on facebook chatting with a tall leggy blond from China. She messages you in Chinese and you respond in Chinese. You need to translate from Chinese to English to understand her love letter, then you translate from English to Chinese to return her love interest. How many clicks does it take to achieve this right now??…….at least 20! with dual panes, each editable for input/typing, and each with its own translate to language file, each sends for translate and the returned translation appears in its own pane. so one pane is en to ch, the other is ch to en. in this mode just using translate to selection gui we accept the first two languages selected 'en ch sp', we take 'en ch' and set up the dual pane notebook.

edit: doing this on a web translator like google requires either 2 tabs or two windows.

edit2: ok, i'll start it off.

Posted: Fri 06 Sep 2019, 10:14
by stemsee
Fred

My yandex is working almost normally. it is slower than the other two, and fewer languages are supported, it seems. Did you change trans script http > https....even though it is coded to try both, better be sure?

refresh is working perfectly now!

icon changes for google+bing and google+bing+yandex (blue > red) very nice. And the yandex .svg is great!

$ONTOP|!$ONTOP is working for all windows ... very nice feature.

Posted: Fri 06 Sep 2019, 16:37
by fredx181
stemsee wrote:Scenario .... youre on facebook chatting with a tall leggy blond from China. She messages you in Chinese and you respond in Chinese. You need to translate from Chinese to English to understand her love letter,
...
...
Ah.., now I understand ! :lol:
Would be great if you can accomplish that, I guess you intent as separate entry from tray Menu ?

Yandex seems to have a limit of 2 translations per hour (first 2 always work for me, the third not, then after +/- an hour it works again)

Fred

Posted: Fri 06 Sep 2019, 23:20
by stemsee
fredx181 wrote: Ah.., now I understand ! :lol:
Would be great if you can accomplish that, I guess you intent as separate entry from tray Menu ?
I do chat with leggy blonds in China (accomplished)!! Yes menu entry is 'dialogue'.

Posted: Sat 07 Sep 2019, 17:24
by stemsee
Hi Fred

can you have a play around, as your code has to drive it. Needs run__acmd & run_bcmd. Re-use functions or rename?

Code: Select all

function trans_dialogue () {
export TLANG=$(cat $HOME/.trans_tray/.trans_target_lang2 2> /dev/null)
export _TLANG=$(cat $HOME/.trans_tray/.trans_target_lang2 2> /dev/null | awk '{print $1}' | tr '\n' '+' | sed 's/.$//')
[ -z "$TLANG" ] && export TLANG="English - en"
[ -z "$_TLANG" ] && export _TLANG="English"
export ENGINE=$(cat $HOME/.trans_tray/_trans_engine_2 2> /dev/null)
[ -z "$ENGINE" ] && ENGINE=google

export run_cmd='@bash -c "run_dtrans %1 %2"'

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

trap "rm -f $fpipe" 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_dtrans
{
    echo "3:@disable@"
export TLANG=$(cat $HOME/.trans_tray/.trans_target_lang2 2> /dev/null)
export _TLANG=$(cat $HOME/.trans_tray/.trans_target_lang2 2> /dev/null | awk '{print $1}' | tr '\n' '+' | sed 's/.$//')
[ -z "$TLANG" ] && export TLANG="English - en"
[ -z "$_TLANG" ] && export TLANG="English"
export ENGINE=$(cat $HOME/.trans_tray/_trans_engine_2 2> /dev/null)
[ -z "$ENGINE" ] && ENGINE=google
  echo -e '\f' >> "$fpipe"
[ -n "$1" ] && export TTEXT="$1" || exit
#echo "Using $ENGINE for translating"

for ex in $ENGINE
do
#echo "icon:/tmp/$ex.svg" >$PIPE
while read i; do
echo "----- $ex translate to $(echo $i | awk '{print $1}') -----"
echo -e "$TTEXT" | trans -e $ex -b -tl $(echo $i | awk '{print $NF}')
#echo ""
done <<< "$TLANG"; done | tee /tmp/trans_tray/run_trans >> "$fpipe"

    echo "3:$run_cmd"
}; export -f run_dtrans
exec 5<> $fpipe
yad --plug="$fkey" --tabnum=1 --listen --form --field="<b>Translate to English</b> :LBL" "" --field="Input/paste:TXT" ""  --field="translation:TXT" ""  --field="Translate!gtk-refresh:fbtn" "$run_cmd" <&5 &
yad --plug="$fkey" --tabnum=2 --listen --form --field="<b>Translate to Chinese</b> :LBL" "" --field="Input/paste:TXT" ""  --field="translation:TXT" ""  --field="Translate!gtk-refresh:fbtn" "$run_cmd" <&5 &
yad --key=$fkey --title="dialogue mode" --paned --tab=AB --tab=BA --orient=hori &
rm -f /tmp/trans_tray/run_trans
}; export -f trans_dialogue

Posted: Sun 08 Sep 2019, 09:52
by technosaurus
Where is the microphone icon for input / text?
Pocket Sphinx
and the speaker icon for translation?
Espeak or Flite

I had a thread with pocket sphinx continuous and associated bash helpers, but the binary itself got lost when the forum lowered the limit on file size.

Posted: Sun 08 Sep 2019, 10:09
by fredx181
Hi stemsee, attached transd1 and transd2.
For transd1 I modified your concept, (using the --cycle-read option), but not sure how to handle exactly because it reads from target language(s) set from tray menu.
So in both panes same target language(s).

Then I thought it might be better to have a dropdown combobox for to set language on top of each pane (transd2), doesn't read from target language set from tray-menu, so is in fact a standalone application.

Fred

Posted: Sun 08 Sep 2019, 10:42
by fredx181
Another experiment I've been working on earlier: strans, attached
This has a button to switch source <-> target language, perhaps useful to compare translations and easy circulate between different translations, not sure.
It identifies the source language not always correct, btw, may be confused sometimes by languages having common words.

p.s. at start it will receive input from xclip (if there is any)

Fred

Posted: Sun 08 Sep 2019, 17:05
by stemsee
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.

Posted: Mon 09 Sep 2019, 11:36
by stemsee
Im struggling to get romanisation in the results..."translit"

Posted: Mon 09 Sep 2019, 12:22
by stemsee
trans2
saveall could be both texts in one trans- file....accumulatively ' >>./trans_tray/savedtexts/trans-*'

Code: Select all

#!/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

Posted: Mon 09 Sep 2019, 12:56
by stemsee
For Fred

Saving not implemented.

edit reuploaded

surely trap * exit should be

Code: Select all

trap "rm -rf /tmp/trans_tray" EXIT

Posted: Mon 09 Sep 2019, 20:08
by fredx181
Hi stemsee, I'll try soon (but may take a few days, real life is calling atm :wink: :roll: )

Fred