Skip to content

Commit 1632d41

Browse files
committed
Improves
1 parent 3a8119f commit 1632d41

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

README.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,29 @@ php artisan laravelcms --action=clear
5353
## Where can I get the app_id & app_key
5454

5555
- Option 1: Provider Baidu, From https://api.fanyi.baidu.com/, free, only 1 translate allowed per second
56+
57+
````json
58+
{
59+
"api_provider": "Baidu",
60+
"app_id": "201911000357",
61+
"app_key": "cX6xUKysHBXaH"
62+
}
5663
- Option 2: Provider Google, From https://cloud.google.com/translate/docs/
5764

5865
## Use free Google translate
5966

6067
- Set provider to Google_Free
61-
- Set both app_id & app_key to google_free_001, then our CMS will use package https://github.com/dejurin/php-google-translate-for-free to do the translate. (It's the default)
62-
- Set both app_id & app_key to google_free_002, then our CMS will use the package https://github.com/Stichoza/google-translate-php to do the translate, YOU NEED INSTALL THE PACKAGE VIA COMMAND LINE FIRST: composer require stichoza/google-translate-php
68+
- Option 1: Set both app_id & app_key to google_free_001, then our CMS will use package https://github.com/dejurin/php-google-translate-for-free to do the translate. (It's the default setting after install)
69+
70+
```json
71+
{
72+
"api_provider": "Google_Free",
73+
"app_id": "google_free_001",
74+
"app_key": "google_free_001"
75+
}
76+
````
77+
78+
- Option 2: Set both app_id & app_key to google_free_002, then our CMS will use the package https://github.com/Stichoza/google-translate-php to do the translate, YOU NEED INSTALL THE PACKAGE VIA COMMAND LINE FIRST: composer require stichoza/google-translate-php
6379

6480
```json
6581
{

src/Controllers/TranslatorController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function update($form_data, $page, $plugin_settings)
7676
if ('' == trim($form_data['translate_content'])) {
7777
return false;
7878
}
79-
if ('baidu' == $plugin_settings['api_provider']) {
79+
if ('baidu' == strtolower($plugin_settings['api_provider'])) {
8080
$this->app_id = $plugin_settings['app_id'];
8181
$this->app_key = $plugin_settings['app_key'];
8282

@@ -98,7 +98,7 @@ public function update($form_data, $page, $plugin_settings)
9898

9999
return false;
100100
}
101-
} elseif ('google_free' == $plugin_settings['api_provider']) {
101+
} elseif ('google_free' == strtolower($plugin_settings['api_provider'])) {
102102
if ('google_free_002' == $plugin_settings['app_key']) {
103103
// https://github.com/Stichoza/google-translate-php
104104
// Need the end-user install via composer first

src/database/migrations/2020_01_19_114400_update_plugin_settings_table.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,12 @@ public function up()
2525
'input_attribute' => '{"rows":10,"required":"required"}',
2626
'enabled' => 1,
2727
'sort_value' => 20,
28-
'abstract' => 'Translate content by Baidu AI or Google AI',
28+
'abstract' => 'Automatically translate content via Google AI or Baidu AI. <a href="https://github.com/AlexStack/Laravel-CMS-Plugin-Translator#where-can-i-get-the-app_id--app_key" target="_blank"><i class="fas fa-link mr-1"></i>Tutorial</a>',
2929
'param_value' => '{
3030
"blade_file": "translator",
3131
"tab_name": "<i class=\'fas fa-language mr-1\'></i>__(translator)",
3232
"php_class": "App\\\\LaravelCms\\\\Plugins\\\\Translator\\\\Controllers\\\\TranslatorController",
33-
"api_provider": "google_free",
33+
"api_provider": "Google_Free",
3434
"app_id": "google_free_001",
3535
"app_key": "google_free_001"
3636
}',

0 commit comments

Comments
 (0)