The gleef init command sets up Gleef in your project by guiding you through the configuration process and creating the necessary configuration file.
Usage
What it does
The init command performs several important setup tasks:
Prompts for locale file patterns using placeholder syntax (e.g., {locale}, {feature})
Validates your file patterns by attempting to load locale files
Fetches company locales from your Gleef account
Maps file/folder names to company locales when needed
Creates configuration in .gleef/config.json with proper format options
Sets up custom locale mappings when file names don’t match standard locale codes
Placeholder Patterns
The command uses placeholder syntax to define file patterns:
{locale} - Required placeholder for the locale identifier
{feature} or {namespace} - Optional placeholders for organizing translations
Gleef supports these localization file formats:
.json - JSON localization files
.xml - XML localization files
.yaml / .yml - YAML localization files
.strings - iOS strings files
Pattern Examples
Pattern Matches Use Case src/locales/{locale}.jsonsrc/locales/en.json, src/locales/fr.jsonSimple locale files public/i18n/{locale}/{feature}.jsonpublic/i18n/en/common.json, public/i18n/fr/auth.jsonNamespaced translations locales/{feature}.{locale}.jsonlocales/common.en.json, locales/auth.fr.jsonFeature-first organization
Interactive Setup Process
Step 1: Enter Locale File Pattern
$ gleef init
___ _ _____ _____ _____
/ ___ | | | ____ | ____ | ___ |
| | _ | | | _ | | _ | | | _
| | _ | | | ___ | | ___ | | ___ | _ |
\____ | _____ | _____ | _____ | _ |
Welcome to the Gleef configuration assistant
You will need your locale files path to continue, using the {locale} placeholder.
? What 's your locale files path? › src/locales/{locale}.json
Step 2: Locale Mapping (if needed)
If your file/folder names don’t match your company locales:
? Please assign one of your configured locale to this file/folder: en
fr-FR
en-US
es-ES
❯ Skip
Step 3: Success
✔ One pattern added successfully. You can add more in your config file.
src/locales/ {locale} .json
Run ` gleef translate` to start translating
To customize nested/flat output per format, edit the formatOptions in .gleef/config.json
Generated Configuration
After running init, you’ll find a .gleef/config.json file in your project:
{
"localeFilePatterns" : [
"src/locales/{locale}.json"
],
"formatOptions" : {
"json" : {
"nested" : true
}
},
"customLocaleNames" : {
"fr-FR" : "french" ,
"de-DE" : "german"
}
}
Configuration Properties
Property Description localeFilePatternsPlaceholder patterns matching your localization files using {locale} syntax formatOptionsOutput format settings for each file type (auto-detected based on your patterns) customLocaleNamesMaps company locale codes to your file/folder names when they don’t match
Configuration Examples by Technology
React/Next.js
Vue/Nuxt.js
Angular
iOS (Swift)
Android
Rails
Laravel
Django
{
"localeFilePatterns" : [
"public/locales/{locale}.json" ,
"src/locales/{locale}/{feature}.json"
],
"formatOptions" : {
"json" : {
"nested" : true
}
}
}
Complex Project Structures
Monorepo with Multiple Apps
{
"localeFilePatterns" : [
"apps/web/src/locales/{locale}.json" ,
"apps/mobile/src/i18n/{locale}.json" ,
"packages/shared/locales/{locale}/{feature}.json"
],
"formatOptions" : {
"json" : {
"nested" : true
}
}
}
Legacy Project with Custom Names
{
"localeFilePatterns" : [
"assets/translations/{locale}.json"
],
"formatOptions" : {
"json" : {
"nested" : false
}
},
"customLocaleNames" : {
"en-US" : "english" ,
"fr-FR" : "french" ,
"es-ES" : "spanish" ,
"zh-CN" : "chinese-simplified"
}
}
Troubleshooting
Pattern Validation Errors
If the pattern validation fails:
⚠ No locale files found with this path
Please correct your path, check the documentation or contact Gleef for help.
Common issues:
Missing {locale} placeholder - All patterns must include {locale}
Incorrect file paths - Verify the files exist at the specified location
Wrong file extensions - Ensure files use .json, .xml, .yaml, or .strings
Path syntax errors - Use forward slashes / in patterns
Locale Mapping Issues
If your file/folder names don’t match company locales:
Use the interactive mapping - The init command will prompt you to map each unmatched locale
Skip unmapped locales - Choose “Skip” for locales you don’t want to include
Update company locales - Add missing locales in Gleef Studio if needed
Manual Configuration
If you need to skip the interactive setup:
{
"localeFilePatterns" : [
"your/custom/{locale}.json"
],
"customLocaleNames" : {
"en-US" : "english" ,
"fr-FR" : "french"
},
"formatOptions" : {
"json" : {
"nested" : true
}
}
}
Best Practices
Always use the {locale} placeholder in your file patterns for proper locale detection.
Use descriptive patterns - Include folder structure in patterns: src/i18n/{locale}/{feature}.json
Test your patterns - Verify patterns match existing files before running init
Plan for namespaces - Consider using {feature} placeholders for organized translations
Review generated config - Check .gleef/config.json matches your expectations
Commit configuration - Add .gleef/config.json to version control
Next Steps
After initialization: