Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Translate Activity not working anymore

I wrote a program that invokes Google Translator android application via Intent.ACTION_VIEW. The problem is that invoking the Google Translator App does not work anymore, although it did once.

The code is identical to the code given here:

Returning Translated Text from Google Translate Activity

(yes, I tried to replace my code by that code, the Google Translator App behaves as if it does not receive any data.)

Currently I cannot specify the text and the two languages. The best I can do is to use ACTION_SEND, but it ignores the two languages:

        Intent i = new Intent();
        i.setAction(Intent.ACTION_SEND);
        i.putExtra(Intent.EXTRA_TEXT, "What is going on?");
        i.putExtra("key_text_input", "What time is it?");
        i.putExtra("key_text_output", "");
        i.putExtra("key_language_from", "en");
        i.putExtra("key_language_to", "es");
        i.putExtra("key_suggest_translation", "");
        i.putExtra("key_from_floating_window", false);
        i.setComponent(new ComponentName("com.google.android.apps.translate",
            "com.google.android.apps.translate.translation.TranslateActivity"));

What actually happened when I ran this code was: the Google Translator asked me if I want to translate from English and translated "What is going on?" to French.

So: how do I pass the languages to the Google Translate App now?

like image 799
18446744073709551615 Avatar asked Oct 02 '13 08:10

18446744073709551615


People also ask

Why has my Google Translate stopped working?

Google translate not working properly on Chrome might happen due to inappropriate browser settings configuration, language settings, third party extensions, or so.

What is wrong with Google Translate?

Google Translate often produces translations that contain significant grammatical errors. This is due to the fact that Google's translation system uses a method based on language pair frequency that does not take into account grammatical rules. Google Translate does not have a system to correct for translation errors.

Is Google Translate shut down?

Both mobile app and web browser versions of Google Translate have been discontinued due to low usage, Alphabet said.


1 Answers

They have changed it once again:

            intent.setAction(Intent.ACTION_SEND);
            intent.setType("text/plain");
            intent.setPackage("com.google.android.apps.translate");

            intent.putExtra(Intent.EXTRA_TEXT, text);

UPDATE: It is possible to pass the languages if you pack the text and the languages into an URI:

            intent = new Intent();
            intent.setAction(Intent.ACTION_VIEW);
            intent.setPackage("com.google.android.apps.translate");

            Uri uri = new Uri.Builder()
                    .scheme("http")
                    .authority("translate.google.com")
                    .path("/m/translate")
                    .appendQueryParameter("q", "c'est l'meunier Mathurin qui caresse les filles au tic-tac du moulin")
                    .appendQueryParameter("tl", "pl") // target language
                    .appendQueryParameter("sl", "fr") // source language
                    .build();
            //intent.setType("text/plain"); //not needed, but possible
            intent.setData(uri);
like image 57
18446744073709551615 Avatar answered Nov 13 '22 23:11

18446744073709551615