Skip to content

Commit 1079168

Browse files
committed
chore: adds diff translations workflow
1 parent b127fe8 commit 1079168

File tree

4 files changed

+60
-7
lines changed

4 files changed

+60
-7
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Translations Diff
2+
3+
on:
4+
pull_request_review:
5+
pull_request:
6+
types: [opened, edited, synchronize, ready_for_review]
7+
branches:
8+
- development
9+
- master
10+
11+
jobs:
12+
translation:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout Base Branch
16+
uses: actions/checkout@v4
17+
with:
18+
ref: ${{ github.base_ref }}
19+
path: optimole-base
20+
- name: Setup node 16
21+
uses: actions/setup-node@v4
22+
with:
23+
node-version: 16.x
24+
- name: Build POT for Base Branch
25+
run: |
26+
cd optimole-base
27+
composer install --no-dev --prefer-dist --no-progress --no-suggest
28+
npm ci
29+
npm run build
30+
# TODO: when is merged to master, switch to npm run build:make-pot
31+
docker run --user root --rm --volume \"$(pwd):/var/www/html/optimole-wp\" wordpress:cli bash -c 'php -d memory_limit=512M \"$(which wp)\" --version --allow-root && wp i18n make-pot optimole-wp ./optimole-wp/languages/optimole-wp.pot --include=inc,assets/src --allow-root --domain=optimole-wp'
32+
ls languages/
33+
- name: Checkout PR Branch (Head)
34+
uses: actions/checkout@v4
35+
with:
36+
path: optimole-head
37+
- name: Build POT for PR Branch
38+
run: |
39+
cd optimole-head
40+
composer install --no-dev --prefer-dist --no-progress --no-suggest
41+
npm ci
42+
npm run build
43+
npm run build:make-pot
44+
ls languages/
45+
- name: Compare POT files
46+
uses: Codeinwp/action-i18n-string-reviewer@main
47+
with:
48+
fail-on-changes: 'true'
49+
openrouter-key: ${{ secrets.OPEN_ROUTER_API_KEY }}
50+
openrouter-model: 'google/gemini-2.5-flash'
51+
base-pot-file: 'optimole-base/languages/optimole-wp.pot'
52+
target-pot-file: 'optimole-head/languages/optimole-wp.pot'
53+
github-token: ${{ secrets.BOT_TOKEN }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ assets/build
1313
test-results
1414
tests/assets/filestash
1515
coverage
16+
languages

inc/cli/cli_setting.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,10 @@ public function connect( $args ) {
3232
if ( $data === false || is_wp_error( $data ) ) {
3333
$extra = '';
3434
if ( is_wp_error( $data ) ) {
35-
/**
36-
* Error from api.
37-
*
38-
* @var WP_Error $data Error object.
39-
*/
40-
$extra = sprintf( /* translators: errors details */ __( '. ERROR details: %s', 'optimole-wp' ), $data->get_error_message() );
35+
$extra = sprintf(
36+
/* translators: Error details */
37+
__( '. ERROR details: %s', 'optimole-wp' ),
38+
$data->get_error_message() );
4139
}
4240

4341
return \WP_CLI::error( __( 'Can not connect to Optimole service', 'optimole-wp' ) . $extra );

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@
4545
"release": "semantic-release --debug",
4646
"e2e:open": "playwright test --ui",
4747
"e2e:run": "playwright test",
48-
"dist": "./bin/dist.sh"
48+
"dist": "./bin/dist.sh",
49+
"build:make-pot": "docker run --user root --rm --volume \"$(pwd):/var/www/html/optimole-wp\" wordpress:cli bash -c 'php -d memory_limit=512M \"$(which wp)\" --version --allow-root && wp i18n make-pot optimole-wp ./optimole-wp/languages/optimole-wp.pot --include=inc,assets/src --allow-root --domain=optimole-wp'"
4950
},
5051
"devDependencies": {
5152
"@playwright/test": "^1.50.1",

0 commit comments

Comments
 (0)