YAD - Tips
Create a continuous digital clock
Hello misko_2083,
your code works great.
Thank you for your help!
achim
your code works great.
Thank you for your help!
achim
Hi stemsee, good luck with the notebook version, don't think I can help, didn't do much with that.
Fred
Yes, would be much better, also I like showing the full language names, so made the "trans_paste" function this(see pic):Also the
Code:
echo -----^$ex $i^-----
should be at the head instead of underlining each translation in case of a large body of text.
Code:
echo -----$ex $i-----
Code: Select all
trans_paste () {
#set -x
export TLANG=$(cat $HOME/.trans_target_lang2 2> /dev/null)
export _TLANG=$(cat $HOME/.trans_target_lang2 2> /dev/null | awk '{print $1}' | tr '\n' '+' | sed 's/.$//')
[ -z "$TLANG" ] && export TLANG="English - en"
export ENGINE=$(cat /tmp/_trans_engine_ 2> /dev/null)
[ -z "$ENGINE" ] && ENGINE=google
echo "Using $ENGINE for translating"
ICON="/tmp/trans-paste.svg"
if [ ! -e "$ICON" ]; then
SVG="<""svg height='100' width='100'>
<path style='fill:red;stroke:darkred;stroke-width:3;'
d='M 93,62 C 83,82 65,96 48,96 32,96 19,89 15,79 L 5,90 5,53
40,53 29,63 c 0,0 5,14 26,14 16,0 38,-15 38,-15 z'/>
<path style='fill:red;stroke:darkred;stroke-width:3;'
d='M 5,38 C 11,18 32,4 49,4 65,4 78,11 85,21 L 95,10 95,47
57,47 68,37 C 68,37 63,23 42,23 26,23 5,38 5,38 z'/>
</svg>"
echo "$SVG" > /tmp/trans-paste.svg
fi
HELP=" Translating to $_TLANG... \n Press <b>ESC</b> key or click <b>EXIT</b> to dismiss."
MYTITLE="Trans"
BUT="<span color='darkblue'><b>Exit</b></span>"
FONT="Mono 12"
TWIDTH=$(xdpyinfo | grep 'dimensions:' | cut -d' ' -f7 | cut -d'x' -f1)
SWIDTH=$(( $TWIDTH - 600 ))
#echo $SWIDTH
for ex in $ENGINE
do
while read i; do
echo " > $ex translation to $(echo $i | awk '{print $1}'):"
xclip -o | trans -e $ex -b -tl $(echo $i | awk '{print $NF}')
done <<< "$TLANG"; done | tee >(yad \
--window-icon="$ICON" \
--text-align=center \
--title="$MYTITLE" \
--geometry=600x600+$SWIDTH+100 \
--fore="black" --back="#fef1e0" \
--margins=5 \
--button="$BUT" \
--text="$HELP" \
--fontname="$FONT" \
--text-info --wrap)
}
export -f trans_paste
- Attachments
-
- 2019-08-22-143328_600x629_scrot.png
- (61.75 KiB) Downloaded 325 times
Hi Fred
Is it possible to make the headings a different text color? If not I prefer the previous style!
The new code is difficult to understand, for me!
However _ _ _ _ _ Each to their own_ _ _ _ _
stemsee
EDIT: I just discovered that google web translate has a character limit of about 3900! Maybe the script could be made to chunk xclip data accordingly?
Is it possible to make the headings a different text color? If not I prefer the previous style!
The new code is difficult to understand, for me!
However _ _ _ _ _ Each to their own_ _ _ _ _
stemsee
EDIT: I just discovered that google web translate has a character limit of about 3900! Maybe the script could be made to chunk xclip data accordingly?
I'm almost sure that's not possible with the --text-info dialog. (e.g.cannot use <span...> etc..), but correct me if I'm wrong.stemsee wrote:Is it possible to make the headings a different text color? If not I prefer the previous style!
What exactly do you prefer then as "previous style" ?
EDIT:
Mmm.. that's a pity, not sure yet how to handle that.EDIT: I just discovered that google web translate has a character limit of about 3900! Maybe the script could be made to chunk xclip data accordingly?
BTW, I think it's better to remove Yandex from the translator choices, it really doesn't work well.
Fred
- misko_2083
- Posts: 114
- Joined: Tue 08 Nov 2016, 13:42
Depends on the moment.
how about html?fredx181 wrote:I'm almost sure that's not possible with the --text-info dialog. (e.g.cannot use <span...> etc..), but correct me if I'm wrong.stemsee wrote:Is it possible to make the headings a different text color? If not I prefer the previous style!
What exactly do you prefer then as "previous style" ?
EDIT:EDIT: I just discovered that google web translate has a character limit of about 3900! Maybe the script could be made to chunk xclip data accordingly?
Code: Select all
echo "<h3>heading</h3><font color=red>some text</font>" | yad --html
Hi Fred, Misko et al
yad --html sounds like an interesting development!
by previous I meant the middle style.... not just _ _ _ _ dashes, but with $ex $i and placed as heading of translated text. I found that my eyes could more easily search and find each translated language section. but that's just my experience.
Indeed remove yandex ... maybe replace?? ... DeepL...?
stemsee
yad --html sounds like an interesting development!
by previous I meant the middle style.... not just _ _ _ _ dashes, but with $ex $i and placed as heading of translated text. I found that my eyes could more easily search and find each translated language section. but that's just my experience.
Indeed remove yandex ... maybe replace?? ... DeepL...?
stemsee
Ok, thanks, never did anything with the yad --html option, I think the compiled yad has to be configured with that, most yad packages (for e.g. Puppy or others) don't have this option by default, I think.misko wrote:how about html? Smile
Code:
echo "<h3>heading</h3><font color=red>some text</font>" | yad --html
@stemsee
Not so difficult in fact, to explain:The new code is difficult to understand, for me!
At start of function:
Code: Select all
export TLANG=$(cat $HOME/.trans_target_lang2 2> /dev/null)
And further on:
Code: Select all
while read i; do
echo " > $ex translation to $(echo $i | awk '{print $1}'):"
xclip -o | trans -e $ex -b -tl $(echo $i | awk '{print $NF}')
done <<< "$TLANG";
and the locale code to be used by trans, e.g. es : trans -e $ex -b -tl $(echo $i | awk '{print $NF}')
EDIT:
Ok, but how would you prefer exactly then as header, something like (or.. ?):by previous I meant the middle style.... not just _ _ _ _ dashes, but with $ex $i and placed as heading of translated text. I found that my eyes could more easily search and find each translated language section. but that's just my experience.
----- google translate to Bulgarian -----
I think deepl isn't supported by trans anymore.
Fred
Last edited by fredx181 on Thu 22 Aug 2019, 15:44, edited 1 time in total.
in the trans script find google and change http: to https: problem solved.
Code: Select all
function googleInit() {
HttpProtocol = "https://"
HttpHost = "translate.googleapis.com"
HttpPort = 80
}
function googleRequestUrl(text, sl, tl, hl, qc) {
qc = Option["no-autocorrect"] ? "qc" : "qca";
return HttpPathPrefix "/translate_a/single?client=gtx"\
"&ie=UTF-8&oe=UTF-8"\
"&dt=bd&dt=ex&dt=ld&dt=md&dt=rw&dt=rm&dt=ss&dt=t&dt=at&dt=gt"\
"&dt=" qc "&sl=" sl "&tl=" tl "&hl=" hl\
"&q=" preprocessByDump(text)
}
function googleTTSUrl(text, tl) {
return HttpProtocol HttpHost "/translate_tts?ie=UTF-8&client=gtx"\
"&tl=" tl "&q=" preprocessByDump(text)
}
function googleWebTranslateUrl(uri, sl, tl, hl) {
return "https://translate.google.com/translate?"\
"hl=" hl "&sl=" sl "&tl=" tl "&u=" uri
stemsee
EDIT harldy yad related anymore![/code]
My retro version, still with yandex. with engine icons
- Attachments
-
- trans_tray.sfs.gz
- fake.gz
- (52 KiB) Downloaded 135 times
- josejp2424
- Posts: 556
- Joined: Sun 01 Aug 2010, 22:35
- Contact:
trans_tray
I like your version.stemsee wrote:My retro version, still with yandex. with engine icons
Thank you.
Hi stemsee,
Thank you very much for your all-that's-needed sfs @ two posts above this one.
The shot below shows the output from the German (in my clipboard):
-------------------------------------------------
I seem to recall you are fluent in 6 or 7 languages, Argolance, Fredx181 and Vovchik also have multi-language fluency and are also star app-makers who have already directed their minds to language translation issues.
My thoughts, tongue-in-cheek, are:
* would be good to auto-fast-remove the sfs on tray exit
* and (perhaps) to add a right-click Preferences section
for say unticking "exit confirmation"
Ticking full screen display
Choosing a male or female voice
* Additional selection of text to speech
* Translating a lengthy piece (e.g. a book) with progress indicator.
* Save and restore (with alternative options)
and the miracle of including any original pictures in the output.
As regards the "auto-fast-remove" Forum member seaside has already facilitated this and MochiMoppel has done it for pets (your sfs could be easily converted to a pet for any user who needs or prefers that).
This thread may not be the most appropriate place to implement any such thoughts - and Argolance and Vovchik have already provided alternative translation apps elsewhere (so perhaps they might add links and brief comments)
My special thanks to all with honourable mention above.
Thank you very much for your all-that's-needed sfs @ two posts above this one.
The shot below shows the output from the German (in my clipboard):
having chosen output using Google, Bing and Yandex in Danish, Dutch, English and Esperanto.Also mein erstes Problem war schon, das ich das Deutsche Sprachpaket
-------------------------------------------------
I seem to recall you are fluent in 6 or 7 languages, Argolance, Fredx181 and Vovchik also have multi-language fluency and are also star app-makers who have already directed their minds to language translation issues.
My thoughts, tongue-in-cheek, are:
* would be good to auto-fast-remove the sfs on tray exit
* and (perhaps) to add a right-click Preferences section
for say unticking "exit confirmation"
Ticking full screen display
Choosing a male or female voice
* Additional selection of text to speech
* Translating a lengthy piece (e.g. a book) with progress indicator.
* Save and restore (with alternative options)
and the miracle of including any original pictures in the output.
As regards the "auto-fast-remove" Forum member seaside has already facilitated this and MochiMoppel has done it for pets (your sfs could be easily converted to a pet for any user who needs or prefers that).
This thread may not be the most appropriate place to implement any such thoughts - and Argolance and Vovchik have already provided alternative translation apps elsewhere (so perhaps they might add links and brief comments)
My special thanks to all with honourable mention above.
- Attachments
-
- ex German.jpg
- (93.42 KiB) Downloaded 659 times
you're welcomemfb wrote:Hi stemsee,
Thank you very much for your all-that's-needed sfs @ two posts above this one.
I
are you a stalker?seem to recall you are fluent in 6 or 7 languages, Argolance, Fredx181 and Vovchik also have multi-language fluency and are also star app-makers who have already directed their minds to language translation issues.
yes, 7 and counting. I have also learnt the Russian, Greek and Hebrew alphabets. I tried Sanskrit grammar but didn't get far, at least not as far as with welsh!!! My 6 year old son learnt to read and speak Welsh phonetics in 2 weeks (you'd think the school would notice an absolute genius and get him into a private school as by law there are places reserved for poor talented kids .... England is however even more corrupt and racist than USA, China and Russia put together! Truth is stranger than fiction). Now he is 10 and learning the drums by computer gaming method - speaks Spanish, Welsh, English and Chinese! Still no place in school though, 'coz we be cheeky!!
Only this?! Nothing else? Are you sure you're not GCMartin in disguise?My thoughts, tongue-in-cheek, are:
* would be good to auto-fast-remove the sfs on tray exit
* and (perhaps) to add a right-click Preferences section
for say unticking "exit confirmation"
Ticking full screen display
Choosing a male or female voice
* Additional selection of text to speech
* Translating a lengthy piece (e.g. a book) with progress indicator.
* Save and restore (with alternative options)
and the miracle of including any original pictures in the output.
As regards the "auto-fast-remove" Forum member seaside has already facilitated this and MochiMoppel has done it for pets (your sfs could be easily converted to a pet for any user who needs or prefers that).
Sfs unload on exit .... easy
rightclick menu with more options - easy
Voice translation is more interesting for me, and embedded images - probably requires yad --html
Progress indicator - easy .... progress indicator with real progress indication ... FRED!!?
Lengthy translations - easy - simply reiterate after 3000 characters or alternate between different engines.
Save and Restore and with EDITs - easy
'Alternative options' what the hell does that mean???
no shiite!This thread may not be the most appropriate place to implement any such thoughts
please do...- and Argolance and Vovchik have already provided alternative translation apps elsewhere (so perhaps they might add links and brief comments)
and me!My special thanks to all with honourable mention above.
What's it worth to you?
stemsee
Nice stemsee ! I like the tray icon change.
Attached my 'take', included the tray icon change, but difference is that .svg icons are used.
I like vovchiks's "self contained" approach, so converted the .png icons to .svg and added the .svg codes in the script (is rather large now because of that)
(used the java based program for converting to .svg from here: https://github.com/jankovicsandras/imagetracerjava)
Also removed Yandex and added some extra's to the Menu, "Help" and "Install/Upgrade trans"
Fred
Attached my 'take', included the tray icon change, but difference is that .svg icons are used.
I like vovchiks's "self contained" approach, so converted the .png icons to .svg and added the .svg codes in the script (is rather large now because of that)
(used the java based program for converting to .svg from here: https://github.com/jankovicsandras/imagetracerjava)
Also removed Yandex and added some extra's to the Menu, "Help" and "Install/Upgrade trans"
Fred
- Attachments
-
- 2019-08-23-134304_659x712_scrot_559x604.jpg
- (105.45 KiB) Downloaded 542 times
-
- trans_tray2.gz
- Remove fake .gz and make executable
- (109.68 KiB) Downloaded 144 times
- Argolance
- Posts: 3767
- Joined: Sun 06 Jan 2008, 22:57
- Location: PORT-BRILLET (Mayenne - France)
- Contact:
Bonjour,
All this is very exciting!
@josejp2424
I don't know why you said you were:
Cordialement.
All this is very exciting!
@josejp2424
I don't know why you said you were:
Be assured I don't take this the wrong way. I'm rather glad I entertained you but it is true and seems to have gone unnoticed:josejp2424 wrote:amused by your comments
This may not have been clearly expressed: a click with the middle button of the mouse on the systray icon closes it. So there is one of the two possibilities to exit that is useless. It seems (to me) that the exit with the middle button should be disabled in the yad script... especially since it is easy to click it by accident!argolance wrote:By default, the middle mouse button closes the notification icon and therefore, the "exit" menu entry may not be necessary, unless the central button is disabled.
Cordialement.
I wanted to do that, but after editing just the normal png files for ages, I couldn't be bothered. So thnxfredx181 wrote:Nice stemsee ! I like the tray icon change.
Attached my 'take', included the tray icon change, but difference is that .svg icons are used.
Thanx again .... this will be useful.(used the java based program for converting to .svg from here: https://github.com/jankovicsandras/imagetracerjava)
Good start on menu extras. Save/export translation as pdf or txt will be nice. It's looking good!Also removed Yandex and added some extra's to the Menu, "Help" and "Install/Upgrade trans"
Fred
Argolance, I agree --disable-middle should be used if the exit in menu stays. I like the exit in menu, actually.
stemsee
New topic for trans_tray
Hi All, I'm having the feeling that this "trans_tray" development is not over yet
That's why I opened new topic here:
http://murga-linux.com/puppy/viewtopic.php?t=116794
Also fine for me personally to continue here, btw, but I thought it's better to have its own thread for trans_tray, to not further "pollute" this thread, after all its purpose is for yad - tips.
So... see you there, or not...
Fred
That's why I opened new topic here:
http://murga-linux.com/puppy/viewtopic.php?t=116794
Also fine for me personally to continue here, btw, but I thought it's better to have its own thread for trans_tray, to not further "pollute" this thread, after all its purpose is for yad - tips.
So... see you there, or not...
Fred
Hi Misko
Can you help with this? I am trying to cat a file into a pipe. But it's not showing anything.
Can you help with this? I am trying to cat a file into a pipe. But it's not showing anything.
Code: Select all
function savedtranstexts (){
rm -f /tmp/TP
stxtp=/tmp/TP
mkfifo -m 755 $stxtp
exec 4<> $stxtp
clr=`echo -e '\f' >/tmp/TP`
yad --plug=$$ --tabnum=1 --list --item-separator=" " --column="Saved Trans:CBE" `ls $HOME/Trans-Text*` --select-action='bash -c "$clr";cat $1 >$stxtp"' &
yad --plug=$$ --tabnum=2 --editable --text-info <&4 &
WINDOWTITLE="Saved-Texts"
yad --window-icon=$pics/wireless.png --width=600 --height=440 --no-buttons --on-top --paned --splitter=160 --key=$$ --title="$WINDOWTITLE" --tab="Selector" --tab="Preview" --orient=hori
}; export -f savedtranstexts