zendframework/zend-i18n
Zend\I18n provides a full translation suite for PHP/Zend Framework: supports major translation formats, pluralization, and text domains. Translator is mostly dependency-free, using the Intl extension only for default locale fallback. Repository abandoned; moved to laminas/laminas-i18n.
composer require zendframework/zend-i18nlaminas/laminas-i18n as the official successor.)Zend\I18n\Translator\Translator and Zend\I18n\View\Helper\TranslateTranslator manually (e.g., for legacy Zend-based migrations or hybrid stacks), or use Translate as a fallback for view-layer translations if integrating older views.translator in config/translator.php (or config/app.php): set locale, translation_file_patterns, and adapter (e.g., gettext, ini, array)..mo/.po (gettext), .ini, or .php array files (e.g., resources/lang/en_US/LC_MESSAGES/messages.mo).<?= $this->translate('Hello world') ?> if leveraging Zend View (rare in Laravel), or inject the Translator service manually into Laravel views/controllers via dependency injection.// In a service provider or controller
$translator = app(\Zend\I18n\Translator\Translator::class);
$translator->setLocale(app()->getLocale());
echo $translator->translate('Welcome');
App::setLocale() to sync Zend\Translator’s locale via a service provider boot method.translatePlural() with Zend\I18n\Translator\Plural\Rule for language-specific pluralization.laminas/laminas-i18n)—API-compatible but actively supported.locale must match the directory structure (e.g., en_US, not en-US). Use LC_MESSAGES subdirectory for gettext files.File cache) to avoid parsing translation files on every request:
$translator->setCache(new \Zend\Cache\Storage\Adapter\Filesystem());
en, Zend uses en_US. Normalize via setLocale() with rtrim($locale, '_') or map locales explicitly.__('message') helper—override Laravel’s trans() or create a custom helper that delegates to the Zend translator.getMessages($locale, $textdomain) to inspect loaded translations at runtime.How can I help you explore Laravel packages today?