
Security News
/Research
Popular node-ipc npm Package Infected with Credential Stealer
Socket detected malicious node-ipc versions with obfuscated stealer/backdoor behavior in a developing npm supply chain attack.
@ttoss/i18n-cli
Advanced tools
A CLI tool for extracting and compiling translations from your code using [FormatJS](https://formatjs.io/docs/getting-started/application-workflow). Automatically handles translations from your application and all ttoss packages.
A CLI tool for extracting and compiling translations from your code using FormatJS. Automatically handles translations from your application and all ttoss packages.
pnpm add @ttoss/i18n-cli --dev
Add script to your package.json:
{
"scripts": {
"i18n": "ttoss-i18n"
}
}
Add to .gitignore:
i18n/compiled/
i18n/missing/
i18n/unused/
Run extraction and compilation:
pnpm i18n
The CLI creates a structured workflow for managing translations:
π i18n/
βββ π lang/ # Translation files
β βββ π en.json # Auto-generated (don't edit)
β βββ π pt-BR.json # Edit with your translations
βββ π compiled/ # Auto-generated (production files)
β βββ π en.json # Compiled for runtime
β βββ π pt-BR.json # Compiled for runtime
βββ π missing/ # Auto-generated (analysis reports)
β βββ π pt-BR.json # What needs translation
βββ π unused/ # Auto-generated (cleanup reports)
βββ π pt-BR.json # Unused translations per language
Extract and compile everything:
pnpm i18n
Extract only (no compilation):
pnpm i18n --no-compile
Ignore ttoss package translations:
pnpm i18n --ignore-ttoss-packages
Custom file patterns:
pnpm i18n --pattern "src/**/*.{ts,tsx}" --ignore "**/*.test.*"
Follow this step-by-step process to set up internationalization:
import { FormattedMessage } from 'react-intl';
<FormattedMessage
defaultMessage="Welcome to our app!"
description="Main welcome message"
/>;
pnpm i18n --no-compile
Result: Creates i18n/lang/en.json directly with all messages found in your code:
{
"2mAHlQ": {
"defaultMessage": "Welcome to our app!",
"description": "Main welcome message"
}
}
Important: Don't edit
en.jsonmanually - it will be overwritten on next extraction.
Copy the base English file to create other language files:
# Create files for other languages
cp i18n/lang/en.json i18n/lang/pt-BR.json
cp i18n/lang/en.json i18n/lang/es.json
Edit each language file with the appropriate translations:
These are the ONLY files you should edit manually
i18n/lang/pt-BR.json:
{
"2mAHlQ": {
"defaultMessage": "Bem-vindo ao nosso app!",
"description": "Mensagem principal de boas-vindas"
}
}
i18n/lang/es.json:
{
"2mAHlQ": {
"defaultMessage": "Β‘Bienvenido a nuestra app!",
"description": "Mensaje principal de bienvenida"
}
}
pnpm i18n
Result: Generates optimized compiled files and analysis reports:
i18n/compiled/ - Production-ready translation filesi18n/missing/ - Shows untranslated messagesi18n/unused/ - Identifies unused translationsBase Language File (i18n/lang/en.json) - Auto-generated:
{
"2mAHlQ": {
"defaultMessage": "Welcome to our app!",
"description": "Main welcome message"
}
}
Translation Files (i18n/lang/pt-BR.json) - Edit with your translations:
{
"2mAHlQ": {
"defaultMessage": "Bem-vindo ao nosso app!",
"description": "Mensagem principal de boas-vindas"
}
}
Compiled Output (i18n/compiled/pt-BR.json) - Auto-generated:
{
"2mAHlQ": [
{
"type": 0,
"value": "Bem-vindo ao nosso app!"
}
]
}
The CLI automatically generates helpful reports to assist with translation management:
i18n/missing/LANG.json): Shows what needs translationi18n/unused/LANG.json): Identifies translations to remove per languageNote: All reports are auto-generated - use them as reference only.
| Option | Description |
|---|---|
--no-compile | Extract only, skip compilation step |
--ignore-ttoss-packages | Skip extraction from ttoss dependencies |
--pattern <glob> | Custom file pattern for extraction (default: src/**/*.{js,jsx,ts,tsx}) |
--ignore <patterns> | Files/patterns to ignore during extraction |
When using ttoss packages like @ttoss/react-i18n, the CLI automatically:
This eliminates manual copying of package translations and ensures consistency across your application.
FAQs
A CLI tool for extracting and compiling translations from your code using [FormatJS](https://formatjs.io/docs/getting-started/application-workflow). Automatically handles translations from your application and all ttoss packages.
We found that @ttoss/i18n-cli demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago.Β It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
/Research
Socket detected malicious node-ipc versions with obfuscated stealer/backdoor behavior in a developing npm supply chain attack.

Security News
TeamPCP and BreachForums are promoting a Shai-Hulud supply chain attack contest with a $1,000 prize for the biggest package compromise.

Security News
Packagist urges PHP projects to update Composer after a GitHub token format change exposed some GitHub Actions tokens in CI logs.