PHP code example of buyme / laravel-google-translate

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

    

buyme / laravel-google-translate example snippets


return [
    /*
    |----------------------------------------------------------------------------------------------------
    | The ISO 639-1 code of the language in lowercase to which the text will be translated to by default.
    |----------------------------------------------------------------------------------------------------
    */
    'default_target_translation' => 'en',

    /*
    |-------------------------------------------------------------------------------
    | Path to the json file containing the authentication credentials.
    |
    |-------------------------------------------------------------------------------
    */
    'api_key' => env('GOOGLE_TRANSLATE_API_KEY'),
];

GoogleTranslate::detectLanguage('Hello world'): array

GoogleTranslate::detectLanguage(['Hello world', 'Laravel is the best']);

// Returns multi-dimensional array containing result set for all the array elements.

// GoogleTranslate::translate($input, $from = null, $to = null, $format = 'text'): array

GoogleTranslate::translate('Hello world'): array

GoogleTranslate::translate(['Hello world', 'Laravel is the best']);

// Returns multi-dimensional array containing result set for all the array elements.

GoogleTranslate::getAvailableTranslationsFor('en'): array

GoogleTranslate::translateUnlessLanguageIs('en', string $text);

GoogleTranslate::justTranslate(string $text): string

GoogleTranslate::translateUnlessLanguageIs('en', string $text, string $format);
bash
php artisan vendor:publish --provider="Byume\GoogleTranslate\GoogleTranslateServiceProvider"