PHP code example of gobline / translator

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

    

gobline / translator example snippets


$translator = new Gobline\Translator\Translator();

$translator->addTranslationFile(__DIR__.'./translations/fr/messages.php', 'fr');

$translator->addTranslationFile(__DIR__.'./translations/nl', 'nl');

$translator->addTranslationArray(['First name' => 'Vorname'], 'de');

$translator->setDefaultLanguage('fr'); // you can set a default language

$translator->translate('First name'); // no language specified, using def. lang "fr" and returns "Prénom"

$translator->translate('First name', null, 'nl'); // returns "Voornaam"

$translator->translate('First name', null, 'it'); // no Italian translations provided, returns "First name"

$translator->translate('User %1 created', 'John'); // returns "Utilisateur John créé"

$translator->translate('User %1 %2 created', ['John', 'Smith']); // returns "Utilisateur John Smith créé"