How to use
InAppTranslation

Taka Mizutori
4 min readSep 25, 2015

--

InAppTranslation framework only support Swift project as of now. We will soon support Objective-C

Get Started

Register yourself to InAppTranslation in inapptranslation.com

After the registration, click “Register a new app” button to add your app on Dashboard.

Press “CREATE NEW APP” button to register your app on the Dashboard

After creating an app, open the app, click “App Setting” button on the right of the menu bar and open App Settings page. Here you can get a “token” which will be later used when you embed InAppTranslation.framework.

Press “App Settings” tab and visit App Settings page. You can get App Token.

Installing iOS library

Next step is to install InAppTranlsation libary to your XCode project.
Add

to your Podfile, and then run “pod install”. That’s it. Below is an example of the Podfile.
(If you’ve not integrated cocoapods to your project yet, run “pod init” to setup cocoapods on your project first.)

Open your AppDelegate.swift, and then override initialize() method. In the method, add “InAppTranslation.start()” as below example. You place the token string to the first parameter of the InAppTranslation.start() method. Copy and paste the token from the InAppTranslation dashboard. Below is an example.

Async Mode

Above example will let the InAppTranslation to fetch the translation data “before your app starts”, so that the translation data is ready when your app starts. This means it will take a few milli seconds for the InAppTranslaiton library to fetch the data after the launch of your app. If you don’t want to have this delay, we provide “Async Mode”. By starting InAppTranslation with async mode, InAppTranslation’s fetch operation doesn’t block your app launch. With Async mode, the translation data is not reflected to the UI at the 1st launch but from the 2nd launch of the app. So you won’t see the UI translated at the 1st launch, but if you kill the app and relaunch, the UI is translated by the data fetched from InAppTranslation. To start InAppTranslation in the async mode, put “true” to the 2nd parameter of the start() method like below example.

Now, all the installation done, you are ready to add translation data.
You can find more detail of the async mode behavior from here.

Prepare translation

From Dashboard top, open your app.

Press “+ ADD NEW KEY” button to add words.
Keys here are the ones used in NSLocalizedString as the 1st parameter, or title strings used in UIButton or other UIKit components in Storyboard. (In Localizable.strings files, keys are the strings on the left hand side of each line.)

Automatically Adding Keys

InAppTranslation iOS library automatically registers keys if it’s not registered yet. This happen in two cases

  • NSLocalizedString is called with a key, but the key is not found in the translation data (i.e. not registered in the InAppTranslation dashboard.)
  • UI is loaded from Storyboard, and texts in the Storyboard such as UIButton titles and UILabels are not found in the translation data (i.e. not registered in the InAppTranslation dashboard.)

After finish adding all the keys, you can press “Add new language” button to add languages you want to support. New column is added when you add new language. On this new language column you can add translation data for that language.

Now you’ve done all the basic setup, and your app is ready to get translation data from InAppTranslation.

Import existing Localizable.strings file

If you already have some translation data in the form of Localizable.strings files, you can import those files from “Import” button.

Each time you import a Localizable.strings file, new column (for that language) is added and translation data (i.e. right hand side values of Localizable.stirngs file) is added to the column.

Export Files

You can easily bring out the data from InAppTranlsation to both Localizable.strings file for iOS or strings.xml file for Android platform.
Press “Export” button and select iOS or Android.

Analytics and User Feedback

InAppTranslation has a powerful feature — Analytics and User Feedback.

Analytics is on immediately after you start InAppTranslation iOS library.
User Feedback requires you to write one line of code.

Calling this method will pop up an alert like below. And users answers are counted and shown in the User Feedback dashboard.

If the you choose “No” (i.e. Unsatisfied), the iOS SDK shows a view like below. Here the user can report which translation he or she thinks bad.

Analytics and User Feedback dashboard will show the results of these stats. Check below link for more detail on Analytics and User Feedback dashboard.
InAppTranslation — Analytics & User Feedback

--

--

Taka Mizutori

Founder and CEO of Goldrush Computing Inc (https://goldrushcomputing.com). Keep making with Swift, Kotlin, Java, C, Obj-C, C#, Python, JS, and Assembly.