PHP code example of 00f100 / fcphp-i18n
1. Go to this page and download the library: Download 00f100/fcphp-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/ */
00f100 / fcphp-i18n example snippets
$default = 'pt-br';
$translate = [
'pt-br' => [
'My name is %s' => 'Meu nome é %s',
],
'en' => [
'My name is %s' => 'My name is %s',
],
'es' => [
'My name is %s' => 'Mi nombre és %s',
],
];
__i18n_configure($default, $translate);
$name = 'João';
$text = 'My name is %s';
// Print: Meu nome é João
echo __($text, $name);
// Print: Meu nome é João
echo _i18n_translate($text, $name);