Download the PHP package monkeyscloud/monkeyslegion-i18n without Composer
On this page you can find all versions of the php package monkeyscloud/monkeyslegion-i18n. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download monkeyscloud/monkeyslegion-i18n
More information about monkeyscloud/monkeyslegion-i18n
Files in monkeyscloud/monkeyslegion-i18n
Package monkeyslegion-i18n
Short Description Production-ready I18n & localization component for the MonkeysLegion PHP framework — v2
License MIT
Informations about the package monkeyslegion-i18n
MonkeysLegion I18n v2
Production-ready internationalization & localization for the MonkeysLegion PHP framework.
Translate, pluralize, format numbers/dates/currencies, and manage locales with security and performance at the core. Built with PHP 8.4 property hooks and asymmetric visibility.
Table of Contents
- Installation
- Quick Start
- Translator
- Basic Translation
- Parameter Replacement
- Pluralization
- Namespaced Translations
- Fallback Locale
- Missing Translation Tracking
- Warm-Up
- MessageFormatter
- Parameter Modifiers
- XSS Protection
- NumberFormatter
- Decimal Formatting
- Currency Formatting
- Compact Notation
- Ordinals
- File Size
- DateFormatter
- Named Formats
- Relative Time
- Diff for Humans
- LocaleManager
- Detection Chain
- Supported Locales
- LocaleInfo
- Native Names
- RTL Detection
- Flag Emojis
- Loaders
- FileLoader
- DatabaseLoader
- CacheLoader
- CompiledLoader
- MlcLoader
- Middleware
- LocaleMiddleware
- LocaleUrlMiddleware
- LocaleRedirectMiddleware
- Enums
- PluralCategory
- Direction
- Attributes
- #[Translatable]
- #[Locale]
- Events
- Template Directives
- Helper Functions
- TranslatorFactory
- Translation Management
- CLI Commands
- Security
- Performance
- Migration from v1
- Testing
- License
Installation
Requirements
- PHP 8.4+ (property hooks, asymmetric visibility)
- ext-json (JSON translation files)
- ext-mbstring (Unicode support)
Optional Extensions
Quick Start
Translation File Structure
Example messages.json
Translator
Basic Translation
Parameter Replacement
Pluralization
Supports ICU plural categories for 200+ languages.
Namespaced Translations
Fallback Locale
Missing Translation Tracking
Warm-Up
Pre-load translation groups for production performance:
Property Hooks (PHP 8.4)
Locale Changed Events
MessageFormatter
Parameter Modifiers
Use braced syntax with modifiers for advanced formatting:
XSS Protection
NumberFormatter
Locale-aware number formatting with graceful ext-intl fallback.
Decimal Formatting
Currency Formatting
Compact Notation
Ordinals
Percentage
File Size
Spell Out
DateFormatter
Locale-aware date/time formatting with relative time support.
Named Formats
Relative Time
Diff for Humans
Day and Month Names
ISO 8601
LocaleManager
Manages locale detection, validation, and state.
Detection Chain
Supported Locales
Locale Parsing
LocaleInfo
Static metadata for 50+ locales.
Native Names
RTL Detection
Flag Emojis
Script & Knowledge
Loaders
FileLoader
Loads from JSON and PHP files with security hardening.
DatabaseLoader
Load translations from any SQL database — MySQL, MariaDB, PostgreSQL, and SQLite.
Install the Schema
Ready-to-use SQL files are included in schema/:
Schema (MySQL)
Schema (PostgreSQL)
Schema (SQLite)
Usage
CacheLoader
Decorator that caches translations from any other loader.
CompiledLoader
Opcache-friendly compiled PHP files — 10-50x faster than JSON decode.
MlcLoader
Zero-dependency alternative to YAML — uses a simple key=value format.
MLC file format (flat — one group per file):
MLC file format (sectioned — multiple groups per file):
Why MLC over YAML?
- Zero external dependencies (no
symfony/yaml) - Simpler syntax, less error-prone
- Translators don't need to learn YAML indentation rules
- Same security hardening as FileLoader
Middleware
LocaleMiddleware
Auto-detect and set locale for each request.
LocaleUrlMiddleware
Extract locale from URL path segment.
LocaleRedirectMiddleware
Auto-redirect to localized URL if locale prefix is missing.
Enums
PluralCategory
Direction
Attributes
[Translatable]
Mark entity properties for automatic translation:
[Locale]
Auto-inject the detected locale into controller parameters:
Events
Template Directives
For use with MonkeysLegion-Template engine:
In templates:
Helper Functions
Global helper functions for convenience:
TranslatorFactory
One-line creation with all features:
Translation Management
Full CRUD management for file and database translations:
CLI Commands
Security
Path Traversal Prevention
Locale Injection Prevention
SQL Injection Prevention
XSS Protection
Cookie Security
Performance
Compiled Loader (Production)
Cache with Jitter
Warm-Up
Const Array Pluralizer
Migration from v1
Namespace Changes
Note: Backward-compatible aliases exist at
src/Contracts/aliases.php.
Property Hooks
Locale Validation
Middleware Split
Testing
Test Coverage
- 139 tests, 250+ assertions
- Covers: Translator, Pluralizer, MessageFormatter, NumberFormatter, DateFormatter, LocaleManager, LocaleInfo, FileLoader, MlcLoader, CompiledLoader, Enums, Attributes, Events, Factory, CLI
License
MIT License. See LICENSE for details.
Built with ❤️ by MonkeysCloud
All versions of monkeyslegion-i18n with dependencies
ext-json Version *
ext-mbstring Version *
psr/http-message Version ^2.0
psr/http-server-handler Version ^1.0
psr/http-server-middleware Version ^1.0
psr/simple-cache Version ^3.0