PHP code example of switon / i18n
1. Go to this page and download the library: Download switon/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/ */
switon / i18n example snippets
use Switon\Core\Attribute\Autowired;
use Switon\I18n\TranslatorInterface;
class WelcomeService
{
#[Autowired] protected TranslatorInterface $translator;
public function message(string $name): string
{
return $this->translator->translate('hello', ['name' => $name]);
}
}
// @resources/i18n/en.php
// return [
// 'hello' => 'Hello, {name}!',
// ];