Home > other >  RTL Language string placeholder in android studio
RTL Language string placeholder in android studio

Time:11-16

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?

CodePudding user response:

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.

CodePudding user response:

You can use it like this s$%1 for RTL languages.

  • Related