September 15, 2009 · File under Technical argle-bargle
I wanted to see something translated into everything, for some reason; the code below does it okay. You need a UTF-8-capable console like Terminal on OS X, or redirect to a file and view it in a browser. Example:
$ CLASSPATH=.:google-api-translate-java-0.8.jar java Panslate "unbelievably interesting" sq: unbelievably interesante ar: المثيرة للاهتمام bg: невероÑтно интереÑно ca: increïblement interessant zh: 令人难以置信的有趣 zh-CN: 令人难以置信的有趣 zh-TW: 令人難以置信的有趣 hr: nevjerojatno zanimljiv cs: neuvěřitelnÄ› zajÃmavé da: utroligt interessant nl: ongelooflijk interessant en: unbelievably interesting et: äärmiselt huvitav tl: unbelievably kagiliw-giliw na fi: uskomattoman mielenkiintoista fr: incroyablement intéressante gl: incrible interesante de: unglaublich interessant el: απίστευτα ενδιαφÎÏον iw: ×ž×¢× ×™×™×Ÿ ×©×œ× ×ª×™×מן hi: अविशà¥à¤µà¤¸à¤¨à¥€à¤¯ दिलचसà¥à¤ª hu: Hihetetlenül érdekes id: luar biasa menarik it: incredibilmente interessante ja: ä¿¡ã˜ã‚‰ã‚Œãªã„ã»ã©é¢ç™½ã„ ko: ì—„ì² ìž¬ë¯¸ lv: neticami interesanti lt: neįtikÄ—tinai įdomÅ«s mt: unbelievably interessanti no: utrolig interessant fa: unbelievably جالب pl: niesamowicie ciekawe pt: incrivelmente interessante ro: incredibil de interesant ru: невероÑтной интереÑно sr: невероватно занимљиво sk: neuveriteľne zaujÃmavé sl: Neverjetno zanimivo es: increÃblemente interesante sv: Otroligt intressant th: น่าเหลืà¸à¹€à¸Šà¸·à¹ˆà¸ tr: inanılmaz ilginç uk: неймовірною цікаво vi: không ngá» thú vị
You'll need google-api-translate-java. Here's the Java code:
import java.io.PrintStream; import java.net.InetAddress; import com.google.api.translate.Language; import com.google.api.translate.Translate; public class Panslate { public static void main(String[] args) throws Exception { PrintStream out = new PrintStream(System.out, true, "UTF-8"); Translate.setHttpReferrer(InetAddress.getLocalHost().getHostName()); for (Language target : Language.values()) { if (target == Language.AUTO_DETECT) continue; String translatedText = Translate.execute(args[0], Language.ENGLISH, target); out.println(target + ": " + translatedText); } } }
A collection of posts about things that suck, and posts that suck about things that don't suck.
@efredricksen
@efred
efredricksen
grumdrig (gh)
grumdrig (bb)
efredricksen
©2022 Eric Fredricksen