PHP code example of i18nagent / laravel-locale-chain
1. Go to this page and download the library: Download i18nagent/laravel-locale-chain 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/ */
// config/locale-chain.php
return [
'enabled' => true,
// Custom chains merged with defaults
'chains' => [
'pt-BR' => ['pt-PT', 'pt'],
'ja-JP' => ['ja'],
],
// Set to false to use ONLY your custom chains
'merge_defaults' => true,
];
// At runtime, via the translator instance
app('translator')->setChains([
'pt-BR' => ['pt-PT', 'pt'],
]);
// Or merge with defaults
use I18nAgent\LocaleChain\FallbackMap;
app('translator')->setChains(
FallbackMap::merge(['pt-BR' => ['pt']])
);