Lingo.dev + .php (Laravel)
Lingo.dev CLI translates PHP array-based language files while preserving syntax, Laravel conventions, and PHP-specific formatting. The CLI maintains PHP array syntax and formatting exactly, works seamlessly with Laravel's localization system, preserves :name
and :count
variables, handles multi-dimensional array structures, and is compatible with any PHP framework using arrays.
Quick Setup
Configure for PHP language array files:
{
"locale": {
"source": "en",
"targets": ["es", "fr", "de"]
},
"buckets": {
"php": {
"include": ["resources/lang/[locale]/*.php"]
}
}
}
Reminder: [locale]
is a placeholder that should remain in the config literally, as it's replaced with the actual locale during CLI run.
Translate PHP Arrays
npx lingo.dev@latest i18n
Preserves PHP syntax, array structure, and Laravel-specific conventions while translating string values.
PHP Array Structure
Basic Language Arrays
<?php
return [
'welcome' => 'Welcome to our application',
'dashboard' => 'Dashboard',
'settings' => 'Settings',
'logout' => 'Log Out',
];
Nested Array Support
<?php
return [
'auth' => [
'login' => 'Log In',
'register' => 'Register',
'forgot_password' => 'Forgot Password?',
'reset_password' => 'Reset Password',
],
'validation' => [
'required' => 'This field is required',
'email' => 'Please enter a valid email address',
],
];
Laravel Placeholder Support
<?php
return [
'welcome_user' => 'Welcome back, :name!',
'items_count' => 'You have :count items in your cart',
'validation' => [
'min' => 'The :attribute must be at least :min characters',
],
];
Framework Integration
Laravel Translation Helpers
Works seamlessly with Laravel's translation functions:
__('messages.welcome')
trans('auth.login')
@lang('validation.required')
Pluralization Support
<?php
return [
'items' => 'item|items',
'minutes' => '{0} no minutes|{1} one minute|[2,*] :count minutes',
];
Advanced Configuration
Multiple Language Directories
"php": {
"include": [
"resources/lang/[locale]/*.php",
"lang/[locale]/**/*.php"
]
}
Lock Configuration Keys
"php": {
"include": ["resources/lang/[locale]/*.php"],
"lockedKeys": ["app.timezone", "app.locale", "app.fallback_locale"]
}