Skip to content

Smart app localisation using Firebase remote config

App localization is an important key factor to be considered in Android development when you are building your app for a wide variety of user base. Most of the cases, developers use some 3rd party tools to generate in-app content in various languages and pack it into the app resources and send it to the production. The localization of the app content allows the businesses to reach more markets and deliver a personalized experience to the customers. It assists in maintaining the transparency and portability of your idea or organisation. Also, it acts as an aid for a strategic result driven approach to ensure a higher revenue and produce higher ROI. This tutorial will take you to thoughts on Android Localisation using Firebase Remote Config.

In India alone, there are 22 official and 122 unofficial languages. From the developer perspective, implementing in-app contents in different configurations (based on language) is definitely a hectic pain. Also sometimes, you may not be having time for adding these contents on a way to release. Think about last minute assignments on these works before a weekend. Ridiculous right? Also, sometimes your content team find a serious grammatical mistake or big illogical content mistake in your app after the release. Again, you have to make a new release with corrected content. and your users should update to the latest. Please note that app-updates are still haunting headache for many users nowadays. These tasks make your Android development more uneasy and painful.

In my company, which is an Ed-Tech start-up based in India delivers a test preparation application for students, we have implemented a smarter way of localisation for in-app contents using Google’s Firebase Remote Config. This made the maintaining of in-app content is very easy and flexible for us. For those who don’t know about Firebase Remote config, it is a tool from Firebase, where you can define key-value pair in the console and using the remote config implementation we can fetch value using the predefined key. You can simply change the behaviour of an application without requiring the updating of the application using the Remote Config tool. Your app controls when updates are applied, and it can frequently check for updates and apply them with a negligible impact on performance.

So let’s start implementing the localisation using Remote Config in an Android application. You can add the Firebase Remote Config dependency using the Gradle command below.

implementation '{VERSION}'
implementation '{VERSION}'

After you have added the dependency, You are all set to implement the logic. In Firebase, there is a concept called User Properties. It is used to identify the different attributes of the users of your application. Language is a user property we have to define. So let’s move to Firebase console and define a new user property called `language`  By pressing the create button we have created a new user property. So when the user chooses a language in your app you have to set this user property with a value. For example, if the user selects the language French, we just mention a the Firebase that the user language is French by using below code


Once this set, The Firebase will recognise the user property with a value and will save this in its own memory. Now here comes the magic part. How are the localisation for multiple languages done? Let’s move to Remote Config section of the Firebase console where you can find a button to add a new key-value pair.

For example, if we have to add a welcome message in the different language for different users, we have to click on Add value for the condition to define a new value. So here is the tricky part, We have a user property called languageright, isn’t it? If you click on the drop down of Applies if menu, you can see that you can define a value for a property called language. Now select the next drop down and select exactly matches condition option. In the values field, you can give the value french which is the language code for French in the property. You can also add more conditions like OS version, App version etc.,

All set! You can create the condition and publish the change to your console. To fetch this value in your app just call this line after fetching your values from the console.

String message=FirebaseRemoteConfig.getInstance().getString("welcome_key");

The value of message will be in French since we have set the user property as french. Same as like this, you can add more languages and appropriate content in the console and fetch them in regular intervals. If your app needs a sudden change in user language, you have to make an urgent value fetch call preceding after resetting the user property. So that the new values for new language will be cached.

The more benefits of this method we found were

  1. There is no need to roll out new updates for each and every content update. It will look like our app is backwards compatible.
  2. If your team introduces a new language for your app, There is no need to create separate assets. Your app size can be reduced by avoiding this kind of works.
  3. You can have more advanced content by implementing more user properties. This will make your app more responsive and smarter.
  4. From a development perspective, handling content is not your cup of tea. So that you can handover this console or you can build your own console using their REST APIs for updating in-app content to appropriate teams. As result, your vacations will not be spoiled!
  5. You can have up to 500 key-value pairs in a free plan itself! Isn’t cool it?
  6. As a higher thought, you can save some JSON/XML in a key-value pair for more contents and parse them into a POJO using parsing library if needed.

Also, the time required for implementing these kinds of stuff are really less and the Firebase server was more responsive on most of the time.Thank you for reading this article.You can ask any queries regarding this topic below.

Thank you

Published inAndroidFirebase

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *