npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

goe-localization-cli

v1.3.3

Published

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

Downloads

3

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:

yarn add goe-localization-cli -D

or

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:

<VARIABLE_NAME>=<value>

Usage

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

translations upload

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

translations download

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

./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:

translations download sort_alphabetically

Known Issues

Currently there is a bug 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.

translations download no_replace_breaks
translations upload no_replace_breaks