I. Introduction

When developing applications that require support for multiple languages, localization automation can streamline the process by automatically managing string files that define key-value pairs. These key-value pairs consist of unique keys that retrieve corresponding values for content specific to the selected language, simplifying the management of language-specific data.

When working on multi-platform projects, it is important to be aware that each platform may have its own unique string file format. For example, iOS uses the .strings format, while Android uses .xml, and Flutter uses the .json format. These file formats have different structures and syntax, which can make it challenging to manage language-specific data across multiple platforms.

II. Problem

Localization workflow automation can address common challenges in multilingual projects by streamlining processes and minimizing errors:

– Collaborators editing the same string file may lead to conflicts or duplicate keys.

– The teams (iOS and Android) do not agree on keys. Usually, developers do not decide the values but rely on translators or clients to provide them. If the keys are not the same, it causes many difficulties.

– For each key, the developer needs to provide temporary values for the corresponding language without knowing the meaning by using Google Translate to translate and then copy into each file.

III. Solution

Google Sheets provides an ideal platform for collaboration on a single file, as it enables multiple users to access and edit the same file simultaneously. By leveraging the power of Google Sheets, developers can work together on a single file in real-time, thereby streamlining the collaboration process and enabling more efficient workflows.

This approach can be particularly helpful for multi-person projects, as it allows team members to view and modify the same data, share feedback, and make updates as needed.

Define key-value pairs for English

In mobile development, localization string files are typically used to provide translations for app content in different languages. Key-value pairs are a common way to define these translations in these files.

By using Google Sheets in conjunction with localization automation, teams can enhance efficiency, minimize errors, and maintain consistency across platforms, all while simplifying collaboration in multilingual projects.
Define key-value pairs for English

Write a script to automatically generate content for the corresponding string files for each language

What is Google Apps Script?

Google Apps Script is a platform for developing applications quickly, designed to facilitate the creation of business applications that can be seamlessly integrated with Google Workspace. By using modern JavaScript, developers can easily write code that leverages the built-in libraries available for popular Google Workspace applications, including Gmail, Calendar, Drive, and many more.

Access the Apps Scripts editor

Access the Apps Scripts editor

By utilizing Google Apps Script, developers can write functions to convert key-value pairs into string files within Google Sheets, with the script being based on JavaScript.

By utilizing Google Apps Script, developers can write functions to convert key-value pairs into string files within Google Sheets, with the script being based on JavaScript.

We define 3 functions for 3 platform (iOS, Android, Flutter), each function will have 3 parameters

Screens: all values of the screen name.

Keys: all values of the keys

Values: all values of the value

The function is designed to merge values with their corresponding keys and screens, creating a final output that accurately reflects the original data. To accomplish this, the function loops through all values and matches them with their respective keys and screens before merging them.

For strings with internal formats, we convert them to the correct format for each platform using the replace function.

– For example, %s will be converted to %@ on iOS.

Code

iOS

iOS

Android

Android

Flutter

Flutter

Back to the Google Sheet file, using the corresponding functions for iOS, Flutter, and Android.

Back to Google Sheet file, using the corresponding functions for iOS, Flutter, and Android.

Back to Google Sheet file, using the corresponding functions for iOS, Flutter, and Android.

For other languages, we use Google Translate to translate and then use the localize function above to generate the corresponding string files. When using GOOGLETRANSLATE to convert text from one language to another, it is necessary to specify the two-letter language codes of both the source and target languages as the 2nd and 3rd parameters.

For other languages, we use Google Translate to translate and then use the localize function above to generate the corresponding string files.

After completing the necessary steps to generate values for iOS, Android, and Flutter, the next action is to copy these values into a text editor. By doing so, developers can easily view and compare the results side-by-side, making it easier to identify any discrepancies or errors that may require further attention.
After completing the necessary steps to generate values for iOS, Android, and Flutter, the next action is to copy these values into a text editor.

Automatically update the corresponding values for each file.

Automated localization helps address the challenge of keeping string files updated after edits by automating the synchronization process. Manually copying and pasting values every time a change is made can be a tedious and error-prone task, which is why we leverage the tool `gspread` (https://github.com/burnash/gspread) to streamline this process.

By utilizing `gspread`, developers can automate the synchronization of data between the string files and the corresponding values, thereby reducing the risk of human error and saving valuable time and resources. This automation ensures that the project remains up-to-date and accurate, while also enabling a more efficient and streamlined development process.

Automatically update the corresponding values for each file

Automatically update the corresponding values for each file

After installing `gspread`, we create a tools folder in each corresponding platform, where we have 2 files updateLocalization.py and updateLocalization.sh

– updateLocalization.py is used to access the Google Sheet file and copy the desired cell value. The Column value is determined by the first parameter of the argument vector, and the Row value is the same as the Row with the cell value gspreadIOS.

– updateLocalization.sh is used to call updateLocalization.py to get the value and copy it to the string file.

Every time we need to update the content of the string file, we only need to run a single command.
Automatically update the corresponding values for each file

Automatically update the corresponding values for each file

Automatically update the corresponding values for each file

IV. Conclusion

Localization automation, utilizing Google Sheets and Scripts, significantly simplifies the management of language-specific data in mobile, front-end, and back-end development. This approach offers a convenient and efficient way to manage language-specific data and automate the synchronization of data between various platforms.

By leveraging the power of Google Sheets and Scripts, localization automation enhances accuracy and efficiency, making it easier to maintain consistent language support across all platforms. This approach can be especially beneficial for multilingual projects or projects that involve frequent updates and changes, as it allows developers to easily manage and update language-specific data in a centralized location.

Our developers have experience with hundreds of mobile projects and know the latest trends and technologies to make your app stand out. Get expert consultation and top-notch support from us now!

Resources
Demo source code: Repos’s link

Employee

Hire Software Developers

Access top talent and accelerate your project by hiring expert software developers today.
Discover Our Services arrow
Content manager
Thanh (Bruce) Pham
CEO of Saigon Technology
A Member of Forbes Technology Council

Related articles

Mobile App Development Trends to Look Out
Industry

Mobile App Development Trends to Look Out

Over the years, smartphones and mobile apps have continued to grow in popularity across users from different demographics. Today, a very big percentage of mobile phone users have access to smartphones which come reloaded with mobile apps
Explore How to Outsource App Development Effectively
Methodology

Explore How to Outsource App Development Effectively

Explore crucial insights into how to outsource app development with Saigon Technology, providing guidance on best practices, and expertise assessment.
Custom App Development: The Ultimate Guide To Build Successful Apps For Businesses
Enterprise

Custom App Development: The Ultimate Guide To Build Successful Apps For Businesses

Custom app development is a complex process with dozens of variables. We provide custom app development services, helping you succeed in 2025.
Unlocking the Potential of .NET MAUI for Frontend and Web Developers
Methodology

Unlocking the Potential of .NET MAUI for Frontend and Web Developers

Let our .net development company help you hire .net developers and unlock the potential of .NET MAUI. Begin your Web Application Development projects with .NET MAUI.
Testing of Mobile Application – Challenges and Best Practices
Methodology

Testing of Mobile Application – Challenges and Best Practices

With the convenience of smartphones, more and more people use them today. For that reason, mobile testing becomes essential before the app is released, to make sure the functions work properly and the user's data is secured. Let's explore the basics of mobile testing in this article.
calendar 07 May 2024
Supabase: Build an ready to published TODO app in just 30 minutes
Technologies

Supabase: Build an ready to published TODO app in just 30 minutes

This article will help you understand what Supabase is and how you can achieve it to build your application more robustly and efficiently by exploring it and creating a Todo app.
calendar 20 Jun 2024
Deep Dive on MAUI Application
Technologies

Deep Dive on MAUI Application

This article offers real-world solutions for addressing these issues when building an enterprise application using .NET MAUI. Whether you're developing a new business application or tackling the evolving problems of existing ones, this content will be invaluable for you.  
calendar 30 Aug 2024

Want to stay updated on industry trends for your project?

We're here to support you. Reach out to us now.
Contact Message Box
Back2Top