Skip to main content

Translate your Mobile App for free in 3 easy steps

This is a simple way to translate your Android (or iOs) application into multiple languages, without using an expensive professional translation service for the initial translation or having to write any additional code. The solution is easy to manage and share for review. I've used this approach in my last 4 jobs and it works for all classes of application. (In one company I used this approach to translate over 8000 strings for a web based app.).
Once you have completed the translation you can manage the strings in Google's Android Translation tool (https://developer.android.com/studio/write/translations-editor.html).

Warning: You should still use someone fluent in the chosen language to verify the final application and make sure you don't end up with something that does not fit your application.

These instructions assume that you have developed an Android application and have located your strings.xml file under the res/values/ directory. The steps are similar with iOs but are not covered here.

You will be using Google Spreadsheets, so you need a Google account. I could just share the spreadsheet - but where's the fun in that?

Step 1: Preparation

In your Android project copy the strings.xml file to strings.csv.
Open strings.csv in your favourite editor.
(I've used strings.xml in the screenshot to highlight specific strings).


 You are going to remove everything other than the text in yellow and white.

Remove all text before <resources> tag.
Remove the <resources> and </resources> tags.
Search and replace all </strings>
Search and replace all  <string name=
Search and replace all < characters with  ,

Your file should now look like this:



Step 2: Import into a Google Spreadsheet

Open a new Google spreadsheet. From the File menu click 'Import' and upload your csv file.











All being well you should have two columns in your spreadsheet. 

Now insert one row at the top of the spreadsheet.
Enter the following headers for each of the columns 

Col A: ui  - the meaning of your string
Col B: en - the two character language code of the source string (en = english in this case)
Col C: de - the two character language code of the target string (de = german in this case)
Col D: the target XML string 

You can read up on language codes here: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2

Your spreadsheet should look like this:


Step 3: Translate and generate <string> tags

Now here comes the fun ! Use the Google Translate function to do the translation for you.
The function takes the following format: source string, source language, target language. 

So based on this enter the following in column C, row 2. 

=GoogleTranslate($B2,$B$1,C$1)

The $ will ensure you are always using the same Row or Column (depending upon where it is used) - so in effect you told Google to

=GoogleTranslate  - translate
$B2                        - the text in col B  row 2
$B$1                      - using the language locale in col B row 1
C$1                        - to the locale in col C row 1














Now you have the translated strings we need to create the XML strings to add back into your app.

Recreate the XML string by concatenating column A and D in a <string></string> tag.
Enter the following formula in column D, row 2 onwards.  

= CONCATENATE ("<string name=", A4, ">", B4, "</string>")










Once the strings have been translated you can select column D and copy the contents into a text file called strings.xml and store this as per the Android instructions (in our example we would store the strings.xml file in /res/values-de/ ).

That's it - you're done!

Step 4: Extra credits


OK - this is good - but what if you want to translate multiple languages in one go? Just clone the spreadsheet and change cell C1 from 'de' to the (two or four) appropriate language string you want - such as 'fr', 'pt' 'ko' etc.



Comments

Popular posts from this blog

Host a static website on Google Drive (in 5 easy steps)

You need to host a static website but don't have the time, money or resources to set up a web server.  Perhaps you're learning to code or just doing a demo. Here's a way to set up a web site at no cost, in just a few minutes. Step 1. Create a new folder in Google Drive. From Google Drive, Click 'Create', select 'Folder' and enter the folder name. (I chose 'hybrid' for this example, but you can choose anything you want). Step 2. Share the folder. First select the folder you created (displayed in the folder list), then click the sharing icon. In the Sharing Settings popup, go to the 'Who has access' section and click 'Change' The Visibility options pop up will appear. Change the Visibility option to 'Public on the web'.  Although set by default, make sure that 'Access' is set to 'Can view'. Click 'Save'. The folder is now shared. Click D...

How to get the BBC iPlayer running when you live outside of the UK

(subtext: Get the World's most famous detective on your favourite browser) The new series of Sherlock has started on the BBC. If you live outside of the UK and you are too impatient to wait for your local TV content provider to host it for you - then fear not !! These simple instructions will get you up and running. In addition to the iPlayer you can access most of the other UK TV channels using the same method. Note: you can use the same method to access content in other countries - such as Hulu in the U.S. How it works:  In simple terms, the BBC iPlayer, like other players, perform a check to determine whether your internet access is originating from the UK.  So the trick is to ensure that your access to the BBC website will originate from the UK. First you are going to use a free piece of open source software that was designed to keep your internet access anonymous. You will add a setting that will ensure that the software makes use of servers in the UK whenever ...

Skip the grunt work: Use AI to turn raw data into Slides (Part 1)

Scenario You've got to create a presentation using data from multiple CSV files. Typically, this means merging files into a single spreadsheet, generating charts, and copying everything into your presentation—an absolute time sink! Let’s fix that. Here’s a free, no-code approach using Google Workspace tools and a sprinkle of automation. This is Part 1 of a two-part series. The Problem Simplified: Multiple CSV files in a consistent format (I used stock data). The goal: Combine into one Spreadsheet for easy analysis and charting. How: Instead of manual copy-pasting, we’ll automate the process using Google Apps Script and Chat-GPT for code generation. What You'll Need: Google Apps account: A free Gmail account will work perfectly. Access to Google Drive , Google Sheets , and Google Slides. Chat-GPT 's free edition for code snippets. Step-by-Step Solution: 1. Collect your data Upload the CSV files to Google Drive. Copy the Drive folder ID. The folder ID is the part of the URL ...