Prismy CLI for i18n Translation Management

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

The Prismy CLI is a command-line interface tool designed to streamline the management of internationalization (i18n) translations, particularly for new keys within a Git branch. It integrates with Prismy, an AI-powered translation platform, to facilitate localized software development. The current stable version is 1.4.1, with recent updates like v1.3.6 suggesting an active development and release cadence. Key differentiators include its tight integration with Git workflows for automatically detecting new i18n keys and generating translations, as well as features for syncing translation files directly with the Prismy platform. It also provides an agent skill to contextualize AI coding tools with project-specific terminology, tone of voice, and translation workflows, significantly enhancing the developer experience for localized applications. The CLI requires Node.js version 18 or higher for execution.

error prismy: command not found
cause The Prismy CLI executable is not found in the system's PATH, or it has not been installed.
fix
Install the CLI globally using npm install -g prismy-cli or ensure it's available in your node_modules/.bin directory if installed locally, and use npx prismy-cli or include it in your package.json scripts.
error Error: Authentication Failed: Invalid API Key
cause The API key provided to the `prismy auth` command is incorrect, expired, or lacks the necessary permissions.
fix
Verify your API key from your Prismy dashboard and re-authenticate using prismy auth --key YOUR_VALID_KEY. Ensure no typos or extra spaces are present.
error Error: Node.js version XX is not supported. Please upgrade to Node.js 18 or higher.
cause Attempting to run the Prismy CLI with an incompatible or outdated Node.js runtime.
fix
Upgrade your Node.js installation to version 18 or newer. Tools like nvm (Node Version Manager) can help you manage multiple Node.js versions easily.
gotcha Prismy CLI explicitly requires Node.js version 18 or higher for proper functionality.
fix Upgrade your Node.js environment to version 18 or newer using tools like `nvm` or by installing a recent Node.js distribution.
gotcha Hardcoding Prismy API keys directly into scripts or source code poses a significant security risk.
fix Always manage API keys securely using environment variables (e.g., `process.env.PRISMY_API_KEY`), a `.env` file, or a dedicated secrets management system, especially in production environments.
gotcha The `prismy generate` command relies on detecting new i18n keys in uncommitted or recently committed Git changes.
fix Ensure you are on a feature branch with new i18n key additions staged or committed before running `prismy generate`. Use the `--dry-run` flag initially to preview changes without modifying files.
npm install prismy-cli
yarn add prismy-cli
pnpm add prismy-cli

This TypeScript script demonstrates how to programmatically invoke Prismy CLI commands, including authentication and initiating a dry run for translation generation, useful for CI/CD or automated workflows.

import { execSync } from 'child_process';
import * as path from 'path';

// Ensure prismy-cli is installed (e.g., as a dev dependency or globally)
// npm install --save-dev prismy-cli
// or npm install -g prismy-cli

const prismyBin = path.resolve(process.cwd(), 'node_modules/.bin/prismy');
// It's highly recommended to use environment variables for API keys in production
const prismyApiKey = process.env.PRISMY_API_KEY ?? 'YOUR_SECRET_PRISMY_API_KEY_HERE'; 

try {
  if (!prismyApiKey || prismyApiKey === 'YOUR_SECRET_PRISMY_API_KEY_HERE') {
    console.warn('Warning: PRISMY_API_KEY is not set. Authentication might fail.');
  }

  console.log('Authenticating with Prismy...');
  execSync(`${prismyBin} auth --key "${prismyApiKey}"`, { stdio: 'inherit' });
  console.log('Authentication successful.');

  console.log('Generating translations (dry run)...');
  // This command detects new i18n keys in your Git changes
  // and sends them to Prismy for AI translation. 
  // Use --dry-run to preview changes without modifying files.
  execSync(`${prismyBin} generate --dry-run`, { stdio: 'inherit' });
  console.log('Dry run complete. Review potential changes in your translation files.');

  // To apply the translations, remove --dry-run:
  // execSync(`${prismyBin} generate`, { stdio: 'inherit' });

} catch (error) {
  console.error('Error running Prismy CLI commands:', error.message);
  process.exit(1);
}