How can I use http://translate.google.com/ to translate the string in Java program?

前端 未结 4 1774
庸人自扰
庸人自扰 2021-01-29 01:18

I want to use http://translate.google.com/ to translate the string. And now I want to sent a string from a java program in http://translate.google.com/ to translate the string f

4条回答
  •  Happy的楠姐
    2021-01-29 02:09

    I used this code on my button for translate:

    String translate = "translate this string";    
    String locale = Locale.getDefault().getLanguage();
    Uri uri = Uri.parse("https://translate.google.com/#auto/"+ locale + "/" + translate);         Intent intent = new Intent(Intent.ACTION_VIEW, uri);
            getApplicationContext.startActivity(intent);
    

    I used #auto to detect automatic from string translate, and locale to detect locale language from phone.

    Hope this helps :)

提交回复
热议问题