How to change string value dynamically with string interpolation for a string loaded from json file

95 views Asked by At

I have 3 json files for translations. I want to translate this message: "ERROR_MESSAGE": "Verification failed, %s tries left.".

I am using sprintf package, and when I load the string it doesn't change the value dynamically. The % sign shouldn't be escaped, so it would work in my opinion.

sprintf(loadedString, [remainingTries]);
1

There are 1 answers

0
Lemmer EL ASSAL On

You could either use:

sprintf(loadedString, [remainingTries.toString()]);

or change %s to %i.