Articles → Android → Support Multiple Languages In An Android Application

Support Multiple Languages In An Android Application






Scenario





Steps




  1. Add a new strings file in values folder.
  2. Add a string for French language.
  3. Add a textview in main activity that displays the text.
  4. Run the application with default language settings.
  5. Run the application with French language settings.



Add A New Strings File In Values Folder




  1. Right-click on values folder and go to New Values resource file
  2. Picture showing add the value resource group file inside the project
    Click to Enlarge

  3. Following window will appear
  4. Picture showing the popup window for adding the new resource file
    Click to Enlarge

  5. Enter the file name as strings
  6. Select the ‘Available qualifiers’ as ‘Country Code’ using ‘>>’.
  7. Once you click on ‘>>’ button, your window will become like this
  8. Picture showing the popup window for adding the details of the resource file
    Click to Enlarge

  9. Here you can enter mobile country code (208 for French) and rename the ‘Directory Name’ as ‘values-fr’ and click on Ok.


Picture showing the resource files added in the strings folder
Click to Enlarge


Add A String For French Language




Picture showing adding a string inside the strings.xml file
Click to Enlarge


Add A Textview In Main Activity That Displays The Text




Picture showing adding a textview inside the main activity
Click to Enlarge


Run The Application With Default Language Settings




Picture showing running the application with the default settings
Click to Enlarge


Run The Application With French Language Settings






Picture showing running the application with the french settings
Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Monday, October 28, 2019

Query/Feedback


Your Email Id
 
Subject
 
Query/FeedbackCharacters remaining 250