lokis
lokis

Reputation: 67

RTL Language string placeholder in android studio

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?

Upvotes: 0

Views: 226

Answers (2)

Ernis A.
Ernis A.

Reputation: 150

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

Upvotes: 0

hmn727
hmn727

Reputation: 40

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.

Upvotes: 1

Related Questions