You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

166 lines
3.4 KiB

#!/bin/bash
# lc = languagecodes
declare -A lc
lc["Afrikaans"]="af"
lc["Akan"]="ak"
lc["Albanian"]="sq"
lc["Amharic"]="am"
lc["Arabic"]="ar"
lc["Armenian"]="hy"
lc["Azerbaijani"]="az"
lc["Basque"]="eu"
lc["Belarusian"]="be"
lc["Bemba"]="bem"
lc["Bengali"]="bn"
lc["Bihari"]="bh"
lc["Bork, bork, bork!"]="xx-bork"
lc["Bosnian"]="bs"
lc["Breton"]="br"
lc["Bulgarian"]="bg"
lc["Cambodian"]="km"
lc["Catalan"]="ca"
lc["Cherokee"]="chr"
lc["Chichewa"]="ny"
lc["Chinese (Simplified)"]="zh-CN"
lc["Chinese (Traditional)"]="zh-TW"
lc["Corsican"]="co"
lc["Croatian"]="hr"
lc["Czech"]="cs"
lc["Danish"]="da"
lc["Dutch"]="nl"
lc["Elmer Fudd"]="xx-elmer"
lc["English"]="en"
lc["Esperanto"]="eo"
lc["Estonian"]="et"
lc["Ewe"]="ee"
lc["Faroese"]="fo"
lc["Filipino"]="tl"
lc["Finnish"]="fi"
lc["French"]="fr"
lc["Frisian"]="fy"
lc["Ga"]="gaa"
lc["Galician"]="gl"
lc["Georgian"]="ka"
lc["German"]="de"
lc["Greek"]="el"
lc["Guarani"]="gn"
lc["Gujarati"]="gu"
lc["Hacker"]="xx-hacker"
lc["Haitian Creole"]="ht"
lc["Hausa"]="ha"
lc["Hawaiian"]="haw"
lc["Hebrew"]="iw"
lc["Hindi"]="hi"
lc["Hungarian"]="hu"
lc["Icelandic"]="is"
lc["Igbo"]="ig"
lc["Indonesian"]="id"
lc["Interlingua"]="ia"
lc["Irish"]="ga"
lc["Italian"]="it"
lc["Japanese"]="ja"
lc["Javanese"]="jw"
lc["Kannada"]="kn"
lc["Kazakh"]="kk"
lc["Kinyarwanda"]="rw"
lc["Kirundi"]="rn"
lc["Klingon"]="xx-klingon"
lc["Kongo"]="kg"
lc["Korean"]="ko"
lc["Krio (Sierra Leone)"]="kri"
lc["Kurdish"]="ku"
lc["Kurdish (Soranî)"]="ckb"
lc["Kyrgyz"]="ky"
lc["Laothian"]="lo"
lc["Latin"]="la"
lc["Latvian"]="lv"
lc["Lingala"]="ln"
lc["Lithuanian"]="lt"
lc["Lozi"]="loz"
lc["Luganda"]="lg"
lc["Luo"]="ach"
lc["Macedonian"]="mk"
lc["Malagasy"]="mg"
lc["Malay"]="ms"
lc["Malayalam"]="ml"
lc["Maltese"]="mt"
lc["Maori"]="mi"
lc["Marathi"]="mr"
lc["Mauritian Creole"]="mfe"
lc["Moldavian"]="mo"
lc["Mongolian"]="mn"
lc["Montenegrin"]="sr-ME"
lc["Nepali"]="ne"
lc["Nigerian Pidgin"]="pcm"
lc["Northern Sotho"]="nso"
lc["Norwegian"]="no"
lc["Norwegian (Nynorsk)"]="nn"
lc["Occitan"]="oc"
lc["Oriya"]="or"
lc["Oromo"]="om"
lc["Pashto"]="ps"
lc["Persian"]="fa"
lc["Pirate"]="xx-pirate"
lc["Polish"]="pl"
lc["Portuguese (Brazil)"]="pt-BR"
lc["Portuguese (Portugal)"]="pt-PT"
lc["Punjabi"]="pa"
lc["Quechua"]="qu"
lc["Romanian"]="ro"
lc["Romansh"]="rm"
lc["Runyakitara"]="nyn"
lc["Russian"]="ru"
lc["Scots Gaelic"]="gd"
lc["Serbian"]="sr"
lc["Serbo-Croatian"]="sh"
lc["Sesotho"]="st"
lc["Setswana"]="tn"
lc["Seychellois Creole"]="crs"
lc["Shona"]="sn"
lc["Sindhi"]="sd"
lc["Sinhalese"]="si"
lc["Slovak"]="sk"
lc["Slovenian"]="sl"
lc["Somali"]="so"
lc["Spanish"]="es"
lc["Spanish (Latin American)"]="es-419"
lc["Sundanese"]="su"
lc["Swahili"]="sw"
lc["Swedish"]="sv"
lc["Tajik"]="tg"
lc["Tamil"]="ta"
lc["Tatar"]="tt"
lc["Telugu"]="te"
lc["Thai"]="th"
lc["Tigrinya"]="ti"
lc["Tonga"]="to"
lc["Tshiluba"]="lua"
lc["Tumbuka"]="tum"
lc["Turkish"]="tr"
lc["Turkmen"]="tk"
lc["Twi"]="tw"
lc["Uighur"]="ug"
lc["Ukrainian"]="uk"
lc["Urdu"]="ur"
lc["Uzbek"]="uz"
lc["Vietnamese"]="vi"
lc["Welsh"]="cy"
lc["Wolof"]="wo"
lc["Xhosa"]="xh"
lc["Yiddish"]="yi"
lc["Yoruba"]="yo"
lc["Zulu"]="zu"
languagecodes=$(printf '%s\n' "${!lc[@]}")
input_text="$(dmenu -p "Text:" <&-)"
translate_to_long="$(echo -e "$languagecodes" | dmenu -i -p "Translate To:" -l 20)"
translate_to=${lc[$translate_to_long]}
translation=$(curl -L "https://translate.metalune.xyz/translate/auto/$translate_to/$input_text")
echo -e $translation | dmenu -i -p "Select to copy translation:" -l 20 | xclip -i -selection clipboard