PHP code example of beautinow / translug

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

    

beautinow / translug example snippets


  'stripe' => [
        'model' => App\User::class,
        'key' => env('STRIPE_KEY'),
        'secret' => env('STRIPE_SECRET'),
    ],
   // 下面是你添加的内容
   'youdao' => [
           'appKey' => env('YOUDAO_APP_KEY'),
           'appSecret' => env('YOUDAO_APP_SECRET'),
       ],
       
/*  如果你是从 translug:~1.0 升级的话,需要把下面的配置修改成上面的
'youdao' => [
        'key' => env('YOUDAO_API_KEY'),
        'from' => env('YOUDAO_KEY_FROM'),
    ],
 */   

YOUDAO_APP_KEY=app_key
YOUDAO_APP_SECRET=app_secret

 //providers
 \JellyBool\Translug\TranslugServiceProvider::class,

// aliases
'Translug' => \JellyBool\Translug\TranslugFacade::class,

app('translug')->translate('如何安装 Laravel'); 
//How to install the Laravel

// or 
use Translug;
Translug::translate('如何安装 Laravel');
//How to install the Laravel

app('translug')->translug('如何安装 Laravel'); 
//how-to-install-the-laravel

// or 
use Translug;
Translug::translug('如何安装 Laravel');
//how-to-install-the-laravel

//或者你只想要 slug 的话

translug('如何安装 Laravel');
//how-to-install-the-laravel

translug('怎么理解 laravel 关联模型');
//how-to-understand-the-laravel-associated-model

//針對繁體,翻譯會有一點不一樣
translug('怎麼理解 laravel 關聯模型');
//how-to-understand-the-laravel-correlation-model

use JellyBool\Translug\Translug;

$translug = new Translug(['appKey' => 'your_key_from', 'appSerect' => 'your_api_key' ]);
// 或者也可以这样
$translug = new Translug();
$translug->setConfig('appKey' => 'your_key_from', 'appSerect' => 'your_api_key']);

$translug->translate('如何安装 Laravel');
//How to install the Laravel

$translug->translug('如何安装 Laravel');
//how-to-install-the-laravel