translate string in android

https://w‮‬ww.lautturi.com
translate string in android

android Display a text message for users after login.

strings.xml

<string name="welcome_messages">Hello, [%1$s]! You have [%2$d] new messages.</string>

Code:

String username = "Lautturi";
Int msgCount = 3;
Resources res = getResources(); //previously done
String text = String.format(res.getString(R.string.welcome_messages), username, msgCount);

text output:

Hello, [Lautturi]! You have [3] new messages.
Created Time:2017-08-31 20:08:30  Author:lautturi