Download the PHP package elcheco/translator without Composer
On this page you can find all versions of the php package elcheco/translator. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download elcheco/translator
More information about elcheco/translator
Files in elcheco/translator
Package translator
Short Description Translation system using neon files, supports plurals and string replacements, fallback language. Extension to Nette Framework ^3.0
License BSD-3-Clause
Informations about the package translator
ElCheco Translator
A powerful and flexible translation library for PHP applications with support for both NEON files and database storage, featuring full Unicode CLDR plural rules support.
Features
- CLDR Plural Rules Support - Full Unicode CLDR compliance for accurate pluralization
- Legacy Format Compatibility - Seamless support for existing numeric plural formats
- Multiple Storage Backends - NEON files or database storage
- Advanced Pluralization - Support for all CLDR categories (zero, one, two, few, many, other)
- Decimal Number Support - Correct handling of decimal plurals (e.g., Czech uses 'many' for decimals)
- Locale-Specific Number Formatting - Automatic number formatting based on locale
- Translation Usage Tracking - Monitor which translations are actually used
- Console Commands - Import, export, and convert translations
- Migration Tools - Convert legacy formats to CLDR standard
- Fallback Locale Support - Automatic fallback when translations are missing
- Compatible with Nette Framework - Full integration with Nette DI
What's New in Version 2.0
- π CLDR Plural Rules - Industry-standard pluralization for 100+ languages
- π’ Decimal Number Support - Proper handling of fractional numbers in plurals
- π Automatic Format Detection - Use legacy and CLDR formats in the same project
- π οΈ Migration Tools - Convert existing translations to CLDR format
- π Enhanced Database Support - Store CLDR patterns and ICU MessageFormat
- β‘ Zero Breaking Changes - Full backward compatibility maintained
Requirements
- PHP 8.3 or higher
- Nette Framework 3.0 or higher (if using with Nette)
- Dibi database library (if using database storage)
- PHP Intl extension (recommended for CLDR support)
Installation
Configuration
Basic Configuration (Nette DI)
NEON File-Based Translations
Database-Based Translations
CLDR Plural Rules Support
The translator now supports the Unicode CLDR (Common Locale Data Repository) standard for plural rules, providing linguistically correct pluralization for all languages.
What are CLDR Plural Rules?
CLDR defines standardized categories for plural forms:
- zero: For zero items (some languages have special forms)
- one: For singular (but not always just 1!)
- two: For dual forms (e.g., Slovenian)
- few: For small quantities (e.g., 2-4 in Czech)
- many: For larger quantities or special cases (e.g., decimals in Czech)
- other: The default/general plural form
CLDR vs Legacy Format
The translator supports both formats simultaneously:
Legacy Format (still supported):
CLDR Format (recommended):
Special Case: Czech Decimals
Czech (and Slovak) use the many
category specifically for decimal numbers:
This ensures grammatically correct output:
- β 1,5 kilometru (not "kilometrΕ―" or "kilometr")
- β 2,5 kilometru (not "kilometry")
Usage
In Presenters or Services
In Templates (Latte)
Direct Usage in PHP
NEON Translation Files
Translation files support both legacy and CLDR formats:
Simple Translations
Legacy Plural Format
CLDR Format (Recommended)
Command Line Tools
Import Translations from NEON to Database
Export Translations from Database to NEON
Convert Legacy Translations to CLDR Format (NEW!)
Database Structure
The database schema has been enhanced to support CLDR:
Number Formatting
The translator automatically formats numbers according to locale:
Migration Guide
Migrating to CLDR Format
- Automatic Detection: The translator automatically detects and handles both formats
- Gradual Migration: You can migrate translations one by one
- Migration Tool: Use the console command to convert existing translations
Example Migration
Before (Legacy):
After (CLDR):
Advanced Features
Custom Plural Rules
Usage Tracking (Database Only)
Testing
Language Support
The translator includes built-in CLDR plural rules for 100+ languages, including:
- Simple plurals (one/other): English, German, Dutch, Spanish, Italian
- Slavic languages: Czech, Slovak, Polish, Russian, Ukrainian, Croatian
- Complex plurals: Arabic (6 forms), Irish, Maltese, Lithuanian
- No plurals: Japanese, Chinese, Thai, Vietnamese
- Special decimals: Czech/Slovak (many), Lithuanian (many), Romanian (few)
Examples
E-commerce Site
Weather App
Changelog
Version 2.0.0
- Added full Unicode CLDR plural rules support
- Added decimal number handling for all languages
- Added ICU MessageFormat support
- Added migration tools for legacy β CLDR conversion
- Enhanced database schema for CLDR storage
- Maintained 100% backward compatibility
Version 1.x
- Basic translation support
- Legacy plural forms
- Database and NEON storage
- Import/export commands
Contributing
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
License
MIT License
Credits
Inspired by rostenkowski/translate, enhanced with:
- Full CLDR plural rules support
- Decimal number handling
- Modern PHP 8.3+ features
- Enhanced database functionality
- Comprehensive migration tools
Support
For questions and support:
- Create an issue on GitHub
- Check the documentation
- See examples
All versions of translator with dependencies
ext-intl Version *
ext-tokenizer Version *
dibi/dibi Version ^v5.0
nette/di Version ^3.1
nette/neon Version ^3.0
nette/safe-stream Version ^2.4|^3.0
nette/utils Version ^3.0|^4.0
psr/log Version ^3.0
symfony/console Version ^7.2
latte/latte Version ^3.0