The gleef init command sets up Gleef in your project by guiding you through the configuration process and creating the necessary configuration file.

Usage

gleef init

What it does

The init command performs several important setup tasks:
  1. Prompts for locale file patterns using placeholder syntax (e.g., {locale}, {feature})
  2. Validates your file patterns by attempting to load locale files
  3. Fetches company locales from your Gleef account
  4. Maps file/folder names to company locales when needed
  5. Creates configuration in .gleef/config.json with proper format options
  6. 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

Supported File Formats

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

PatternMatchesUse 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

PropertyDescription
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

{
  "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:
  1. Missing {locale} placeholder - All patterns must include {locale}
  2. Incorrect file paths - Verify the files exist at the specified location
  3. Wrong file extensions - Ensure files use .json, .xml, .yaml, or .strings
  4. Path syntax errors - Use forward slashes / in patterns

Locale Mapping Issues

If your file/folder names don’t match company locales:
  1. Use the interactive mapping - The init command will prompt you to map each unmatched locale
  2. Skip unmapped locales - Choose “Skip” for locales you don’t want to include
  3. 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.
  1. Use descriptive patterns - Include folder structure in patterns: src/i18n/{locale}/{feature}.json
  2. Test your patterns - Verify patterns match existing files before running init
  3. Plan for namespaces - Consider using {feature} placeholders for organized translations
  4. Review generated config - Check .gleef/config.json matches your expectations
  5. Commit configuration - Add .gleef/config.json to version control

Next Steps

After initialization: