PHP code example of polyglot / translator

1. Go to this page and download the library: Download polyglot/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/ */

    

polyglot / translator example snippets




/**
 * @var \Polyglot\Contract\TemplateProvider\TemplateProvider $templateProvider
 * @var \Polyglot\Contract\TemplateResolver\TemplateResolver $templateResolver
 */
$polyglot = new \Polyglot\Translator\Polyglot('en_US', $templateProvider, $templateResolver);

$french = $polyglot->trans('translation_id', [], 'domain', 'fr_FR');
$default = $polyglot->trans('translation_id', [], 'domain');