Skip to content

Commit 1b328c1

Browse files
committed
v3.2 対応 & google translate api ライブラリを変更
1 parent b66832e commit 1b328c1

19 files changed

Lines changed: 1020 additions & 2589 deletions

composer.json

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,24 @@
22
"name": "com.appleple/google-translate",
33
"description": "a-blog cms extension.",
44
"scripts": {
5-
"lint": "vendor/bin/phpcs --standard=phpcs.xml",
6-
"format": "vendor/bin/phpcbf --standard=phpcs.xml",
7-
"post-install-cmd": "\"vendor/bin/phpcs\" --config-set installed_paths vendor/phpcompatibility/php-compatibility",
8-
"post-update-cmd" : "\"vendor/bin/phpcs\" --config-set installed_paths vendor/phpcompatibility/php-compatibility"
5+
"lint": "vendor/bin/phpcs --standard=phpcs.xml",
6+
"format": "vendor/bin/phpcbf --standard=phpcs.xml",
7+
"check:version": "vendor/bin/phpcs --standard=PHPCompatibility --runtime-set testVersion 8.1-8.4 --ignore=./src/vendor/* ./src",
8+
"post-install-cmd": "\"vendor/bin/phpcs\" --config-set installed_paths vendor/phpcompatibility/php-compatibility",
9+
"post-update-cmd": "\"vendor/bin/phpcs\" --config-set installed_paths vendor/phpcompatibility/php-compatibility"
910
},
1011
"require-dev": {
11-
"squizlabs/php_codesniffer": "3.*",
12-
"phpcompatibility/php-compatibility": "*"
12+
"squizlabs/php_codesniffer": "^3.13",
13+
"phpcompatibility/php-compatibility": "^9.3",
14+
"dealerdirect/phpcodesniffer-composer-installer": "^1.1"
1315
},
1416
"prefer-stable" : true,
1517
"config": {
1618
"platform": {
1719
"php": "8.3"
20+
},
21+
"allow-plugins": {
22+
"dealerdirect/phpcodesniffer-composer-installer": true
1823
}
1924
}
2025
}

composer.lock

Lines changed: 108 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/README.md

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,51 @@ a-blog cms のための「Google Translation API」連携拡張アプリにな
55

66
## 動作条件
77

8-
* php 7.2.5 以上
8+
* php: 8.1 – 8.4 (8.5+ not tested yet)
99
* a-blog cms for Professional or Enterprise のみ(現状スタンダードライセンスでの利用はライセンス違反となります)
10-
* a-blog cms Ver. 3.1.0 以上
10+
* a-blog cms: >= Ver. 3.2.11 (3.3+ not tested yet)
1111

1212
## ダウンロード
1313

1414
[Google Translate for a-blog cms](https://github.com/appleple/acms-google-translate/raw/master/build/GoogleTranslate.zip)
1515

1616
## 事前準備
1717

18-
### 「Google Translate API Key」の取得
18+
### サービスアカウントの設定と JSON 取得(Cloud Translation API)
1919

20-
[Google API Console](https://console.developers.google.com/) にログインし、以下の作業を行います。
20+
#### 1. プロジェクト作成
2121

22-
* ライブラリで **Cloud Translation API** の有効化
23-
* 認証情報で **APIキー** の作成
22+
- G[Google Cloud Console](https://console.developers.google.com/) にログイン
23+
- 新規プロジェクトを作成
24+
- プロジェクト ID(Project ID)をメモ
2425

25-
APIキーは必ず、**キーの制限** をかけるようにしてください。ただし、**HTTPリファラー** での制限はできませんので、IPアドレスによる制限をかけてください。
26+
#### 2. Cloud Translation API を有効化
27+
28+
- 作成したプロジェクトを選択
29+
- 「API とサービス」→「ライブラリ」
30+
- Cloud Translation API を検索して 有効化
31+
32+
```
33+
※ ここで課金が必要になる場合があります。GCP 側で 請求先アカウント(Billing) が未設定だと API 利用で弾かれることがあります(権限/有効化はできても実行時に失敗するケースがあるため、必要なら Billing も確認)。
34+
```
35+
36+
#### 3. サービスアカウント作成
37+
38+
- 「IAM と管理」→「サービスアカウント」
39+
- サービスアカウントを作成
40+
41+
#### 4. 権限(ロール)を付与
42+
43+
- 対象プロジェクトで、作成したサービスアカウントにロールを付与
44+
- ロール: **Cloud Translation API ユーザー** を付与
45+
46+
#### 5. JSON キー発行(秘密鍵)
47+
48+
- サービスアカウント詳細 →「鍵」タブ
49+
- 「鍵を追加」→「新しい鍵を作成」→ JSON
50+
- ダウンロードした JSON を サーバーに設置
51+
- Web 公開ディレクトリ外に配置(例: /var/app/credentials/translate-sa.json)
52+
- 権限は最小限(例: chmod 600、所有者を実行ユーザーに)
2653

2754
### a-blog cms の設計
2855

@@ -52,7 +79,8 @@ zipファイルをダウンロードし、解凍したディレクトリ(Googl
5279
|設定項目|説明|
5380
|:---|:---|
5481
|ベース言語|翻訳元となる言語を設定します|
55-
|Google Translate API Key|事前準備で用意した **APIキー** を設定します|
82+
|プロジェクトID|事前準備で用意した **プロジェクトID** を設定します|
83+
|サービスアカウントJSONパス|事前準備で用紙したJSONのパスを絶対パスで設定します|
5684
|カテゴリー作成|翻訳先の記事を作成するときに、カテゴリーも自動で複製するか設定します|
5785
|ベース言語(このブログ)と関連づける他言語ブログを設定|ベース言語のブログと翻訳先のブログの関連を設定します|
5886
|訳対象のフィールドを設定します|翻訳対象のカスタムフィールド名を指定します|

package-lock.json

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)