Now in your package, create a new blank activity called MainActivity and add following code in it. Create new file in res/menu/ called menu_main.xml.īefore we move onto the java part, let us quickly create a custom dialog layout with a spinner in it to select our languages from. Next we add items to menu in which one would be used to show custom language selection dialog. If you want to copy/paste just to try, open strings.xml file in res/values-hi/ folder and add the following. Now let us quickly write translations for it. In that there is strings.xml file specifically having all the translated strings for that particular language. What it basically does is that in res/ folder of the project, it creates values-hi folder. Like I selected Hindi, so mine looks like that. Click Add Locale and select the language you wish to translate the strings to. In that you have buttons for Add key and Add Locale. Now see the image below, the translation editor looks like this. Strings.xml Settings Search Logout Developer Share App Change Language Change Password Īdd more if you want to. (Showing support for hindi in this tutorial) Before opening the translation editor, open your strings.xml file and write some strings in it. In that open up strings.xml file and one thing I found very useful in new Android studio is that it has an inbuilt translation editor which is pretty useful. Let’s codeĬreate a new android app project. We will see that how it is possible to do so. If you are not in a habbit of writing each and every string in strings.xml file then you probably should start doing that because it is easier to manage translations that way. Try to do it from the beginning otherwise you will end up with lots of strings to translate by the end. Supporting multiple languages in android app is one of the most important tasks.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |