PHP code example of joelstein / laravel-t
1. Go to this page and download the library: Download joelstein/laravel-t library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
joelstein / laravel-t example snippets
t('Hello, :name!', ['name' => $user->name])
// Plain strings
t('Hello, world!')
// Named placeholders
t('Hello, :name!', ['name' => $user->name])
// ICU plurals
t('{count, plural, one {# item} other {# items}}', ['count' => $total])
// Contexts (for homographs)
t('May', context: 'month')
// Inline markup via closures
t('Click <a>here</a>.', [
'a' => fn ($text) => "<a href=\"/next\">{$text}</a>",
])
// Explicit locale override
t('Saved.', locale: 'es')
return [
'path' => lang_path('t'),
'source_locale' => 'en',
'locales' => ['en'],
'fallback_locale' => null,
'scan_paths' => ['app', 'resources/views'],
'cache' => null, // null = cache in production only
'cache_ttl' => 86400,
'log_missing' => null, // true, a channel name, or null to disable
];
bash
# Scan source files and update PO files for every configured locale
php artisan t:extract
# List untranslated strings, optionally for one locale
php artisan t:untranslated
php artisan t:untranslated es
# Validate PO files (parse errors, placeholder mismatches, invalid ICU)
php artisan t:lint
php artisan t:lint es
# Clear the translation cache
php artisan t:clear