WPZylos I18n
Internationalization with dynamic text domain and WordPress translation integration.
What You Get
- Dynamic text domain — Uses context, not hardcoded strings
- Translation loading — Automatic MO file loading
- Translator class — Object-oriented translation API
- Plural support —
plural()wrapper with proper handling
Quick Start
use WPZylos\Framework\I18n\Translator;
$translator = new Translator($context);
// Localization (uses context's textDomain)
echo $translator->translate('Settings saved');
echo $translator->plural('1 item', '%d items', $count);
// With placeholders
echo $translator->sprintf(
$translator->translate('Welcome, %s'),
$userName
);
Why Dynamic Text Domain
Hardcoded text domains break PHP-Scoper builds and prevent multi-instance plugins:
// Bad: Hardcoded - breaks after scoping
__('Hello', 'my-plugin');
// Good: Dynamic from context - survives scoping
$translator->translate('Hello');
Documentation
- Overview — I18n architecture
- Installation — Setup
- Usage — Translation patterns
- API Reference — Translator methods
- Examples — Real-world usage
- Testing — Testing translations
- Security — Security notes
- Troubleshooting — Common issues
Related Packages
- wpzylos-core — PluginContext for text domain
- wpzylos-views — Localized view rendering