1

I have some arabic text in the app that has parameters.

<string name="text_1">s$1% نقطة إلى  s%2$</string>

The problem is that IDE shows an error when I am using this string

Format string text_1 is not a valid format string so it should not be passed to String.format

For english I have

   <string name="text_1"> %1$s beans to %2$s</string>

which is working just fine.

edit:

enter image description here

So, 1,3 & 4 are working just fine, the problem is with 2

How i need to format my arabic parameters to be ok?

ghita
  • 2,746
  • 7
  • 30
  • 54
  • You have to use the same string format no matter what language file you're creating. (See the Android Developer docs for more info: https://developer.android.com/guide/topics/resources/string-resource#FormattingAndStyling) – Edric Sep 09 '19 at 14:52
  • There's probably something wrong with the way you've defined the string. See https://stackoverflow.com/questions/45983711/android-handling-integer-1d-and-string-1s-arguments-for-right-to-left-l?rq=1 – Edric Sep 09 '19 at 14:56
  • i am using the same format s$1% for other strings and they work fine – ghita Sep 09 '19 at 14:57
  • Did you try inputting the inverted version of the formatter string? – Edric Sep 09 '19 at 14:58
  • @Edric i have edit the question – ghita Sep 09 '19 at 14:59

2 Answers2

1

I just copied your code and it works fine. enter image description here

Try to:

  • clean the project
  • check multi-language files
  • or just use the string.format

This question was answered here with a similar issue:

Format string XXX is not a valid format string so it should not be passed to String.format

NobodyIsPerfect
  • 182
  • 1
  • 12
  • 1
    This is because OP is actually using an invalid format of defining a format string, not because of possible build problems: https://developer.android.com/guide/topics/resources/string-resource#FormattingAndStyling – Edric Sep 09 '19 at 14:53
-2

Also when using Arabic text, you should use

%1$s and %2$s

not

s$1% and s%2$

Yoav Gibri
  • 158
  • 5