Skip to content
Twaha Mukammel edited this page Aug 20, 2021 · 3 revisions

Welcome to the locale-automator wiki!

A Localization automator bot

Problem description

Given a software project code base which needs to have multiple locale support,

  1. How can a program decide an idempotent key for a localizable element (e.g text label) in a given context in code for a developer
  2. How can a program extract all the used locale keys and default locale values occurring in the code base
  3. If we have an excel sheet with key and values, how can a program update locale files without manually copying the values from the sheet

Target

  1. Protocol (locale key generation convention) to make locale keys idempotent
  2. No manual locale file management
  3. No human error in localization update
  4. Keep client localization sheets and locale files in project always in sync
  5. Should work for multiple platforms

Functions:

V1.0

  1. Automated locale file management

    a. Insert and update locale from code occurrences
    b. Insert and update from excel sheet

  2. Export locale files as excel sheets
  3. Import locale files from excel sheets
  4. Platforms: JavaScript, iOS, Android

V1.0 Application flow

Step 01:

In some code, e.g

// locale key: common.title.label.appName
// locale value for default english locale: Locale Bot
row.lblLastName = i18n(common.title.label.appName); // Locale Bot

To extract all locale key values from similar code occurances

$localebot extract --platform:iOS --dir:src

Or extract from specific file

$localebot extract --platform:iOS --file:src/views/pages/appLaunchScreen

This will update all locale files with default locale value

// bn.json
{
"common.title.label.appName": "Locale Bot"
}
// ja.json
{
"common.title.label.appName": "Locale Bot"
}
// en.json
{
"common.title.label.appName": "Locale Bot"
}

Step 02:

Export the locale fiels to excel sheet for linguists to to update the locale values for different locales

localebot export --to:xls

This will export one excel file with one sheet for all locale at current localization state

localebot.xls

key bn en ja
src.views.pages.patientdetailsViewController.label.firstname Locale Bot Locale Bot Locale Bot

If the file was already localzed, the output would be something like:

localebot.xls

key bn en ja
src.views.pages.patientdetailsViewController.label.firstname স্থানীয়করণ বট Locale Bot ローカリゼーションボット

Step 03:

After the excel sheet is updated by linguists

import the updated file back into project

localebot import --file:~/localebot.xls

This will update all locale files with latest values from the excel sheet

// bn.json
{
"common.title.label.appName": "স্থানীয়করণ বট"
}
// ja.json
{
"common.title.label.appName": "Locale Bot"
}
// en.json
{
"common.title.label.appName": "ローカリゼーションボット"
}

V2.0

  1. System for Automatic, idempotent, unique locale key suggestion

    a. Suggest in code context
    b. Automatic suggestion
    b. Idempotent suggestion
    b. Unique suggestion

  2. Coding ide extension for

    a. VSCode
    b. Android Studio
    c. Xcode

Result:

  1. Faster development: Not manage the locale files manually
  2. Easier identification of locale keys (readability of locale keys)
  3. Faster and always accurate replacement of translations