A flexible tool for application localization using Google Sheets.

Overview

Logo

goloc

A flexible tool for application localization using Google Sheets.

Table of Contents

Features

  • Easy configuration
  • High configurability
  • Precise error reporting
  • Multiple supported target platforms
  • Customizable format strings
  • Missing localization reports

Supported OS / architectures

goloc can be built for each OS/architecture supported by golang, but release archives contain binaries only for amd64 architecture for macOS, Linux and Windows.

Supported formats

Setup

  • Download a goloc.zip file from the latest release and unpack it into your project's root folder
  • Download client_secret.json file from Google API Console and put it inside a newly created goloc folder. To do so, follow these steps:
    • Open Google API Console
    • Select a project (or create a new one)
    • Press ENABLE APIS AND SERVICES button
    • Find Google Sheets API
    • Press ENABLE
    • Go to Dashboard->Credentials
    • Press Create credentials->Service account key
    • Select any type of service account and JSON for key type, then press Create
    • Rename the downloaded file to client_secret.json and put it into a goloc folder of a project
  • Create a new localization document
  • Share your localization document with a service account created previously. To do so, follow these steps:
    • Open the client_secret.json file
    • Copy the client_email value
    • Open the localization document
    • Press SHARE button
    • Paste the client_email value into the People input field.

Localization document

Each localization document consists of formats and localizations sheets. One localization document can have multiple sheets for both.

The simplest way to create a new goloc-compatible localization document is to copy the sample spreadsheet. However, you can easily create a goloc-compatible localization document yourself just by following the simple requirements described below.

Localizations sheet

Example localizations sheet

On the example above you can see a goloc-compatible localizations sheet. The rules to make a localizations sheet goloc-compatible are:

  • First row must contain column names
  • There must be exactly one key column and at least one language column
  • Key column can have any name, but the dafault name is key
  • Each language column must be named as lang_<lanaguage code>
  • To define a format string, you can use {format_name} in place of the formatted value (each format must be specified in the formats sheet)

Formats sheet

Example formats sheet

On the example above you can see a goloc-compatible formats sheet. The rules to make a formats sheet goloc-compatible are:

  • First row must contain column names
  • There must be exactly one format column and at least one platform column
  • Format column can have any name, but the dafault name is format
  • Each platform column must have a name of a goloc-supported platform.
  • Empty format name can be used to define a default format (used as {})

Usage

  • Create a script or build task definition with parameters best suited for your project. To see available parameters, run goloc --help. goloc is distributed in form of separate executables for each platform, so don't forget to take that into account creating localization script.
  • Execute the script/task whenever you want to update localized strings. goloc will automatically replace any existing localization files with the updated ones.

Android

No special configuration in code is required.

Example gradle task specification:

task "fetchLocalizations"(type: Exec) {
    def osName = System.getProperty('os.name').toLowerCase()
    def isWindows = osName.contains("win")
    def isMac = osName.contains("mac")
    def isUnix = osName.contains("nix") || osName.contains("nux") || osName.contains("aix")

    def params = [
            '--credentials', "goloc/client_secret.json",
            '--platform', 'android',
            '--spreadsheet', '1MbtglvGyEey3gH8yh4c9QovCIbtl5EcwqWqTZUiNga8',
            '--tab', "localizations",
            "--key-column", "key",
            '--resources', "app/src/main/res/",
            '--default-localization', 'en',
            '--default-localization-file-path', "app/src/main/res/values/localized_strings.xml"
    ]

    if (isWindows) {
        params = ['cmd', '/c', 'goloc\\windows_amd64.exe'] + params
    } else if (isMac) {
        params = ['./goloc/darwin_amd64'] + params
    } else if (isUnix) {
        params = ['./goloc/linux_amd64'] + params
    } else {
        logger.error('Your OS is not supported.')
        return
    }

    commandLine params
}

Flutter

Localized strings can be accessed through AppLocalizations.of(context)

Requirements:

  • Add sprintf: ^4.0.2 to the dependencies section of pubspec.yaml
  • Add AppLocalizationsDelegate() to localizationsDelegates of the app widget constructor
  • Specify supported localizations in supportedLocales of the app widget constructor
  • (Recommended) Add DefaultIntlLocaleDelegate() to localizationsDelegates of the app widget constructor. This will make intl-dependent formatters use currently selected locale.
class DefaultIntlLocaleDelegate extends LocalizationsDelegate<Null> {
  @override
  bool isSupported(Locale locale) => true;

  @override
  Future<Null> load(Locale locale) {
    Intl.defaultLocale = locale.toLanguageTag();
    return Future.value(null);
  }

  @override
  bool shouldReload(LocalizationsDelegate<AppLocalizations> old) => false;
}

Example bash localization script:

#!/bin/bash

case "$OSTYPE" in
  darwin*)  EXECUTABLE="darwin_amd64" ;;
  linux*)   EXECUTABLE="linux_amd64" ;;
  msys*)    EXECUTABLE="windows_amd64.exe" ;;
  *)
	  echo "Platform is not supported: $OSTYPE"
	  exit 1
  ;;
esac

goloc/${EXECUTABLE} -c goloc/client_secret.json -p flutter -s 1MbtglvGyEey3gH8yh4c9QovCIbtl5EcwqWqTZUiNga8 -t localizations -r lib/intl

macOS Catalina usage notes

Due to the security improvements in the macOS Catalina, any 3rd party application downloaded from the internet has to be notarized to be launched without additional actions from the user side. Since goloc is entirely free, I can't afford Apple Developer Program subscription for notarizing macOS builds. Luckily, Apple has left a way to launch a non-notarized app, but it requires some actions.

Here's the instruction on how to launch goloc on macOS Catalina:

  1. Upon the first launch you'll see a window like this:catalina_0
  2. Go to settings and choose Security & Privacy:catalina_1
  3. Choose Open Anyway:catalina_2
  4. Re-launch goloc, and you'll see a next window:catalina_3
  5. Choose Open. Next time you launch goloc, macOS won't complain anymore.

License

Released under the MIT License.

You might also like...

tool for art challenges check

ArtTime This is a tool for artists to have a simple and fast art challenges check. Links Demo Video Architecture plan Plan (What to expect from this p

Oct 11, 2021

Metask is an intuitive tool for project management and task management.

Metask is an intuitive tool for project management and task management.

Metask is an intuitive tool for project management and task management. It is ideal for your personal organization, but also for efficient teams.

Nov 5, 2022

A Real-time Fps Tool for Android

A Real-time Fps Tool for Android

fpsviewer A Real-time Fps Tool for Android, 一个能实时显示fps,一段时间的平均帧率,以及帧率范围占比,并能获取卡顿堆栈的可视化工具。侵入性低,通过在异步线程采样获取堆栈,无代码侵入,性能消耗可忽略,对性能监控项的异常数据进行采集和分析,整理输出展示相应的

Dec 27, 2022

A command-line tool which simplifies the task of updating your Flutter app's launcher name

flutter_launcher_name A command-line tool which simplifies the task of updating your Flutter app's launcher name. If you user this package, You don't

Nov 13, 2022

The Device Fingerprint tool collects thorough insight about the devices associated to a user.

The Device Fingerprint tool collects thorough insight about the devices associated to a user. Account takeovers and multiple account signups, payments can easily be avoided by applying the Device Fingerprinting module.

Nov 28, 2022

A sample application to show Google Drive Flutter Clone.

A sample application to show Google Drive Flutter Clone.

Flutter Google Drive UI Demo A sample application to show Google Drive Flutter Clone. Demo Android Screen iOS Screen Getting Started This project is a

May 6, 2021

Google Keep Clone using flutter

flutter_google_keep_clone A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get yo

Apr 29, 2022

Library App Using Google Books API

Library App Using Google Books API

Library App USing Google Books API A new Flutter project. Getting Started For he

Nov 2, 2022

A Flutter plugin for the Google Mobile Ads SDK

A Flutter plugin for the Google Mobile Ads SDK

Jan 2, 2023
Comments
  • [Build] Could not build binary from source code.

    [Build] Could not build binary from source code.

    Problem:

    Could not build the binary from source code.

    1. Clone repo.
    2. Go to folder.
    3. Try to build.
    $ sh build.sh  
    
    1. Receive an error.
    3 errors occurred:
    --> darwin/amd64 error: exit status 1
    Stderr: main.go:6:2: cannot find package "github.com/s0nerik/goloc/tree/master/goloc" in any of:
            /usr/local/Cellar/go/1.10.2/libexec/src/github.com/s0nerik/goloc/tree/master/goloc (from $GOROOT)
            /Users/MSavisko/go/src/github.com/s0nerik/goloc/tree/master/goloc (from $GOPATH)
    main.go:7:2: cannot find package "github.com/s0nerik/goloc/tree/master/platforms/resolver" in any of:
            /usr/local/Cellar/go/1.10.2/libexec/src/github.com/s0nerik/goloc/tree/master/platforms/resolver (from $GOROOT)
            /Users/MSavisko/go/src/github.com/s0nerik/goloc/tree/master/platforms/resolver (from $GOPATH)
    main.go:8:2: cannot find package "gopkg.in/alecthomas/kingpin.v2" in any of:
            /usr/local/Cellar/go/1.10.2/libexec/src/gopkg.in/alecthomas/kingpin.v2 (from $GOROOT)
            /Users/MSavisko/go/src/gopkg.in/alecthomas/kingpin.v2 (from $GOPATH)
    --> windows/amd64 error: exit status 1
    Stderr: main.go:6:2: cannot find package "github.com/s0nerik/goloc/tree/master/goloc" in any of:
            /usr/local/Cellar/go/1.10.2/libexec/src/github.com/s0nerik/goloc/tree/master/goloc (from $GOROOT)
            /Users/MSavisko/go/src/github.com/s0nerik/goloc/tree/master/goloc (from $GOPATH)
    main.go:7:2: cannot find package "github.com/s0nerik/goloc/tree/master/platforms/resolver" in any of:
            /usr/local/Cellar/go/1.10.2/libexec/src/github.com/s0nerik/goloc/tree/master/platforms/resolver (from $GOROOT)
            /Users/MSavisko/go/src/github.com/s0nerik/goloc/tree/master/platforms/resolver (from $GOPATH)
    main.go:8:2: cannot find package "gopkg.in/alecthomas/kingpin.v2" in any of:
            /usr/local/Cellar/go/1.10.2/libexec/src/gopkg.in/alecthomas/kingpin.v2 (from $GOROOT)
            /Users/MSavisko/go/src/gopkg.in/alecthomas/kingpin.v2 (from $GOPATH)
    --> linux/amd64 error: exit status 1
    Stderr: main.go:6:2: cannot find package "github.com/s0nerik/goloc/tree/master/goloc" in any of:
            /usr/local/Cellar/go/1.10.2/libexec/src/github.com/s0nerik/goloc/tree/master/goloc (from $GOROOT)
            /Users/MSavisko/go/src/github.com/s0nerik/goloc/tree/master/goloc (from $GOPATH)
    main.go:7:2: cannot find package "github.com/s0nerik/goloc/tree/master/platforms/resolver" in any of:
            /usr/local/Cellar/go/1.10.2/libexec/src/github.com/s0nerik/goloc/tree/master/platforms/resolver (from $GOROOT)
            /Users/MSavisko/go/src/github.com/s0nerik/goloc/tree/master/platforms/resolver (from $GOPATH)
    main.go:8:2: cannot find package "gopkg.in/alecthomas/kingpin.v2" in any of:
            /usr/local/Cellar/go/1.10.2/libexec/src/gopkg.in/alecthomas/kingpin.v2 (from $GOROOT)
            /Users/MSavisko/go/src/gopkg.in/alecthomas/kingpin.v2 (from $GOPATH)  
    

    Configuration:

    1. OS: macOS High Sierra 10.13.4
    2. GO: go1.10.2 darwin/amd64
    3. Gox: stable 0.4.0 (bottled)
    4. Source: v0.9
    
    opened by MSavisko 5
  • Add support for region codes

    Add support for region codes

    We found ourselves facing a situation where we need to use region-specific localization, but we don't see any way to do it with goloc.

    Example of language tags with region components: fr-FR, fr-CA, en-GB, en-US, ar-KW, ar-SA.

    Example of resource folder names on android: values-fr-rFR, values-fr-rCA, values-en-rGB, values-en-rUS.

    enhancement design-needed 
    opened by Kreiri 0
  • Add support for annotated string parts

    Add support for annotated string parts

    image

    Android supports custom tags inside string resources. This can be represented in a localization document by adding support for string part annotations.

    The basic requirements are:

    • The annotation itself must only be added for platforms that support adding metadata to resource strings, otherwise the annotation must be omitted
    • Annotations may or may not contain additional metadata in them (design needed)
    • Each supported platform is responsible of formatting the annotated part of the string
    enhancement design-needed 
    opened by s0nerik 0
Releases(0.9.13)
Owner
Alex Isaienko
Alex Isaienko
Flutter Chat App with localization - powered by Stream

flutter_chat_app A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started

Pawan Kumar 49 Dec 23, 2022
Collection of common localization assets for Nations package

Nations Assets ?? collection of common localization assets for Nations package. FAQ Why not with Nations ? to make the Nations smaller and give the us

FlutterQueen 2 Jun 22, 2022
Provide easy and flexible way to show SnackBar. Simple text, undo, and error style are supported.

snack_bar_presenter Provide easy and flexible way to show SnackBar. Simple text, undo, and error style are supported. . . . Usage import 'package:exam

Masayuki Ono (mono) 8 Nov 30, 2020
A Translator App Which is Build using Flutter, Speech To Text, Google ML Kit, Google Translator and Text To Speech.

AI Translator This is a Translator App Which is Build using Flutter, Speech To Text, Google ML Kit, Google Translator and Text To Speech. Download App

null 4 Jul 16, 2022
In this video, we learn how to do integrate Google Admob with Flutter with latest Flutter 2.0 Google Admob Package.

?? Monetizing Flutter apps with Google AdMob ?? In this video, we learn how to do integrate Google Admob with Flutter with latest Flutter 2.0 Google A

SnippetCoder 14 Nov 30, 2022
Cross platform application for iOS and Android using Google's SDK Flutter.

scout Cross platform application for iOS and Android using Google's SDK Flutter. Launch screen for the application. The menu for selecting cookies. Cu

null 0 Nov 9, 2021
Amazing task management application with fluid, minimal and modern UI using Flutter! One of The Winner Apps for Google DevFest 2021!

Orb "Let your task orbit!" ?? Description Orb is an easy-to-use task manager app that help you manage your daily struggles to get your things done eff

Tom Huynh 9 Oct 28, 2022
gui automation based on pyautogui python as backend and flutter desktop as frontend, drag and drop tool, no coding required.

GUI_AUTOMATION gui automation based on pyautogui python as backend and flutter desktop as frontend, drag and drop tool, no coding required. Install py

Hassan Kanso 34 Oct 30, 2022
A super simple l10n tool with auto translations via GoogleSheet.

Flutter Translation Sheet Generator [fts] Command line application to make your l10n super fast. Compose your strings in yaml/json format and use Goog

Roi Peker 33 Oct 24, 2022