Skip to main content

Jhlangtool

Jhlangtool is a command line tool built for processing translations in the form of .json files. It is divided into multiple different utilities, each accessed by a keyword.

It currently supports:

  • Generating an excel workbook from translation json files

  • Generating json from a corresponding excel workbook

Installation

Install and update using pip:

$ pip install jhlangtool

This should add jhlangtool to the system’s path variable, allowing you to call it from the command line.

Utilities

Generating an excel workbook from translation json files

The generateExcel or toExcel utility generates an excel workbook listing the values of json files. It takes the base directory as an argument, which is the directoy in which the language directories are stored. It generates one spreadsheet for every json file, and a column for every language (see example spreadsheet below). The first value in the spreadsheet (first row, first column) will be the json file name when converting back into json with the generateJson or toJson utility.

Note that currently, it only works if the json files are direct children from language directories (it will work on "./i18n/en/example.json", but it will not work on "./i18n/en/admin/example.json" because example.json is not a direct child of en). Also, any empty string value in the json file will be replaced by the empty string identifier ($JHEMPTY by default). The identifier will be converted back into an empty string when using the generateJson or toJson utility.

$ jhlangtool generateExcel <path to base directory> [options]

Example directory tree:

I18n <-- The base directory
  |
  |-+ de
  |   |- audits.json
  |   |- dashboard.json
  |   |- login.json
  |
  |-+ en
  |   |- audits.json
  |   |- dashboard.json
  |   |- login.json
  |
  |-+ es
  |   |- audits.json
  |   |- dashboard.json
  |   |- login.json
  |   |- extra.json <--- The language directories don't necessary have to have the same json files.
  |                      If a file is missing in other directories, the excel file wil treat is as missing keys.
  |
  |-+ fr
  |   |- audits.json
  |   |- dashboard.json
  |   |- login.json

When the command $ jhlangtool generateExcel ./i18n is used on the example input directory, it generates an excel file. The audits spreadsheet of that excel file (filled with mock data):

audits.json

de

en

es

fr

example/key

Hallo

Hello

Hola

Bonjour

example/key2

Beispiel

Example

Ejemplo

Exemple

Options

-f, –filepath The path to the excelfile. Must end with the excel filename and the .xlsx extension. Default is ./output.xlsx.

-s, –separator The separator for the keys in the excel file. Default is “/”.

-i, –identifier The empty str ( “” <— ) identifier

-v, –verbose Enables verbose output (outputs which files are currently being processed and which directory is currently being checked for new files)

-q, –quiet Disables writing to stdout (disables outputting anything)

-h, –help Shows a help message

Generating json files from an excel workbook

The generateJson or toJson utility is meant to be used with the generateExcel or toExcel utility. It takes the path to the excel file as an argument. The excel file must have the format generated by the generateExcel or toExcel utility. It generates a new language directory for every language column in the excel file, with corresponding json files. It will also convert the empty string identifier into an empty string.

$ jhlangtool generateJson ./output.xlsx
Options

-o, –output In which directory to generate the language json files. Default is the current working directory. Note that the json files will be generated in the selected directory (it does not generate a new directory inside the selected one).

-s, –separator The separator for the keys in the excel file. Default is “/”.

-i, –identifier The identifier for the empty string( “” <— this).

-v, –verbose Enables verbose output (outputs which files are currently being processed)

-q, –quiet Disables writing to stdout (disables outputting anything)

-h, –help Shows a help message

Version: 0.8.0

Author: Martin Vrbovcan, 2018.

Metadata

Release files for jhlangtool 0.8.1

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

Source distribution (sdist)

Source distribution for jhlangtool 0.8.1
File Size Uploaded
jhlangtool-0.8.1.tar.gz 9.4 kB Details

Built distribution (wheel)

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

Total release size: 25.2 kB

Release files / jhlangtool-0.8.1.tar.gz

Download URL jhlangtool-0.8.1.tar.gz
Size 9.4 kB
Tags Source
SHA-256 checksum
How to use checksums
c4bbdae21ee231dc3d5c76ff1334e7a8ca2307fc6ac1041afee66b510054a4ab
BLAKE2b-256 checksum
How to use checksums
0e24a8f5bb87ab6a6e719d6400b5d381a543ac71cad815c91577f335f83badd3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.9.1 pkginfo/1.4.1 requests/2.14.2 setuptools/38.5.1 requests-toolbelt/0.8.0 tqdm/4.19.5 CPython/3.6.1

Release files / jhlangtool-0.8.1-py3-none-any.whl

Download URL jhlangtool-0.8.1-py3-none-any.whl
Size 15.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
41419a0b3c26f13fcb3edd16fe34f2b7db323c2ee90fcc5c2580d139fbfb0793
BLAKE2b-256 checksum
How to use checksums
2ca61533ec4e2854df85056353b6fb69ed12577b11c6e86e7833d07630ceb288
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/1.9.1 pkginfo/1.4.1 requests/2.14.2 setuptools/38.5.1 requests-toolbelt/0.8.0 tqdm/4.19.5 CPython/3.6.1

Release history Release notifications | RSS feed

This release

0.8.1 This release

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

1 release file

0.0.2

1 release file

0.0.1

1 release file

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