agentsclimarketplace

Laravel i18n

Skill fusengine/agents/plugins/laravel-expert/skills/laravel-i18n

Redefining development through cognitive automation and collaborative agent systems.

Install
npx -y skills add fusengine/agents --skill laravel-i18n

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

One thing to look at

  • 22 stars22 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

Laravel localization - __(), trans_choice(), lang files, JSON translations, pluralization, middleware, formatting. Use when implementing translations.

SKILL.md

4.5 KB, as published. Nobody here has run it

Laravel Internationalization

Agent Workflow (MANDATORY)

Before ANY implementation, use TeamCreate to spawn 3 agents:

  1. fuse-ai-pilot:explore-codebase - Check existing translation patterns
  2. fuse-ai-pilot:research-expert - Verify Laravel i18n best practices via Context7
  3. mcp__context7__query-docs - Check Laravel localization documentation

After implementation, run fuse-ai-pilot:sniper for validation.


Overview

FeaturePHP FilesJSON Files
KeysShort (messages.welcome)Full text
NestingSupportedFlat only
Best forStructured translationsLarge apps

Critical Rules

  1. Never concatenate strings - Use :placeholder replacements
  2. Always handle zero in pluralization
  3. Group by feature - auth.login.title, auth.login.button
  4. Extract strings early - No hardcoded text in views
  5. Validate locales - Use enum or whitelist

Decision Guide

Translation 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')

Reference Guide

Concepts (WHY & Architecture)

TopicReferenceWhen to Consult
Setuplocalization.mdInitial configuration
Pluralizationpluralization.mdCount-based translations
Bladeblade-translations.mdView translations
Middlewaremiddleware.mdLocale detection
Formattingformatting.mdDate/number/currency
Packagespackages.mdVendor translations
Best Practicesbest-practices.mdLarge app organization

Templates (Complete Code)

TemplateWhen to Use
SetLocaleMiddleware.php.mdURL/session locale detection
lang-files.mdTranslation file examples
LocaleServiceProvider.php.mdCentralized localization service
LocaleRoutes.php.mdURL prefix locale routing

Quick Reference

// Basic translation
__('messages.welcome')

// With replacement
__('Hello :name', ['name' => 'John'])

// Pluralization
trans_choice('messages.items', $count)

// Runtime locale
App::setLocale('fr');
App::currentLocale();  // 'fr'

Best Practices

DO

  • Use :placeholder for dynamic values
  • Handle zero case in pluralization
  • Group keys by feature module
  • Use Locale enum for type safety
  • Set Carbon locale in middleware

DON'T

  • Concatenate translated strings
  • Hardcode text in views
  • Accept any locale without validation
  • Create DB-based translations (use files)

Laravel 13 Notes

L'API de localisation (__(), trans_choice(), App::setLocale()) reste inchangée en Laravel 13. Points spécifiques :

  • Context::add('locale', $locale) propage la locale dans les jobs queue (résout le bug L12 où la locale était perdue dans les ShouldQueue)
  • serializable_classes : whitelister vos Locale enums si utilisés en queue
  • Middleware SetLocale : compatible avec le nouveau validateOrigin() de [[laravel-auth]]
// app/Jobs/SendNotification.php
public function handle(): void
{
    App::setLocale(Context::get('locale', 'en'));
    Notification::send($this->user, new OrderShipped());
}

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.