Agent skill
laravel-i18n
Laravel localization - __(), trans_choice(), lang files, JSON translations, pluralization. Use when implementing translations in Laravel apps.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/laravel-i18n-fusengine-agents
SKILL.md
Laravel Internationalization
Setup
php artisan lang:publish
Creates lang/ directory with default language files.
File Structure
lang/
├── en/
│ ├── messages.php # Short keys
│ └── validation.php
├── fr/
│ ├── messages.php
│ └── validation.php
├── en.json # Full text keys
└── fr.json
Configuration
// config/app.php
'locale' => env('APP_LOCALE', 'en'),
'fallback_locale' => env('APP_FALLBACK_LOCALE', 'en'),
Translation Helpers
// Basic translation
__('messages.welcome')
// With replacement
__('Hello :name', ['name' => 'John'])
// JSON approach (full text as key)
__('Welcome to our application')
// Alias
trans('messages.welcome')
PHP Translation Files
// lang/en/messages.php
return [
'welcome' => 'Welcome to our application',
'hello' => 'Hello :name',
'goodbye' => 'Goodbye :name, see you :time',
];
JSON Translation Files
// lang/fr.json
{
"Welcome to our application": "Bienvenue sur notre application",
"Hello :name": "Bonjour :name"
}
Pluralization
// lang/en/messages.php
'apples' => '{0} No apples|{1} One apple|[2,*] :count apples',
trans_choice('messages.apples', 0); // "No apples"
trans_choice('messages.apples', 1); // "One apple"
trans_choice('messages.apples', 5); // "5 apples"
Runtime Locale
use Illuminate\Support\Facades\App;
// Set locale
App::setLocale('fr');
// Get current locale
$locale = App::currentLocale();
// Check locale
if (App::isLocale('fr')) {
// ...
}
Middleware Example
// app/Http/Middleware/SetLocale.php
public function handle(Request $request, Closure $next): Response
{
$locale = $request->segment(1);
if (in_array($locale, ['en', 'fr', 'de'])) {
App::setLocale($locale);
}
return $next($request);
}
Blade Usage
{{ __('messages.welcome') }}
@lang('messages.welcome')
{{ trans_choice('messages.apples', 5) }}
Best Practices
- Use JSON files for large apps with many strings
- PHP files for structured, nested translations
- Always use placeholders
:namenot concatenation - Group by feature in namespaces:
auth.login.title
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?