Prerequisites
Before you begin, make sure you have:- Installed Saykit and the necessary packages for your framework (see Installation)
- Configured your build tool (Babel plugin or unplugin)
Step-by-Step Tutorial
Create a configuration file
Create a This configuration:
saykit.config.ts file in your project root:saykit.config.ts
- Sets English as the source locale
- Defines three supported locales (English, French, Spanish)
- Scans all TypeScript and JavaScript files in
src/ - Outputs extracted messages to
src/locales/{locale}/messages.json
You can also use JSON format by creating
saykit.config.json and omitting the defineConfig wrapper.Initialize the Say instance
Create a Say instance that will handle your translations:
- Vanilla JavaScript
- React (Next.js)
src/i18n.ts
Add translatable messages
Use Saykit’s template literal syntax to mark strings for translation:
- Vanilla JavaScript
- React
src/index.ts
Extract messages
Run the extract command to scan your source files and generate message catalogs:This creates
.po files for each locale in your output directory (e.g., src/locales/en/messages.po).The
.po (Portable Object) format is an industry-standard format used by professional translation tools.Compile translations
Convert This generates
.po files to runtime-ready JSON:messages.json files that your application will load at runtime.CLI Commands Reference
Saykit provides three main CLI commands:saykit extract
Scans your source files and extracts translatable messages into .po files.
-v, --verbose- Enable verbose logging-q, --quiet- Suppress all logging
saykit compile
Compiles .po translation files into runtime-ready JSON files.
-v, --verbose- Enable verbose logging-q, --quiet- Suppress all logging
saykit build
Combines extract and compile into a single step.
-v, --verbose- Enable verbose logging-q, --quiet- Suppress all logging
Next Steps
Now that you have Saykit set up, explore more features:- Configuration - Learn about all configuration options
- Core Concepts - Understand how Saykit works under the hood
- React Integration - Deep dive into React-specific features
- Message Formatting - Advanced pluralization, selection, and formatting