title: Arabic number in Arabic text in Android
body: <p><strong>EDIT</strong></p>
  
  <p>I'm porting my app to Arabic locale. I have some getString() with parameters like:</p>
  
  <pre><code>getString(R.string.distance, distance)
  </code></pre>
  
  <p>where <code>&lt;string name="distance"&gt;%1d km&lt;/string&gt;</code></p>
  
  <p>The requirement is that in Arabic I should show it like this: "2.3 كم".</p>
  
  <p>If I set as the locale for Saudi Arabia (country = "sa") or UAE (country = "ae") the number are shown in Eastern-Arabic but my client wants them in Western-Arabic.</p>
  
  <p>The solution <em><a href="https://stackoverflow.com/questions/31185993/android-display-digits-in-arabic-format">here</a></em> is to use Egypt as a country in the locale but this is not possible for me.</p>
  
  <p>I tried:</p>
  
  <pre><code>@TargetApi(Build.VERSION_CODES.LOLLIPOP)
  public void setAppContextLocale(Locale savedLocale) {
      Locale.Builder builder = new Locale.Builder();
      builder.setLocale(savedLocale).setExtension(Locale.UNICODE_LOCALE_EXTENSION, "nu-latn");
      Locale locale = builder.build();
      Configuration config = new Configuration();
      config.locale = locale;
      config.setLayoutDirection(new Locale(savedLocale.getLanguage()));
      mAppContext.getResources().updateConfiguration(config, mContext.getResources().getDisplayMetrics());
  }
  </code></pre>
  
  <p>as suggested in <a href="https://stackoverflow.com/questions/33003948/android-locale-builder-doesnt-mirror-the-page-in-right-to-left-locales">this question</a> but after that the country is ignored so both SA and AE locales use the strings in the default file.</p>