Loading...
Loading...
Laravel localization - __(), trans_choice(), lang files, JSON translations, pluralization, middleware, formatting. Use when implementing translations.
npx skill4agent add fusengine/agents laravel-i18nTeamCreate| Feature | PHP Files | JSON Files |
|---|---|---|
| Keys | Short ( | Full text |
| Nesting | Supported | Flat only |
| Best for | Structured translations | Large apps |
:placeholderauth.login.titleauth.login.buttonTranslation task?
├── Basic string → __('key')
├── With variables → __('key', ['name' => $value])
├── Pluralization → trans_choice('key', $count)
├── In Blade → @lang('key') or {{ __('key') }}
├── Locale detection → Middleware
├── Format date/money → LocalizationService
└── Package strings → trans('package::key')| Topic | Reference | When to Consult |
|---|---|---|
| Setup | localization.md | Initial configuration |
| Pluralization | pluralization.md | Count-based translations |
| Blade | blade-translations.md | View translations |
| Middleware | middleware.md | Locale detection |
| Formatting | formatting.md | Date/number/currency |
| Packages | packages.md | Vendor translations |
| Best Practices | best-practices.md | Large app organization |
| Template | When to Use |
|---|---|
| SetLocaleMiddleware.php.md | URL/session locale detection |
| lang-files.md | Translation file examples |
| LocaleServiceProvider.php.md | Centralized localization service |
| LocaleRoutes.php.md | URL prefix locale routing |
// Basic translation
__('messages.welcome')
// With replacement
__('Hello :name', ['name' => 'John'])
// Pluralization
trans_choice('messages.items', $count)
// Runtime locale
App::setLocale('fr');
App::currentLocale(); // 'fr':placeholder