Tongues Documentation
Complete guide for i18n translation validation
Getting Started
Tongues is a powerful i18n translation file checker that helps maintain consistency across your translation files. It automatically scans common i18n directories and supports JSON and ARB formats.
Quick Start
go install github.com/infobits-io/tongues@latesttonguesTongues will automatically find your translation files in common directories like i18n, locales, src/i18n, src/locales, and more.
Installation
Go Install
If you have Go installed (1.21 or later):
go install github.com/infobits-io/tongues@latestHomebrew (macOS)
Install using Homebrew on macOS:
brew tap infobits/tongues\nbrew install tonguesSnap (Linux)
Install using Snap on Linux distributions:
sudo snap install tonguesScoop (Windows)
Install using Scoop on Windows:
scoop bucket add infobits https://github.com/infobits/scoop-bucket\nscoop install tonguesBinary Downloads
Download pre-built binaries from the releases page.
CLI Usage
Tongues provides a comprehensive command-line interface with many options.
Basic Usage
tonguesThis checks translation files in the current directory or automatically finds them in common i18n directories.
Command Options
Examples
# Check translations in current directory
tongues
# Check specific directory
tongues -d ./locales
# Use Spanish as reference
tongues -r es
# Output as JSON for CI/CD
tongues -f json --strict
# Clean and sort files
tongues --clean
# Fix missing keys with placeholder
tongues --fix --placeholder "[TODO]"
# Check ARB descriptions
tongues --check-descriptions
# Verbose output with extra keys
tongues -v --extraGitHub Action
Tongues provides a reusable GitHub Action for CI/CD pipelines.
Basic Setup
name: Check Translations
on: [push, pull_request]
jobs:
i18n-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: infobits/tongues@v1
with:
directory: ./i18n
strict: trueAdvanced Configuration
name: i18n Validation
on:
pull_request:
paths:
- 'locales/**'
- 'src/i18n/**'
jobs:
validate-translations:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Check Translations
uses: infobits/tongues@v1
with:
directory: ./src/i18n
reference: en
strict: true
check-empty: true
check-extra: true
check-descriptions: true
- name: Auto-fix Missing Keys
if: github.event_name == 'pull_request'
uses: infobits/tongues@v1
with:
directory: ./src/i18n
fix: true
placeholder: '[TODO]'
- name: Commit fixes
if: github.event_name == 'pull_request'
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add .
git diff --staged --quiet || git commit -m "Auto-fix missing translations"
git pushFeatures
Automatic Directory Detection
Tongues automatically searches for translation files in common directories:
i18n/l10n/locales/translations/lang/src/i18n/src/l10n/src/locales/src/translations/src/lang/
Nested Key Support
Tongues flattens nested JSON structures for comprehensive checking:
{
"user": {
"profile": {
"name": "Name",
"email": "Email"
}
}
}
// Checked as: user.profile.name, user.profile.emailSmart Filename Detection
Recognizes various naming patterns:
en.json- Simple language codeen_US.json- Locale with regionapp_en.arb- Prefixed filenamesmessages_es.json- Named bundles
ARB Format Support
Full support for Flutter's ARB format including:
- Automatic locale detection from
@@locale - Description checking with
@keymetadata - Placeholder validation
File Cleaning & Sorting
Keep your translation files organized:
- Alphabetically sort keys
- Maintain consistent formatting
- Remove duplicate keys
- Preserve metadata in ARB files
Auto-fix Capabilities
Automatically repair common issues:
- Add missing keys from reference
- Insert placeholder text for TODO items
- Copy translations from reference language
- Clean and standardize file structure
API Reference
Coming soon: REST API for translation validation and auto-translation services.
Authentication
The API supports multiple authentication methods:
- API Keys for CLI and CI/CD
- JWT tokens for web applications
- GitHub OAuth for repository integration
Endpoints
POST /api/v1/translate
{
"source_language": "en",
"target_language": "es",
"text": "Hello, world!",
"project_id": "uuid"
}
GET /api/v1/translate/usage
{
"tokens_used": 15000,
"translations_count": 250,
"period": "2024-01"
}
POST /api/v1/projects
{
"name": "my-app",
"github_repo": "user/repo",
"settings": {
"auto_translate": true,
"reference_language": "en"
}
}CLI Authentication
# Login to Tongues service
tongues auth login
# Set API key
export TONGUES_API_KEY="your-api-key"
# Use with auto-translation
tongues --fix --auto-translate