-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from creative-commoners/pulls/1/translator
NEW Create Translator
- Loading branch information
Showing
9 changed files
with
892 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: CI | ||
|
||
on: | ||
push: | ||
pull_request: | ||
workflow_dispatch: | ||
# Every Tuesday at 2:00pm UTC | ||
schedule: | ||
- cron: '0 14 * * 2' | ||
|
||
jobs: | ||
ci: | ||
name: CI | ||
# Only run cron on the silverstripe account | ||
if: (github.event_name == 'schedule' && github.repository_owner == 'silverstripe') || (github.event_name != 'schedule') | ||
uses: silverstripe/gha-ci/.github/workflows/ci.yml@v1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
name: Keepalive | ||
|
||
on: | ||
workflow_dispatch: | ||
# The 4th of every month at 10:50am UTC | ||
schedule: | ||
- cron: '50 10 4 * *' | ||
|
||
jobs: | ||
keepalive: | ||
name: Keepalive | ||
# Only run cron on the silverstripe account | ||
if: (github.event_name == 'schedule' && github.repository_owner == 'silverstripe') || (github.event_name != 'schedule') | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Keepalive | ||
uses: silverstripe/gha-keepalive@v1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,47 @@ | ||
# silverstripe-tx-translator | ||
# silverstripe tx translator | ||
|
||
Module to assist with transifex integration. Works with Silverstripe 4.12+ and 5.0+. | ||
|
||
## Operations | ||
|
||
- Pull latest translations from transifex and merge them into yml/json/js translation files | ||
- Run i18nTextCollectorTask on a local website | ||
- Push updated source strings to transifex (optional) | ||
- Create github pull-requests with file changes | ||
|
||
## Requirements | ||
|
||
Transifex cli client (tx) - [https://developers.transifex.com/docs/cli](https://developers.transifex.com/docs/cli) configured API key from transifex. | ||
|
||
You must use the go version at least version 1.6+ and not the old python version. | ||
|
||
Create a new classic github api token in [github token settings](https://github.com/settings/tokens) with all checkboxes unticked except for `public_repo`. This is required to create pull-requests. | ||
|
||
Delete this token from github once you have completed updating translations. | ||
|
||
## Usage | ||
|
||
``` | ||
cd /path/to/my-local-site | ||
composer require silverstripe/tx-translator | ||
TX_GITHUB_API_TOKEN=mytoken TX_SITE=my-local-site.test TX_PUSH=1 php vendor/silverstripe/tx-translator/scripts/translate.php | ||
``` | ||
|
||
**To omit the push to transifex** | ||
|
||
``` | ||
TX_GITHUB_API_TOKEN=mytoken TX_SITE=my-local-site.test php vendor/silverstripe/tx-translator/scripts/translate.php | ||
``` | ||
|
||
## Environment variables | ||
|
||
Environment variables can either be set via the command line, like in the examples above, or in an .env in the root folder of the site, or using any other methods to set environment variables. | ||
|
||
Note that the valid values for the boolean variables are 1, true, on, 0, false and off. | ||
|
||
- `TX_GITHUB_API_TOKEN` (required) - the github token with write access to create pull-requests | ||
- `TX_SITE` (required) - the url of a local silverstripe site to run i18nTextCollectorTask against. `http://` will be automatically added if protocol is omitted | ||
- `TX_PULL` (default `1`) - pull latest translations from transifex, run i18nTextCollectorTask and update translation files | ||
- `TX_PUSH` (default `0`) - push new source strings to transifex | ||
- `TX_DEV_MODE` (default `0`) - do not push to transifex or create github pull-requests. Useful for local development and for doing dry-runs | ||
- `TX_VERBOSE_LOGGING` (default `0`) - show verbose logging |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{ | ||
"name": "silverstripe/tx-translator", | ||
"description": "Silverstripe TX Translator", | ||
"authors": [ | ||
{ | ||
"name": "SilverStripe", | ||
"homepage": "http://silverstripe.com" | ||
}, | ||
{ | ||
"name": "The SilverStripe Community", | ||
"homepage": "http://silverstripe.org" | ||
} | ||
], | ||
"require": { | ||
"php": "^7.4 || ^8.1", | ||
"symfony/console": "^4 || ^5 || ^6", | ||
"symfony/process": "^4 || ^5 || ^6", | ||
"symfony/yaml": "^4 || ^5 || ^6", | ||
"symfony/dotenv": "^5 || ^6", | ||
"guzzlehttp/guzzle": "^6 || ^7" | ||
}, | ||
"conflict": { | ||
"silverstripe/framework": "<4.12.0" | ||
}, | ||
"require-dev": { | ||
"phpunit/phpunit": "^9.5", | ||
"squizlabs/php_codesniffer": "^3.7" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"SilverStripe\\TxTranslator\\": "src/", | ||
"SilverStripe\\TxTranslator\\Tests\\": "tests/" | ||
} | ||
}, | ||
"scripts": { | ||
"lint": "phpcs src/ tests/php/", | ||
"lint-clean": "phpcbf src/ tests/php/" | ||
}, | ||
"minimum-stability": "dev", | ||
"prefer-stable": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ruleset name="SilverStripe"> | ||
<description>CodeSniffer ruleset for SilverStripe coding conventions.</description> | ||
|
||
<file>src</file> | ||
|
||
<rule ref="PSR12" /> | ||
</ruleset> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit bootstrap="vendor/silverstripe/framework/tests/bootstrap.php" colors="true"> | ||
<testsuites> | ||
<testsuite name="Default"> | ||
<directory>tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
|
||
<filter> | ||
<whitelist addUncoveredFilesFromWhitelist="true"> | ||
<directory suffix=".php">src/</directory> | ||
<exclude> | ||
<directory suffix=".php">tests/</directory> | ||
</exclude> | ||
</whitelist> | ||
</filter> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
use SilverStripe\TxTranslator\Translator; | ||
use Symfony\Component\Dotenv\Dotenv; | ||
|
||
$vendorDir = dirname(dirname(dirname(__DIR__))); | ||
require "$vendorDir/autoload.php"; | ||
|
||
|
||
$baseDir = dirname($vendorDir); | ||
if (file_exists("$baseDir/.env")) { | ||
$dotenv = new Dotenv(); | ||
$dotenv->usePutenv(true)->load("$baseDir/.env"); | ||
} | ||
|
||
$translator = new Translator(); | ||
$translator->run(); |
Oops, something went wrong.