StrongLoop Globalize CLI

raw JSON →
7.1.1 verified Thu Apr 23 auth: no javascript

strong-globalize-cli is a command-line interface tool designed to facilitate the globalization of JavaScript applications. Its primary functions include extracting translatable text messages from JavaScript and HTML source code, linting message files to identify potential issues, and integrating with IBM Globalization Pipeline for automated machine translation. The current stable version is 7.1.1, supporting Node.js versions 10.x and above. The tool distinguishes itself with both 'regular extraction' for package development and 'deep extraction' for enterprise-scale applications, allowing comprehensive identification of all literal strings—globalized or not—within a codebase. Its release cadence is tied to updates in globalization features or the underlying IBM Cloud services it integrates with.

error slt-globalize: command not found
cause The `strong-globalize-cli` package was not installed globally, or its executable path is not in your system's PATH.
fix
Install the package globally using npm install -g strong-globalize-cli.
error Error: IBM Cloud credentials are not provided or invalid when running `slt-globalize -t`.
cause The CLI could not find or validate the necessary credentials for the IBM Globalization Pipeline service.
fix
Ensure BLUEMIX_URL, BLUEMIX_USER, BLUEMIX_PASSWORD, and BLUEMIX_INSTANCE environment variables are set, or that ~/.strong-globalize/ibm-cloud-credentials.json exists and contains valid credentials.
error Error: Failed to parse messages.json: Unexpected token ...
cause The `messages.json` file (e.g., `intl/en/messages.json`) contains malformed JSON, often due to manual edits or an issue during extraction.
fix
Manually inspect and correct the syntax errors in the specified messages.json file, or re-run slt-globalize -e to regenerate it if no manual changes were intended.
gotcha The `slt-globalize` command requires Node.js version 10.x or higher. Earlier Node.js versions are not supported and may lead to unexpected behavior or errors.
fix Upgrade your Node.js environment to version 10.x or later.
gotcha To utilize the translation feature (`slt-globalize -t`), access credentials for IBM Globalization Pipeline on IBM Cloud must be provided. This can be done either through environment variables (BLUEMIX_URL, BLUEMIX_USER, BLUEMIX_PASSWORD, BLUEMIX_INSTANCE) or by placing a `ibm-cloud-credentials.json` file in your home directory's `.strong-globalize` folder.
fix Set the required BLUEMIX_* environment variables or create `~/.strong-globalize/ibm-cloud-credentials.json` with valid IBM Cloud Globalization Pipeline credentials.
gotcha The `extract` mode (`-e`) and `deepextract` mode (`-d`) serve different purposes. Regular extraction (`-e`) is typically for package development, while deep extraction (`-d`) is designed for enterprise-scale applications and includes non-globalized literal strings in `intl/zz/messages.json` to help identify untranslated content.
fix Choose the appropriate extraction mode based on your project's scope and needs. Use `-e` for typical package string extraction and `-d` for a more comprehensive scan including potentially untranslated strings.
npm install strong-globalize-cli
yarn add strong-globalize-cli
pnpm add strong-globalize-cli

Demonstrates global installation, basic string extraction, linting, and translation via the command-line interface.

npm install -g strong-globalize-cli

# Create a sample JavaScript file
echo "const g = require('strong-globalize'); g.log('Hello, World!');" > app.js

# Extract strings (creates intl/en/messages.json and intl/zz/messages.json)
slt-globalize -e

# Lint the extracted messages file
slt-globalize -l

# Configure IBM Globalization Pipeline credentials via environment variables
export BLUEMIX_URL="${process.env.BLUEMIX_URL ?? 'https://gp-beta-rest.ng.bluemix.net/translate/rest'}"
export BLUEMIX_USER="${process.env.BLUEMIX_USER ?? 'your-user-id'}"
export BLUEMIX_PASSWORD="${process.env.BLUEMIX_PASSWORD ?? 'your-password'}"
export BLUEMIX_INSTANCE="${process.env.BLUEMIX_INSTANCE ?? 'your-instance-id'}"

# Translate strings using Globalization Pipeline (requires credentials setup)
slt-globalize -t