Skip to main content

i18n-json-spreadsheet

Lazy i18n json to spreadsheet and back tool.

The aim of this utility is to help the management of JSON translations file used for example in JS frontends to handle locales.

Usually we can have key/value items nested in some way like the following:

{
  "hello": "ciao",
  "how_are_you": "come stai",
  "component_a": {
    "my_name_is": "il mio nome é"
  }
}

To avoid editors to edit JSON files directly, ofted in git repos, the idea is to create/update online spreadsheet on Google Docs and maybe Microsoft Office 365.

Installation

PIP

The package is available on Pypi. To install locally on a virtual env or globally execute a standard package installation:

❯ pip install i18nconverter

Authentication

At the moment we support only Service Account file to authenticate API for Google Drive and Google Spreadsheet. To get you SA file you have to:

Quickstart

  1. Move to your current project directory and configure the environment
❯ i18nconverter init
📝 Creating local configuration...
↳ GCP Service Account JSON file location? : /tmp/my-sa-file.json
↳ Google Spreadsheet link? : NA
↳ How do you manage locale codes?
   ↳ [1] in different files
   ↳ [2] on the first level of JSON
 [1]:

🎉  Configuration file created .i18nconverter.json 

Since we're going to create a new file we can insert a random string to Google Spreadsheet link? question.

  1. Then we can create the new spreadsheet where manage translations
❯ i18nconverter create --name "MY_PROJECT_Translations" --owner "john.doe@none.com" --save
📝 Creating new spreadsheet "MY_PROJECT_Translations"...
https://docs.google.com/spreadsheets/d/99999-8
✅ Config file updated.
  1. Create entries to the previously created Google Spreadsheet for italian using dedicated sheet named it-IT.
 ❯ i18nconverter togdoc -i public/locales/it-IT/translation.json --sheet IT --create-sheet
✅ Update completed.
💻 Check at https://docs.google.com/spreadsheets/d/99999-8

Then repeat for en-US locale.

❯ i18nconverter togdoc -i public/locales/en-US/translation.json --sheet en-US --create-sheet
✅ Update completed.
💻 Check at https://docs.google.com/spreadsheets/d/99999-8
  1. Fill some translations on Google Docs
  2. Update local JSON file
❯ i18nconverter tojson -o public/locales/it-IT/translation.json -s it-IT
  1. Check differences locally maybe with the help of git diff

How to

This tool is intended to be used as CLI tool.

Get help

❯ i18nconverter --help
Usage: i18nconverter [OPTIONS] COMMAND [ARGS]...

Options:
  --auth TEXT  Service Account JSON file path
  --silent     Silent mode: questions to user will be skipped (ignored for
               setup)
  --help       Show this message and exit.

Commands:
  init
  togdoc
  tojson
  tokv

Create local permantent config file

To simplify the frequent usage we support a local configuration file that will be searched only in the current directory.

 ❯ i18nconverter init
📝 Creating local configuration...
↳ GCP Service Account JSON file location? : /tmp/my-sa-file.json
↳ Google Spreadsheet link? : https://docs.google.com/spreadsheets/d/ffa9a9f99f
↳ How do you manage locale codes?
   ↳ [1] in different files
   ↳ [2] on the first level of JSON
 [1]: 1


🎉  Configuration file created .i18nconverter.json

As you can see a file in the same directory called .i18nconverter.json will be created and you can skip setting SA file path and source/target spreadsheet link on each command.

Json To Google Spreadsheet

❯ i18nconverter togdoc --help
Usage: i18nconverter togdoc [OPTIONS]

Options:
  -i, --infile TEXT               JSON input file
  -ol, --outlink TEXT             Destination link for Google Spreadsheet
  -s, --sheet TEXT                Destination sheet in Google Spreadsheet
  -o, --overwrite                 Clear worksheet before writing values
  --create-sheet / --no-create-sheet
                                  Create new sheet with given name if it not
                                  exists
  --help                          Show this message and exit.

Google Spreadsheet to Json file

❯ i18nconverter tojson --help
Usage: i18nconverter tojson [OPTIONS]

Options:
  -o, --outfile TEXT  JSON output file
  -il, --inlink TEXT  Source link for Google Spreadsheet
  --start-cell TEXT   Start reading from this cell coordinates
  -s, --sheet TEXT    Source sheet in Google Spreadsheet
  --help              Show this message and exit.

Compare Json file and Google Spreadsheet

❯ i18nconverter compare --help
Usage: i18nconverter compare [OPTIONS]

Options:
  -f, --file TEXT       JSON file for comparison  [required]
  -l, --link TEXT       Link to Google Spreadsheet
  -s, --sheet TEXT      Source sheet in Google Spreadsheet
  -c, --column INTEGER  Colum to read in Google Spreadsheet
  --help                Show this message and exit.

The response will show two csv with differences:

❯ i18nconverter compare -f /tmp/somefile.json
Keys present in Google Spreadsheet and not present in JSON: 
actions.addedaaa
Keys present in JSON and not present in Google Spreadsheet: 
actions.added

Metadata

Release files for i18nconverter 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for i18nconverter 0.0.4
File Size Uploaded Provenance Actions
i18nconverter-0.0.4.tar.gz 21.5 kB Without provenance Details for i18nconverter-0.0.4.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for i18nconverter 0.0.4
File Interpreter ABI Platform Actions
i18nconverter-0.0.4-py3-none-any.whl Python 3 none any Details for i18nconverter-0.0.4-py3-none-any.whl

Total release size: 43.0 kB

Release files / i18nconverter-0.0.4.tar.gz

Download URL i18nconverter-0.0.4.tar.gz
Size 21.5 kB
Tags Source
SHA-256 checksum
How to use checksums
1492743eb138d9722536731429cd862981f4195ec27fe14ced246190f3a1bdbb
BLAKE2b-256 checksum
How to use checksums
89fa4bf062c4641b5573242474bf97082d6f1ef0473ca98c48a784f3406c2600
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.9.18

Release files / i18nconverter-0.0.4-py3-none-any.whl

Download URL i18nconverter-0.0.4-py3-none-any.whl
Size 21.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
66e74ea1c4bc33b56bbb99e1134e00920e2f6ef34938d804da9079dd58e9d39c
BLAKE2b-256 checksum
How to use checksums
fc09184425adc88a723e2aa46473a21d75885585b4a55c522ee98ae02b0101e4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.9.18

Security for i18nconverter 0.0.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page