PHP code example of sy / translate

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

    

sy / translate example snippets




return [
	'Hello world' => 'Bonjour monde', 
	...
]



use Sy\Translate\PhpTranslator;

// Create a translator
$translator = new PhpTranslator();

// Set translation files directory
$translator->setTranslationDir(__DIR__ . '/path/to/directory');

// Set translation file
$translator->setTranslationLang('fr');

// Return 'Bonjour monde'
$translator->translate('Hello world'),



use Sy\Translate\GettextTranslator;

// Create a translator
$translator = new GettextTranslator();

// Set translation files directory
$translator->setTranslationDir(__DIR__ . '/path/to/directory');

// Set translation file
$translator->setTranslationLang('fr');

// Return 'Bonjour monde'
$translator->translate('Hello world'),