- Add to composer.json file of your project section repositories:
"repositories": [
{
"type": "vcs",
"url": "git@gitlab.com:r.alymov/translations-parser.git"
},
{
"type": "vcs",
"url": "git@github.com:R-Alymov/php-html-parser.git"
}
],
- Add this library with composer require icobox/translations-parser.
- Publish library config with php artisan vendor publish -- provider=Icobox\TranslationsParser\ServiceProvider
- Edit published config translations-parser.php for your application (look at Config section of this Readme).
- Generate OAuth2 tokens to use Google Api (look at Tokens section of this Readme) and edit path to json tokens in translations-parse.php.
- Add class translated to markup tags with text that must be translated.
- Use php artisan translations:initial-parse to parse markup.
- Use php artisan translation::export to export parsed markup to Google Sheets table.
- Use php artisan translation::import to import translations from Google Sheets table.
translations-parse.php:
- original_filename - path to file with original markup (with translatable classes in tags that must be translatted).
- parsed_filename - path to parsed file, that created with php artisan translations:initial-parse command.
- google_sheets_filename - no comments.
- spreadsheet_id - no comments.
- google_sheets_oauth_json - path to OAuth2 json google sheets token file.
- google_drive_oauth_json - path to OAuth2 json google drive token file.
- Use this link to create or select a project in the Google Developers Console and turn on the Google Sheets and Google Drive API.
- Then Go to credentials.
- At the top of the page, select the OAuth consent screen tab. Select an Email address, enter a Product name if not already set, and click the Save button.
- Select the Credentials tab, click the Create credentials button and select OAuth client ID.
- Select the application type Other, enter some name, and click the Create button.
- Click OK to dismiss the resulting dialog.
- Click the file_download (Download JSON) button to the right of the client ID.
- Move this file to your working directory and rename it to google_sheets_oauth_json or google_drive_oauth_json from config file.