wowworks / translation-google-sheet
用于向Google Sheets推送/拉取翻译的工具
1.0
2021-02-19 06:29 UTC
Requires
- php: >=7.1
- google/apiclient: ^2.0
- yiisoft/yii2: 2.*
This package is not auto-updated.
Last update: 2024-09-15 02:06:28 UTC
README
与Google Sheets API的集成。
安装
此扩展可在packagist.org上找到,可以通过以下命令使用composer安装:
composer require wowworks/translation-google-sheet`
配置
$client = new Google_Client(); $client->setApplicationName('Google Sheets API Wowworks'); $client->setScopes(Google_Service_Sheets::SPREADSHEETS); $client->setAccessType('offline'); $client->setPrompt('select_account consent'); $pathToCredentialFile = 'pathToCredentialFile'; putenv("GOOGLE_APPLICATION_CREDENTIALS={$pathToCredentialFile}"); $client->useApplicationDefaultCredentials(); $serviceGoogleSheets = new Google_Service_Sheets($client); $configurationService = new TranslationGoogleSheetConfigurationService( ['en_EN', 'ru_RU', 'de_DE'], ['ru_RU'] ); $service = new TranslationGoogleSheetService( ['spreadSheetUrl1', 'spreadSheetUrl2'], $serviceGoogleSheets, $configurationService, new TranslationStringConverter() );
用法
$allPathsToTranslations = $configurationService->getAllPathsToTranslations(Yii::$app->i18n->translations); $service->pull($allPathsToTranslations); $service->push($allPathsToTranslations);