PHP code example of megajdcc / lg-translater

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

    

megajdcc / lg-translater 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.
    |
    | The process to get this file is documented in a step by step detailed manner
    | over here:
    | https://github.com/megajdcc/laravel-google-translate/blob/master/google.md
    |-------------------------------------------------------------------------------
    */
    '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::unlessLanguageIs('en', string $text);

GoogleTranslate::justTranslate(string $text): string

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