The Android method for this, uses xml resources, as described in Localization with resources .
<strong> values /strings.xml:
<resources> <string name="yes_response">That is great, %s!</string> </resources>
<strong> pt / strings.xml values:
<resources> <string name="yes_response">C\'est bon, %s!</string> </resources>
The code:
yourYesResponse = context.getString(R.string.yes_response, usersName);
Motivation:
It is good practice to use the Android resource framework to separate the localized aspects of your application as much as possible from the Java core:
- You can place most or all of the contents of your application interface in resource files, as described in this document, and in Provision of resources.
- The user interface behavior, on the other hand, is controlled by your Java code. For example, if a user enters data that needs to be formatted or sorted differently depending on the language, then you will use Java to process the data programmatically. This document does not describe how to localize your Java code.
source share