textproc/dmenu-translate: New port: Quick text translation with dmenu

dmenu-translate is a simple and efficient tool that allows users to translate
text quickly using the dmenu or any other dmenu-like utility. It supports
multiple languages and translation services, making it easy
to get instant translations with minimal effort.

WWW: https://github.com/NikitaIvanovV/dmenu-translate

PR:		282733
This commit is contained in:
Yusuf Yaman 2024-11-13 22:55:30 +03:00 committed by Robert Clausecker
parent 2846450082
commit f604686b3a
5 changed files with 93 additions and 0 deletions

View file

@ -155,6 +155,7 @@
SUBDIR += diffutils
SUBDIR += dikt
SUBDIR += discount
SUBDIR += dmenu-translate
SUBDIR += doc-mode.el
SUBDIR += docbook
SUBDIR += docbook-sgml

View file

@ -0,0 +1,40 @@
PORTNAME= dmenu-translate
DISTVERSION= g20230526
CATEGORIES= textproc
MAINTAINER= nxjoseph@protonmail.com
COMMENT= Quick text translation with dmenu
WWW= https://github.com/NikitaIvanovV/dmenu-translate
LICENSE= MIT
LICENSE_FILE= ${WRKSRC}/LICENSE
RUN_DEPENDS= gsed:textproc/gsed \
notify-send:devel/libnotify \
trans:textproc/translate-shell \
xterm:x11/xterm
USE_GITHUB= yes
GH_ACCOUNT= NikitaIvanovV
GH_TAGNAME= 8cc717d3d3bec7f1d7db804e1c339362536b6e45
NO_ARCH= yes
NO_BUILD= yes
PLIST_FILES= bin/${PORTNAME}
OPTIONS_DEFINE= WAYLAND X11
OPTIONS_DEFAULT= WAYLAND X11
WAYLAND_DESC= depend on x11/wmenu and x11/wl-clipboard for use with Wayland
X11_DESC= depend on x11/dmenu and x11/xclip for use with X11
WAYLAND_RUN_DEPENDS= wl-copy:x11/wl-clipboard \
wmenu:x11/wmenu
X11_RUN_DEPENDS= dmenu:x11/dmenu \
xclip:x11/xclip
do-install:
${INSTALL_SCRIPT} ${WRKSRC}/${PORTNAME} \
${STAGEDIR}${PREFIX}/bin/${PORTNAME}
.include <bsd.port.mk>

View file

@ -0,0 +1,3 @@
TIMESTAMP = 1732713638
SHA256 (NikitaIvanovV-dmenu-translate-g20230526-8cc717d3d3bec7f1d7db804e1c339362536b6e45_GH0.tar.gz) = 418e75f8913366095f2276ee2579228c60ab5b5c292ecf95c08e7a135b54a29c
SIZE (NikitaIvanovV-dmenu-translate-g20230526-8cc717d3d3bec7f1d7db804e1c339362536b6e45_GH0.tar.gz) = 965509

View file

@ -0,0 +1,45 @@
--- dmenu-translate.orig 2024-11-26 19:46:24 UTC
+++ dmenu-translate
@@ -53,7 +53,7 @@ formatmenu() {
}
formatmenu() {
- echo "$1" | tr '\n' ' ' | sed 's/\s\{3,\}//g; s/^\(.\{30\}\).\+/\1.../; s/$/\n/'
+ echo "$1" | tr '\n' ' ' | gsed 's/\s\{3,\}//g; s/^\(.\{30\}\).\+/\1.../; s/$/\n/'
}
get_selection() {
@@ -62,12 +62,12 @@ clip_menu() {
clip_menu() {
{ formatmenu "$1"; formatmenu "$2"; } |
- sed 's/^\s*$//; 1s/^./Primary: &/; 2s/^./Clipboard: &/' |
- sed '/^$/d'
+ gsed 's/^\s*$//; 1s/^./Primary: &/; 2s/^./Clipboard: &/' |
+ gsed '/^$/d'
}
lang_menu() {
- echo "$TRANS_LANGS" | sed 's/\s\+/\n/g' | sed '/:/!s/^/:/'
+ echo "$TRANS_LANGS" | gsed 's/\s\+/\n/g' | gsed '/:/!s/^/:/'
echo '[Define]'
}
@@ -86,7 +86,7 @@ save_file() (
}
save_file() (
- tmp="$(mktemp --tmpdir 'dmenu-translate.XXXXXX')"
+ tmp="$(mktemp --tmpdir -t dmenu-translate)"
echo "$1" > "$tmp"
echo "$tmp"
)
@@ -98,7 +98,7 @@ get_text() {
get_text() {
echo "$2" | while IFS= read -r clip; do
[ "$1" = "$clip" ] && {
- type="$(echo "$clip" | sed 's/^\(\w\+\):.*/\1/')"
+ type="$(echo "$clip" | gsed 's/^\(\w\+\):.*/\1/')"
case "$type" in
Primary) echo "$primary" ;;
Clipboard) echo "$clipboard" ;;

View file

@ -0,0 +1,4 @@
dmenu-translate is a simple and efficient tool that allows users to translate
text quickly using the dmenu or any other dmenu-like utility. It supports
multiple languages and translation services, making it easy
to get instant translations with minimal effort.