Advanced Features
The Algebras CLI offers several advanced features to optimize your localization workflow, including UI-safe translations, custom prompts, glossary management, batch processing, and Git integration.
UI-Safe Translations
Section titled “UI-Safe Translations”The --ui-safe flag ensures that translations won’t exceed the original text length, which is crucial for maintaining consistent UI layouts.
algebras translate --ui-safealgebras update --ui-safeWhen to Use
Section titled “When to Use”- UI strings with length constraints
- Button labels and navigation items
- Form field labels
- Mobile app interfaces
- Responsive web designs
Example
Section titled “Example”# Original: "Submit"# UI-Safe Translation: "Enviar" (5 chars)# Regular Translation: "Enviar formulario" (15 chars)Custom Translation Prompts
Section titled “Custom Translation Prompts”You can provide custom prompts for more specific translation requirements.
Using Prompt Files
Section titled “Using Prompt Files”Create a prompt file:
echo "Translate to {target_language} maintaining a professional tone for a business application" > custom-prompt.txtUse the prompt file:
algebras translate --prompt-file custom-prompt.txtUsing Inline Prompts
Section titled “Using Inline Prompts”algebras translate --prompt "Translate to {target_language} using casual, friendly language"Setting Default Prompts
Section titled “Setting Default Prompts”algebras configure --prompt "Translate to {target_language} maintaining a professional tone"Prompt Variables
Section titled “Prompt Variables”Available variables in prompts:
{target_language}- Target language name{source_language}- Source language name{context}- Translation context (if available)
Glossary Management
Section titled “Glossary Management”Algebras CLI supports glossary management for consistent terminology across translations.
Creating Glossaries
Section titled “Creating Glossaries”Glossaries can be created through the platform or uploaded from CSV/XLSX files.
Using Glossaries
Section titled “Using Glossaries”algebras translate --glossary-id glossary-123Glossary Benefits
Section titled “Glossary Benefits”- Consistent terminology across translations
- Domain-specific vocabulary
- Brand name preservation
- Technical term accuracy
Batch Processing
Section titled “Batch Processing”Optimize translation performance with batch processing settings.
Adjusting Batch Size
Section titled “Adjusting Batch Size”# Process 10 translations per batchalgebras translate --batch-size 10Controlling Parallel Batches
Section titled “Controlling Parallel Batches”# Run maximum 3 batches in parallelalgebras translate --max-parallel-batches 3Configuring Defaults
Section titled “Configuring Defaults”algebras configure --batch-size 10 --max-parallel-batches 3Performance Tips
Section titled “Performance Tips”- Smaller batch sizes (5-10) for better error handling
- Larger batch sizes (20-50) for faster processing
- Fewer parallel batches for rate limit compliance
- More parallel batches for maximum throughput
Git Integration
Section titled “Git Integration”Algebras CLI automatically tracks translation changes using Git.
Automatic Git Detection
Section titled “Automatic Git Detection”The CLI automatically:
- Detects outdated keys by comparing modification times
- Validates translations against source file changes
- Skips unnecessary translations
Git-Friendly Commands
Section titled “Git-Friendly Commands”# Skip git validation (useful for CI)algebras translate --only-missing
# CI-friendly commandalgebras ci --fail-on-errorGit Workflow Integration
Section titled “Git Workflow Integration”# 1. Make changes to source filesgit add src/locales/en/git commit -m "Update English strings"
# 2. Update translationsalgebras update
# 3. Commit translation changesgit add src/locales/git commit -m "Update translations"String Normalization
Section titled “String Normalization”Control how strings are processed before translation.
Enable String Normalization
Section titled “Enable String Normalization”algebras configure --normalize-strings trueThis removes escaped characters like \' and normalizes whitespace.
Disable String Normalization
Section titled “Disable String Normalization”algebras configure --normalize-strings falseThis preserves all characters exactly as they appear.
When to Use Each Mode
Section titled “When to Use Each Mode”Enable normalization for:
- User-facing text
- Clean, readable translations
- Standard localization files
Disable normalization for:
- Code strings
- Technical documentation
- Strings with special formatting
Advanced Configuration Options
Section titled “Advanced Configuration Options”Custom API Settings
Section titled “Custom API Settings”api: provider: algebras-ai model: gpt-4 batch_size: 15 max_parallel_batches: 2 normalize_strings: trueEnvironment Variables
Section titled “Environment Variables”export ALGEBRAS_BATCH_SIZE=15export ALGEBRAS_MAX_PARALLEL_BATCHES=2export ALGEBRAS_BASE_URL=https://custom-api.example.comWorkflow Optimization
Section titled “Workflow Optimization”Incremental Updates
Section titled “Incremental Updates”# Only translate missing or outdated keysalgebras update --only-missingSelective Translation
Section titled “Selective Translation”# Translate specific languagesalgebras translate --languages es frQuality Assurance
Section titled “Quality Assurance”# Use UI-safe mode for UI stringsalgebras translate --ui-safe --glossary-id ui-terms
# Use custom prompt for technical contentalgebras translate --prompt-file technical-prompt.txtPerformance Monitoring
Section titled “Performance Monitoring”Verbose Output
Section titled “Verbose Output”algebras translate --verboseShows detailed progress information including:
- Batch processing status
- Translation timing
- Error details
- Performance metrics
Status Monitoring
Section titled “Status Monitoring”algebras statusShows:
- Configuration status
- Recent translation history
- Performance statistics
- Error counts
Integration Examples
Section titled “Integration Examples”CI/CD Pipeline
Section titled “CI/CD Pipeline”name: Update Translationson: push: paths: ['src/locales/en/**']
jobs: translate: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - name: Setup Python uses: actions/setup-python@v4 with: python-version: '3.9' - name: Install Algebras CLI run: pip install git+https://github.com/algebras-ai/algebras-cli.git - name: Update Translations run: algebras ci --only-missing --fail-on-error env: ALGEBRAS_API_KEY: ${{ secrets.ALGEBRAS_API_KEY }}Pre-commit Hook
Section titled “Pre-commit Hook”#!/bin/bash# Check if English locale files changedif git diff --cached --name-only | grep -q "src/locales/en/"; then echo "English locale files changed, updating translations..." algebras update --only-missing git add src/locales/fiTroubleshooting Advanced Features
Section titled “Troubleshooting Advanced Features”UI-Safe Issues
Section titled “UI-Safe Issues”Problem: Translations still too long Solution: Check glossary terms and adjust prompt specificity
Batch Processing Errors
Section titled “Batch Processing Errors”Problem: Rate limit errors
Solution: Reduce --max-parallel-batches or increase --batch-size
Git Integration Issues
Section titled “Git Integration Issues”Problem: Unnecessary translations Solution: Ensure source files are properly tracked in Git
Performance Issues
Section titled “Performance Issues”Problem: Slow translations Solutions:
- Increase
--batch-size - Increase
--max-parallel-batches - Use
--only-missingfor updates
Next Steps
Section titled “Next Steps”- Troubleshooting - Common issues and solutions
- Commands Reference - Complete command reference
- Configuration - Detailed configuration options