1. Go to this page and download the library: Download almacil/php-translate 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/ */
almacil / php-translate example snippets
// Require composer autoloader
auto detectable language
$lang = 'en';
// Directory containing the json files with the translations
$directory = __DIR__ . '/i18n';
// We want the library to search for the translations that it cannot find in the files and to
// ... after the setup
function t($text, $params = null) {
global $translate;
return $translate->get($text, $params);
}
echo '<p>' . t('Hola mundo!') . '</p>'; // <p>Hello World!</p>