Retourner au contenu associé (journal : Google translate sans quitter votre emacs)
Posté par Vincent Gay (site web personnel) le 02 mars 2015 à 23:22. En réponse au journal Google translate sans quitter votre emacs. Évalué à 9.
#!/bin/bash # access translate.google.com from terminal help='translate <text> [[<source language>] <target language>] if target missing, use DEFAULT_TARGET_LANG if source missing, use auto' # adjust to taste DEFAULT_TARGET_LANG=en if [[ 1ドル = -h || 1ドル = --help ]] then echo "$help" exit fi if [[ 3ドル ]]; then source="2ドル" target="3ドル" elif [[ 2ドル ]]; then source=auto target="2ドル" else source=auto target="$DEFAULT_TARGET_LANG" fi result=$(curl -s -i --user-agent "" -d "sl=$source" -d "tl=$target" --data-urlencode "text=1ドル" https://translate.google.com) encoding=$(awk '/Content-Type: .* charset=/ {sub(/^.*charset=["'\'']?/,""); sub(/[ "'\''].*$/,""); print}' <<<"$result") #iconv -f $encoding <<<"$result" | awk 'BEGIN {RS="<div"};/<span[^>]* id=["'\'']?result_box["'\'']?/ {sub(/^.*id=["'\'']?result_box["'\'']?(>| [^>]*>)([ \n\t]*<[^>]*>)*/,"");sub(/<.*$/,"");print}' | html2text -utf8 iconv -f $encoding <<<"$result" | awk 'BEGIN {RS="</div>"};/<span[^>]* id=["'\'']?result_box["'\'']?/' | html2text -utf8 exit
sur cette page : http://crunchbang.org/forums/viewtopic.php?id=17034
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル
# en bash
Posté par Vincent Gay (site web personnel) . En réponse au journal Google translate sans quitter votre emacs. Évalué à 9.
sur cette page : http://crunchbang.org/forums/viewtopic.php?id=17034