1. Go to this page and download the library: Download nyrados/translator 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/ */
nyrados / translator example snippets
use Nyrados\Translator\TranslatorApi;
use Nyrados\Translator\Provider\ArrayProvider;
'article_header' => 'A meaningful title',
'article' => 'A very interesting article',
]);
$provider->set('de', [
'greet' => 'Hallo {name}!',
'article_header' => 'Eine aussagekräftige Überschrift',
]);
$t = new Translator();
$t->addProvider($provider);
$t->setPreferences(['de-at', 'en-us']);
echo $trans->get($context);
echo $trans($context) // via __invoke()
echo (string) $trans; // via __toString()
// Set from $_SERVER['HTTP_ACCEPT_LANGUAGE']
$t->setPreferences(Helper::preferencesFromAcceptLanguage());
// Set from a Psr\Http\Message\ServerRequestInterface instance
$t->setPreferences(Helper::preferencesFromAcceptLanguage($request));
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.