---
title: "Android support for different Languages"  
description: "Hi Everyone, here we will talk about how to use different languages in our Android app. We will discuss about the support for different languages in a"  
author: "Anonymous User"  
published: 2014-11-11  
updated: 2014-11-11  
canonical: https://www.mindstick.com/blog/700/android-support-for-different-languages  
category: "android"  
tags: ["android"]  
reading_time: 3 minutes  

---

# Android support for different Languages

[Android device](https://www.mindstick.com/articles/342298/best-ways-to-customize-your-android-device-for-better-productivity) comes in many shapes and size all over the world. With a vast wide range of device types .In order to be as [successful as](https://yourviews.mindstick.com/view/84278/google-pixel-phones-not-successful-as-compared-to-apple-phones) possible our app need to be compatible with different device configurations. Some of the important variations that we must consider includes different languages, [screen sizes](https://www.mindstick.com/forum/158661/how-to-create-a-responsive-layout-that-adapts-to-different-screen-sizes-using-css-media-queries), and versions of the Android platform.\

Here we are going to know how to use basic platform features that leverage alternative resources and features so our app provide an optimized [user experience](https://www.mindstick.com/articles/12731/the-importance-of-feedback-to-the-user-experience) on variety of Android-compatible device , using a single application package(APK)

Thumb Rule for Strings: The best practice is to extract the UI strings from the app code and keep them in an external file. Android makes this easy with a resource directory in each Android Project.

If you created [your project](https://www.mindstick.com/forum/156583/best-way-to-link-bootstrap-file-in-your-project) using the Android SDK Tools, the tools create a res/ directory in the top level of the project. Within this res/ directory are subdirectories for the various resource types. There are also a few default files such as res/values/strings.xml which holds our string values

\
Create Local Directories and String Files:

To add support for more languages, create additional values directories inside res/ that include a hyphen and the ISO-language code at the end of the directory name. For example, values-es/ is the directory containing simple resources for the locales with the language code. Android loads the appropriate resources according to the locale settings of the device at the runtime.

First chose the language for which we want support, create the resource sub-directories and string [resource file](https://www.mindstick.com/articles/327263/what-is-the-use-of-resource-file-how-to-use-it-on-your-project).

```
MyProject/        res/            values/                      strings.xml            values-es/                      strings.xml            values-fr/                      strings.xml
```

Add the string values for each locale into the appropriate file.

At runtime, the Android systems uses the appropriate set of string resources based on the locale currently set for the user’s device.

Have look on some of the string resource examples in different languages.

English ([default locale](https://www.mindstick.com/forum/12827/change-default-locale-for-junit-test)) /values/strings.xml:

```
<?xml version =“1.0” encoding=”utf-8”><resources>      <string  name=”title”>My First App </string>      <string  name=”hello_world”>Hello World! </string></resources>
```

French,/values-fr/strings.xml :

```
 <?xml version =“1.0” encoding=”utf-8”><resources>      <string  name=”title”>Ma premiere App </string>      <string  name=”hello_world”>Bonjur le monde! </string></resources>
```

Spanish,/values-fes/strings.xml :

```
<?xml version =“1.0” encoding=”utf-8”><resources>      <string  name=”title”>Mi primera App </string>      <string  name=”hello_world”> Hola Monda! </string></resources>
```

Use the String Resources

We can refer our string resource in our [source code](https://www.mindstick.com/forum/33476/pls-send-me-source-code-for-changing-passward-in-asp-dot-net-i-tried-so-much-from-google-but-its-not-workining) and other XML files using the resource name defined by the <string> element’s name attribute.

In our source code we can refer to a string resource with syntax R.string.<string_name>. There are a variety of methods that accept a string resource this way

```
// Get a string resource from app’s ResourcesString hello =  getResource().getString(R.string.hello_world); // Supply a string resource to a method that requires a  stringTextView textView = new TextView(this);textView.setText(R.string.hello_world);
```

We can also refer string in XML files, with the syntax @string/<string_name> whenever the XML attributes accepts a [string value](https://www.mindstick.com/forum/159623/how-to-get-an-enum-value-from-a-string-value-in-c-sharp).

```

<TextView       android:  layout_width=”wrap_content”      android:  layout_height=”wrap_content”      android:  text=”@string/hello_world” />
```

This post is referred from [Google docs](https://www.mindstick.com/blog/246065/office-365-vs-google-docs-features-comparison) Supporting Different Languages\

---

Original Source: https://www.mindstick.com/blog/700/android-support-for-different-languages

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
