Lingua

1.0.1

A unified localization management tool for iOS & Android
poviolabs/Lingua

What's New

1.0.1

2023-11-21T15:00:36Z

What's Changed

Full Changelog: 1.0.0...1.0.1

Lingua

Documentation

Lingua

Lingua is a tool designed to streamline the localization process for iOS and Android platforms. It provides a unified solution for generating localization files from a single source, Google Sheets.

There are several benefits of using the tool:

  • Unified translation system for iOS and Android platforms

  • Seamless integration with project workflows for automatic translation imports

  • Minimized risk of typo errors in localization usage

  • Enhanced productivity through intelligent auto-completion and semantic clarity

  • Safeguard against referencing non-existent translations

Setup Google Sheet

In order to setup Google sheet, we need to complete two steps. First one is to create a sheet with predefined structure, and the second one is to obtain api key and sheet id.

a. Sheet Document

We have prepared a tamplate for sheet structure for you. What you have to do is to open the link below and make a copy File > Make a copy

Mobile Localizations Template - Google Sheets

Sheet structure: For detailed information about the sheet structure used in the Lingua localization tool, please refer to the Sheet Structure Documentation.

Important: Make sure to replace the existing API key in your application with the newly generated one. Also, ensure that the Google Sheet you're trying to access has its sharing settings configured to allow access to anyone with the link. You can do this by clicking on "Share" in the upper right corner of the Google Sheet and selecting "Anyone with the link."

b. Obtain the sheet id

The sheet id can easly be accessed from the url after you have create a copy of the document tamplate.

https://docs.google.com/spreadsheets/d/ 1GpaPpO4JMleZPd8paSW4qPBQxjImm2xD8yJhvZOP-8w

c. Obtain the API key

Here are the steps to enable the Google Sheets API and create an API key:

  1. Go to the https://console.cloud.google.com/.

  2. If you haven't already, create a new project or select an existing one.

  3. In the left sidebar, click on "APIs & Services"

  4. Click on "+ ENABLE APIS AND SERVICES" at the top of the page.

  5. In the search bar, type "Google Sheets API" and select it from the list.

  6. Click on "ENABLE" to enable the Google Sheets API for your project.

  7. After the API is enabled, go back to the "APIs & Services" > "Credendtials" page.

  8. Click on "CREATE CREDENTIALS" at the top of the page.

  9. In the dropdown, select "API key"

Wait a bit until the key is generated and an information modal with the message API key created will be shown.

Usage

1. macOS App

The Lingua macOS app provides a user-friendly interface for managing your localization process seamlessly. You can configure your settings and initiate the translation process directly from the app.

Installation

You can download the macOS app from App Store. Follow the installation guide available on the page to get started with the app.

Features and Usage

  • Settings Configuration: Easily configure and manage your settings through the app's settings panel.
  • Translation Initiation: Initiate the translation process with a single click without the need for terminal commands.

2. Terminal App

For those who prefer using the terminal or require scriptable solutions, Lingua offers a terminal app that allows you to manage and initiate translations directly from the command line.

Installation

Currently we support the tool to be installed via Homebrew

$ brew tap poviolabs/lingua
$ brew install lingua

Configuration file

Create a configuration file as a starting point to adapt as your needs, lingua_config.json or any other .json file.

To create a sample configuration file as a starting point to adapt to your needs, runĀ lingua config init. The tool will create a file named lingua_config.json in the directory you are running the Lingua tool.

Then in the configuration file created you need to provide your data, like below:

{
   "localization": {
        "apiKey": "<google_api_key>",
        "sheetId": "<google_spreadsheet_id>",
        "outputDirectory": "path/to/Resources/Localization"
    }
}

Output directory

The output directory property should be the path where you want the tool to create localization files.

  • For iOS it can be any directory on your project. After you run the command, for the first time, you have to Add files to 'YourProject' in Xcode.

  • For Android, since the translation are placed in a specific project directory, the output directory it should look something like this: path/YourProject/app/src/main/res

iOS specific

Since iOS does not have a built in feature to access the localization safely, we have made this possible using Lingua tool. In the configuration file you have to provide the path where the default language strings are stored and where the Swift file you want to be created. With that the tool will create Lingua.swift with an enumeration to easily access localizations in your app.

{
   "localization": {
        "apiKey": "<google_api_key>",
        "sheetId": "<google_spreadsheet_id>",
        "outputDirectory": "path/to/Resources/Localization",
        "swiftCode": {
           "stringsDirectory": "path/to/Resources/Localization/en.lproj",
           "outputSwiftCodeFileDirectory": "path/to/Resources/Localization"
        }
    }
}

Now you can run the tool in terminal, switch to your project directory and run:

iOS

$ lingua ios /path/to/lingua_config.json

Android

$ lingua android /path/to/lingua_config.json

Best Usage Practices

To ensure you're leveraging the tool optimally, both locally and in the context of CICD, we recommend you delve into our Best Usage Practices guide.

Description

  • Swift Tools 5.7.0
View More Packages from this Author

Dependencies

  • None
Last updated: Fri Jan 19 2024 09:11:30 GMT-1000 (Hawaii-Aleutian Standard Time)