Multilanguage Implementation on Android Using JSON Files and APIs

Ashu Maurya
2 min readMar 22, 2021

Generally Most of the Android Developers used Localization method for supporting Multilanguage. Android considers English as a default language and it loads the string from /res/values/strings.xml. In case, if we want to add a support for other languages, we need to create a values folder by appending the Hyphen and ISO language code.

But in these blog I will show another way of implementing multilanguage implementation using JSON Files or either with APIs.

Let’s get started…

Let make one Android Project which contatin two screen which is Login and Registration Screen..

Which means require two activity for that..

Now have to create one file named as “english_language.json” and “hindi_language.json” in the Android Studio and place it in /res/values/raw folder.

File Name: english_language.json
File Name: hindi_language.json

The concept is by default we would store a default json file of English in android studio, when we there is page in your project where you have to change the language then you call the api which return the json with same keys but value different according to the language u have selected as you can compare with above two json format.

When app is get installed by default it takes the json file of English language. It will extract them and stored it in shared preference….Afterwards we built an function which will extract sharedpreference and convert that into json format and according to there keys it will be set ….

File: LanguageUtils.kt

In the above code you can see the setlanguage() will set the language either Hindi or English from the inbuilt json files…

And according to the user setting the current language it will return the value in form of english and hindi value using the getLanguageString()

Whole concept has been used in the below github project …

https://github.com/ashumau845/seminarintroduction

Above architecture has been used In IOS ….Need to implement in Flutter

Thank you for reading this tutorial. Let me know in the comments if this tutorial helped you.

--

--