Overview
Thecompile command transforms your translation files into optimized runtime formats that your application can load. It reads translation files, applies fallback logic, and generates JSON files with key-value pairs for fast lookup.
Syntax
Options
Enable verbose logging to see detailed compilation progress for each locale.
Suppress all logging output. Only errors will be displayed.
How It Works
The compile command uses theBucketCompileWorker to:
1. Read Translation Files
For each locale in your configuration:- Reads the translation file using the configured formatter (e.g.,
.pofiles) - Parses messages into structured data with IDs, translations, and metadata
2. Apply Fallback Translations
For messages missing translations:- Checks the fallback chain defined in
fallbackLocalesconfiguration - Falls back to the source locale if no translation is found in fallbacks
- Ensures every message has a displayable value
3. Generate Runtime Files
Creates optimized JSON files:- Key-value format: Maps message IDs/hashes to translated strings
- Compact structure: Only includes the data needed at runtime
- Fast lookup: Enables O(1) message retrieval in your application
Output Format
The compiled files are JSON objects with this structure:- Explicit IDs: The
idfield from your message definition - Generated hashes: Computed from the message content and context
Examples
Basic compilation
Verbose compilation
Quiet compilation
Output Files
Compiled files use the sameoutput pattern as extraction, but with a .json extension:
locales/en.json(runtime format)locales/es.json(runtime format)locales/fr.json(runtime format)
.po files) used by translators.
Fallback Logic
The compiler implements intelligent fallback:es-MX:
- First tries the
es-MXtranslation - Falls back to
esif missing - Falls back to
en(source locale) as last resort
The compile command caches translations during execution for efficiency when processing multiple locales with shared fallbacks.
When to Use
Runsaykit compile in these scenarios:
- After translators update your
.poor other source translation files - Before deploying your application to production
- As part of your build pipeline (though consider using
saykit buildinstead) - When changing fallback locale configuration