# goe-localization-cli

> Common CLI tool for updating Lokalise translations in all go-e Labs front-end projects

Latest version **1.3.3** (published 2023-05-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install goe-localization-cli
pnpm add goe-localization-cli
yarn add goe-localization-cli
bun add goe-localization-cli
```

Provides the command `translations`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.3 |
| Published | 2023-05-08 |
| First published | 2022-01-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 12.1 KB |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| Maintainers | ankush-goe, sergeialmazov, mohamed.clio, fitimfejzullahu, nicolas-cauet-go-e, go-e |

## Links

- npm: https://www.npmjs.com/package/goe-localization-cli
- npm.io page: https://npm.io/package/goe-localization-cli

## Dependencies (4)

- [dotenv](https://npm.io/package/dotenv.md) ^10.0.0
- [adm-zip](https://npm.io/package/adm-zip.md) ^0.5.9
- [node-fetch](https://npm.io/package/node-fetch.md) ^2.6.6
- [@lokalise/node-api](https://npm.io/package/@lokalise/node-api.md) ^7.1.0

## Recent versions

- 1.3.3 (latest) — 2023-05-08
- 1.3.1 — 2022-12-15
- 1.3.0 — 2022-05-31
- 1.2.0 — 2022-04-25
- 1.1.0 — 2022-03-09
- 1.0.1 — 2022-01-11
- 1.0.0 — 2022-01-11

## README

# goe-localization-cli

> CLI for updating translation files provided by _Lokalise_ tool

## Description

The package is intended for projects using _Lokalise_ tool. The CLI allows to communicate with _Lokalise_. Namely, you can download files with translations after they have been updated in _Lokalise_. You can also initiate translation update locally. To do that you have to change the base (English) translation file and upload it to _Lokalise_. When the tool has completed translating, you have then to download the rest translations.

The first iteration (goe-localization-cli@^1.0.0) supports the following structure of translation files:

`path/to/translations/<language-ISO-code>/<translation-file-name>.json`

where `language-ISO-code` represent codes like `en`, `de`, `fr`, etc., while `translation-file-name` is an arbitrary name same for all translation files. In other words, you have as many translation folders as you have languages in your application.

## Installation

The package should be added as develop dependency:

```bash
yarn add goe-localization-cli -D
```

or

```bash
npm install goe-localization-cli --save-dev
```

To configure the package, you should add environment variables. The package allows to split the variables between two files. One of them, named `.env`, is optional. It can be public and kept directly in the repo. This file is designed to keep non-critical data. The other one, called `.env.secret`, is mandatory. It is designed to hold the variables which should not be compromised, so it is better to excluded this file from version control.

These files should contain the following variables the package will use:

`LOKALISE_TOKEN` This is a personal token to access Lokalise. To get this token:

- Ask a Lokalise administrator to add you to the project with the role "admin".

- Go to https://app.lokalise.com/profile#apitokens and create a token.

It is strongly discouraged to keep the secret token a public `.env`.

`LOKALISE_PROJECT_ID` The identifier for the project within _Lokalise_

`LOCALIZATION_FOLDER_PATH` Path to folder with translations (relative of the project root)

`LOCALIZATION_FILE_NAME` (optional) Name of the JSON files with translations (including file extention).

If this parameter is provided, it will be used as the name of translation files for all languages, while each translation file will be placed inside folder named according to the language locale name.

If this parameter is not provided, each translation file will be named according to its language locale, while all files will be placed in a single folder.

Examples

`LOCALIZATION_FILE_NAME` set to `translation.json`

```
translation_folder (named as in `LOCALIZATION_FOLDER_PATH`)
 |
 |___en
 |    |
 |	  |___translation.json
 |
 |___de
      |
	  |___translation.json
```

`LOCALIZATION_FILE_NAME` not provided

```
translation_folder (named as in `LOCALIZATION_FOLDER_PATH`)
 |
 |___en.json
 |___de.json
```

The variables in `.env` files should be assigned according to the following rule:

```bash
<VARIABLE_NAME>=<value>
```

## Usage

To upload updated English translation to _Lokalise_, run the following command:

```bash
translations upload
```

To get the updated translations from _Lokalise_, run the following command:

```bash
translations download
```

In case your system cannot find the `translations` command name, use the full path for binaries:

```bash
./node_modules/.bin/translations
```

If you need to sort keys in translation files in the alphabetical order regardless of keys' case (high or low), add `sort_alphabetically` line to the `download` command:

```bash
translations download sort_alphabetically
```

## Known Issues
Currently there is a [bug](https://github.com/lokalise/node-lokalise-api/issues/28) in "@lokalise/node-api".
This bug converts "\n" for new line to "\\n". To avoid this replace_breaks should be set to false.

By default replace_breaks is true, to set it to false use no_replace_breaks in download/upload command.

```bash
translations download no_replace_breaks
translations upload no_replace_breaks
```

---
_Source: https://npm.io/package/goe-localization-cli · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
