Aller au contenu

« Linux Traduction Rapide » : différence entre les versions

De Marmits Wiki
Page créée avec «  ===Commande et Raccourci Clavier pour une Traduction Rapide === <syntaxhighlight lang="bash" line copy> sudo apt install translate-shell </syntaxhighlight> ==== Créez un script ~/scripts/traduire.sh: ==== <syntaxhighlight lang="bash" line> #!/bin/bash # Enregistrez ceci sous ~/traduire.sh # Récupère le texte du presse-papiers texte_copie=$(xclip -o -selection clipboard 2>/dev/null) # Vérifie si le presse-papiers est vide if [ -z "$texte_copie" ]; then... »
 
 
(7 versions intermédiaires par le même utilisateur non affichées)
Ligne 8 : Ligne 8 :
<syntaxhighlight lang="bash" line>
<syntaxhighlight lang="bash" line>
#!/bin/bash
#!/bin/bash
# Enregistrez ceci sous ~/traduire.sh
# ~/traduire.sh - Version avec texte agrandi garantie


# Récupère le texte du presse-papiers
# Récupération du texte
texte_copie=$(xclip -o -selection clipboard 2>/dev/null)
texte_copie=$(xclip -o -selection clipboard 2>/dev/null)


# Vérifie si le presse-papiers est vide
if [ -z "$texte_copie" ]; then
if [ -z "$texte_copie" ]; then
     zenity --error --text="Le presse-papiers est vide !"
     zenity --error --text="Le presse-papiers est vide !" --width=300
     exit 1
     exit 1
fi
fi


# Traduction et affichage
# Traduction et affichage avec HTML
traduction=$(trans -b "$texte_copie" -t fr)
traduction=$(trans -b "$texte_copie" -t fr)
zenity --info --title="Traduction" --text="$traduction" --width=500
zenity --info \
        --title="Traduction" \
        --text '<span foreground="white" font="14">'"$traduction"'</span>' \
        --width=1800 \
        --height=900
 
</syntaxhighlight>
 
ou (scrollbar si texte trop long ...)
 
<syntaxhighlight lang="bash" line>
#!/bin/bash
# ~/traduire.sh - Version avec texte agrandi garantie
 
# Récupération du texte
texte_copie=$(xclip -o -selection clipboard 2>/dev/null)
 
if [ -z "$texte_copie" ]; then
    zenity --error --text="Le presse-papiers est vide !" --width=300
    exit 1
fi
 
# Traduction et affichage avec HTML
traduction=$(trans -b "$texte_copie" -t fr)
echo "$traduction" | zenity --text-info \
      --title="Traduction" \
      --width=1800 \
      --height=900 \
      --text '<span foreground="white" font="14">'"$traduction"'</span>' \
      --ok-label="Fermer" \
      --font "ubuntu 14"
 
 
 
</syntaxhighlight>
</syntaxhighlight>


Ligne 49 : Ligne 81 :
→ Désormais, copiez un texte et appuyez sur Super+T pour voir la traduction !
→ Désormais, copiez un texte et appuyez sur Super+T pour voir la traduction !


[[Catégorie:Linux]] [[Catégorie:Ubuntu]] [[Catégorie:Debian]]
[[Catégorie: Terminal Tools]]

Dernière version du 22 octobre 2025 à 14:59

Commande et Raccourci Clavier pour une Traduction Rapide

sudo apt install translate-shell

Créez un script ~/scripts/traduire.sh:

#!/bin/bash
# ~/traduire.sh - Version avec texte agrandi garantie

# Récupération du texte
texte_copie=$(xclip -o -selection clipboard 2>/dev/null)

if [ -z "$texte_copie" ]; then
    zenity --error --text="Le presse-papiers est vide !" --width=300
    exit 1
fi

# Traduction et affichage avec HTML
traduction=$(trans -b "$texte_copie" -t fr)
zenity  --info \
        --title="Traduction" \
        --text '<span foreground="white" font="14">'"$traduction"'</span>' \
        --width=1800 \
        --height=900

ou (scrollbar si texte trop long ...)

#!/bin/bash
# ~/traduire.sh - Version avec texte agrandi garantie

# Récupération du texte
texte_copie=$(xclip -o -selection clipboard 2>/dev/null)

if [ -z "$texte_copie" ]; then
    zenity --error --text="Le presse-papiers est vide !" --width=300
    exit 1
fi

# Traduction et affichage avec HTML
traduction=$(trans -b "$texte_copie" -t fr)
echo "$traduction" | zenity --text-info \
       --title="Traduction" \
       --width=1800 \
       --height=900 \
       --text '<span foreground="white" font="14">'"$traduction"'</span>' \
       --ok-label="Fermer" \
       --font "ubuntu 14"

Rendez-le exécutable :

chmod +x ~/scripts/traduire.sh

Créer un alias

dans ~/.bashrc

alias traduire='bash /home/geo/scripts/traduire.sh'

→ Désormais, copiez un texte et dans le terminal, tapez :

 traduire

Ajoutez un raccourci clavier

Paramètres → Clavier → Raccourcis personnalisés

Commande : bash -c '~/scripts/traduire.sh'

Raccourci : Super+T

→ Désormais, copiez un texte et appuyez sur Super+T pour voir la traduction !