1. Go to this page and download the library: Download phpdot/i18n 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/ */
phpdot / i18n example snippets
use PHPdot\I18n\I18nConfig;
use PHPdot\I18n\Translator;
use PHPdot\I18n\Loader\PhpArrayLoader;
$config = new I18nConfig(
default: 'en',
supported: ['en', 'ar', 'fr'],
paths: ['/app/lang'],
);
$translator = new Translator(
loader: new PhpArrayLoader($config),
cache: $cache, // any PSR-16 implementation
config: $config,
);
$translator->setLocale('ar_JO');
echo $translator->translate('messages.welcome', ['name' => 'Omar']);
// lang/en/messages.php
return [
'welcome' => 'Welcome, {name}!',
'items' => '{count, plural, one {# item} other {# items}}',
'buttons' => [
'save' => 'Save', // messages.buttons.save
],
'buttons.save' => 'Save', // the same key, written flat
];
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.