My App uses the Bing Translate API . Now i want to set the target language like here:
@Override
public void onClick(View v) {
Translate.setClientId("hidden");
Translate.setClientSecret("hidden");
try {
String translatedText = Translate.execute(textToTranslate, Language.ENGLISH/* <----Target Language */);
b.setText(translatedText);
} catch (Exception e) {
Toast.makeText(this,"Fail!",Toast.LENGTH_LONG);
}
}
But the Target Language should be a string . When i am using a string i got the error that i cant use a string here. Could anybody help me , please ?
Sammy
The target language parameter is not a String
. Language
is an enum class. You can use it just as you have it in the code you've posted, or you can call Language.valueOf()
to get the appropriate value to pass to the execute()
method.
For example:
String translatedText = Translate.execute(textToTranslate, Language.valueOf("ENGLISH"));