skip to Main Content

I would like to ask is it possible to update/edit RTL languages with placeholders?

Other languages will correctly display the %1$s placeholder but in RTL languages is s$1%. Hence, it will crash if the placeholder will be replaced using

getString(R.string.sample, "mystring");

Is there any other way?

2

Answers


  1. You can try concatenating the String, or appending substring to a StringBuilder.
    Then TextView.setText(<the result of concatenation>) (Java) or TextView.text = <the result of concatenation> (Kotlin).

    Yes, this is just a workaround, and even Android Studio tooltips doesn’t recommend it and will show a warning, because by doing so, it can’t handle locale changes if your app support multiple languages.

    Login or Signup to reply.
  2. You can use it like this s$%1 for RTL languages.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search