Reputation: 8408
How can I change the text within my textview based on the language set on the device without using string resources? I don't want to use string resources. As an example could someone please tell me what code I can use if the device language is in French and whether or not I'd need to use else if
or else
for including other languages.
TextView txt = (TextView)v.findViewById(R.id.WCBank_textView1);
txt.setText(Html.fromHtml("<font color='#E32017'>Red apples,</font>" +
"<font color='#FFD300'> yellow bananas,</font>" +
"<font color='#00782A'> green grapes</font>"
));
Upvotes: 1
Views: 960
Reputation: 2070
I still prefer string resources for i18n (not for the individual words, but for the whole expression). That said, you could try something like this:
if (Locale.getDefault().equals(Locale.FRENCH) || Locale.getDefault().equals(Locale.FRANCE)) {
// do the french stuff...
txt.setText(...);
} else if ...
Upvotes: 1