title: How to set Arabic language as Locale
body: <p>I'm working on text to speech conversion. For this, I got the example from the internet. In this they set the English language by <code>setLanguage(Locale.US);</code>. So, now I'm trying to set the Arabic instead of English. But I failed when I change the language to Arabic. Anyone help me to change the language as Arabic </p>
  
  <p><strong>Code for reference</strong></p>
  
  <pre><code>import java.util.Locale;
  import android.app.Activity;
  import android.os.Bundle;
  import android.speech.tts.TextToSpeech;
  import android.speech.tts.TextToSpeech.OnInitListener;
  import android.util.Log;
  import android.view.View;
  import android.widget.Button;
  import android.widget.EditText;
  import android.widget.Toast;
  
  public class TexttoSpeechActivity extends Activity implements OnInitListener {
      /** Called when the activity is first created. */
  
      private TextToSpeech tts;
      private Button btnSpeak;
      private EditText txtText;
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main);
          tts = new TextToSpeech(this, this);
          btnSpeak = (Button) findViewById(R.id.btnSpeak);
          txtText = (EditText) findViewById(R.id.txtText);
  
          btnSpeak.setOnClickListener(new View.OnClickListener() {
  
              public void onClick(View arg0) {
                  speakOut();
              }
  
          });
      }
  
      @Override
      public void onDestroy() {
          // Don't forget to shutdown!
          if (tts != null) {
              tts.stop();
              tts.shutdown();
          }
          super.onDestroy();
      }
  
      public void onInit(int status) {
          // TODO Auto-generated method stub
  
          if (status == TextToSpeech.SUCCESS) {
  
              /*Locale locale = new Locale("ar_EG");
              Locale.setDefault(locale);
              Configuration config = new Configuration();
              config.locale = locale;
              getBaseContext().getResources().updateConfiguration(config,
                    getBaseContext().getResources().getDisplayMetrics());*/
  
              int result = tts.setLanguage(Locale.US);
  
              if (result == TextToSpeech.LANG_MISSING_DATA
                      || result == TextToSpeech.LANG_NOT_SUPPORTED) {
                  Toast.makeText(this, "Language not supported", Toast.LENGTH_LONG).show();
                  Log.e("TTS", "Language is not supported");
              } else {
                  btnSpeak.setEnabled(true);
  
              }
  
          } else {
              Log.e("TTS", "Initilization Failed");
          }
  
      }
  
      private void speakOut() {
  
          String text = txtText.getText().toString();
          if (text.length() == 0) {
              tts.speak("You haven't typed text", TextToSpeech.QUEUE_FLUSH, null);
          } else {
              tts.speak(text, TextToSpeech.QUEUE_FLUSH, null);
          }
  
      }
  }
  </code></pre>