Skip to content

Commit b3ef906

Browse files
authored
Merge pull request #1025 from equalizedigital/william/pro-142-pro-add-action-or-build-script-to-auto-generate-new-pot2
Add a workflow that can make an updated pot file for the plugin
2 parents 3b98d6a + 8134122 commit b3ef906

212 files changed

Lines changed: 9153 additions & 30 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/make-pot.yml

Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
name: Generate POT file
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- develop
7+
8+
jobs:
9+
make-pot:
10+
runs-on: ubuntu-latest
11+
services:
12+
mysql:
13+
image: mysql:5.7
14+
env:
15+
MYSQL_ROOT_PASSWORD: root
16+
MYSQL_DATABASE: wordpress
17+
ports:
18+
- 3306:3306
19+
options: >-
20+
--health-cmd="mysqladmin ping --silent" --health-interval=10s --health-timeout=5s --health-retries=3
21+
steps:
22+
- name: Checkout code
23+
uses: actions/checkout@v4
24+
25+
- name: Set up Node.js
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version: '20'
29+
30+
- name: Cache Node.js modules
31+
uses: actions/cache@v4
32+
with:
33+
path: ~/.npm
34+
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
35+
restore-keys: |
36+
${{ runner.os }}-node-
37+
38+
- name: Install dependencies
39+
run: npm install --ignore-scripts
40+
41+
- name: Build plugin (dotorg dist)
42+
run: npm run dist:dotorg
43+
44+
- name: Install PHP and required extensions
45+
run: |
46+
sudo apt-get update && sudo apt-get install -y php php-mysql php-xml php-curl
47+
echo "xdebug.max_nesting_level=1024" | sudo tee -a /etc/php/$(php -r 'echo PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')/cli/conf.d/20-xdebug.ini
48+
49+
- name: Download wp-cli
50+
run: |
51+
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
52+
chmod +x wp-cli.phar
53+
sudo mv wp-cli.phar /usr/local/bin/wp
54+
55+
- name: Download and configure WordPress
56+
run: |
57+
curl -O https://wordpress.org/latest.tar.gz
58+
tar -xzf latest.tar.gz
59+
cp -r dist/accessibility-checker wordpress/wp-content/plugins/accessibility-checker
60+
cp wordpress/wp-config-sample.php wordpress/wp-config.php
61+
sed -i \
62+
-e "s/database_name_here/wordpress/" \
63+
-e "s/username_here/root/" \
64+
-e "s/password_here/root/" \
65+
-e "s/'DB_HOST', 'localhost'/'DB_HOST', '127.0.0.1:3306'/" \
66+
wordpress/wp-config.php
67+
echo "define('FS_METHOD', 'direct');" >> wordpress/wp-config.php
68+
69+
- name: Wait for MySQL to be ready
70+
run: |
71+
for i in {1..30}; do
72+
if mysqladmin ping -h127.0.0.1 -uroot -proot --silent; then
73+
break
74+
fi
75+
sleep 2
76+
done
77+
78+
- name: Install WordPress
79+
run: |
80+
cd wordpress
81+
wp core install --url=localhost --title=Test --admin_user=admin --admin_password=admin --admin_email=admin@example.com --skip-email --allow-root
82+
83+
- name: Generate POT file
84+
run: |
85+
cd wordpress/wp-content/plugins/accessibility-checker
86+
wp i18n make-pot . ./languages/accessibility-checker.pot --allow-root
87+
88+
- name: Generate JSON files
89+
run: |
90+
cd wordpress/wp-content/plugins/accessibility-checker
91+
wp i18n make-json ./languages ./languages --no-purge --pretty-print --allow-root
92+
93+
- name: Check if POT file changed (ignoring some headers)
94+
id: pot_diff
95+
run: |
96+
if [ -f wordpress/wp-content/plugins/accessibility-checker/languages/accessibility-checker.pot ] && [ -f dist/accessibility-checker/languages/accessibility-checker.pot ]; then
97+
diff_output=$(diff \
98+
<(grep -vE '^("?(POT-Creation-Date|PO-Revision-Date|X-Generator|Project-Id-Version):|#|$)' wordpress/wp-content/plugins/accessibility-checker/languages/accessibility-checker.pot) \
99+
<(grep -vE '^("?(POT-Creation-Date|PO-Revision-Date|X-Generator|Project-Id-Version):|#|$)' dist/accessibility-checker/languages/accessibility-checker.pot) || true)
100+
if [ -n "$diff_output" ]; then
101+
echo "pot_changed=true" >> $GITHUB_OUTPUT
102+
else
103+
echo "pot_changed=false" >> $GITHUB_OUTPUT
104+
fi
105+
else
106+
echo "pot_changed=true" >> $GITHUB_OUTPUT
107+
fi
108+
109+
- name: Comment on PR if POT file changed
110+
if: steps.pot_diff.outputs.pot_changed == 'true'
111+
uses: actions/github-script@v7
112+
with:
113+
script: |
114+
github.rest.issues.createComment({
115+
issue_number: context.issue.number,
116+
owner: context.repo.owner,
117+
repo: context.repo.repo,
118+
body: 'The POT file has changed. Please update the POT file in your PR to keep translations up to date.\nThe updated POT file is available in the artifacts of this workflow run: https://github.com/' + context.repo.owner + '/' + context.repo.repo + '/actions/runs/' + process.env.GITHUB_RUN_ID
119+
})
120+
121+
- name: Upload POT and JSON files as artifact
122+
if: steps.pot_diff.outputs.pot_changed == 'true'
123+
uses: actions/upload-artifact@v4
124+
with:
125+
name: accessibility-checker-i18n
126+
path: |
127+
wordpress/wp-content/plugins/accessibility-checker/languages/accessibility-checker.pot
128+
wordpress/wp-content/plugins/accessibility-checker/languages/*.json
129+
130+
- name: Set up Git for PR
131+
if: steps.pot_diff.outputs.pot_changed == 'true'
132+
run: |
133+
git config --global user.name "github-actions[bot]"
134+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
135+
136+
- name: Replace root languages folder with built one
137+
if: steps.pot_diff.outputs.pot_changed == 'true'
138+
run: |
139+
rm -rf languages
140+
cp -r wordpress/wp-content/plugins/accessibility-checker/languages ./languages
141+
142+
- name: Create or Update Pull Request with updated translations
143+
if: steps.pot_diff.outputs.pot_changed == 'true'
144+
uses: peter-evans/create-pull-request@v6
145+
with:
146+
add-paths: ./languages
147+
commit-message: Update translation files (POT/JSON)
148+
title: Update translation files (POT/JSON)
149+
body: This PR updates the translation files (POT/JSON) generated by the workflow.
150+
branch: update-translations/${{ github.head_ref || github.ref_name }}
151+
base: ${{ github.head_ref || github.ref_name }}
152+
delete-branch: true
153+

admin/class-enqueue-admin.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ public static function maybe_enqueue_admin_and_editor_app_scripts() {
7676
global $post;
7777
$post_id = is_object( $post ) ? $post->ID : null;
7878
wp_enqueue_script( 'edac', plugin_dir_url( EDAC_PLUGIN_FILE ) . 'build/admin.bundle.js', [ 'jquery' ], EDAC_VERSION, false );
79+
wp_set_script_translations( 'edac', 'accessibility-checker', plugin_dir_path( EDAC_PLUGIN_FILE ) . 'languages' );
7980

8081
wp_localize_script(
8182
'edac',
@@ -105,6 +106,7 @@ public static function maybe_enqueue_admin_and_editor_app_scripts() {
105106
}
106107

107108
wp_enqueue_script( 'edac-editor-app', plugin_dir_url( EDAC_PLUGIN_FILE ) . 'build/editorApp.bundle.js', false, EDAC_VERSION, false );
109+
wp_set_script_translations( 'edac-editor-app', 'accessibility-checker', plugin_dir_path( EDAC_PLUGIN_FILE ) . 'languages' );
108110

109111
// If this is the frontpage or homepage, preview URLs won't work. Use the live URL.
110112
if ( (int) get_option( 'page_on_front' ) === $post_id || (int) get_option( 'page_for_posts' ) === $post_id ) {

admin/opt-in/class-email-opt-in.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public function enqueue_scripts() {
5555

5656
wp_enqueue_style( 'email-opt-in-form', plugin_dir_url( EDAC_PLUGIN_FILE ) . 'build/css/emailOptIn.css', false, EDAC_VERSION, 'all' );
5757
wp_enqueue_script( 'email-opt-in-form', plugin_dir_url( EDAC_PLUGIN_FILE ) . 'build/emailOptIn.bundle.js', false, EDAC_VERSION, true );
58+
wp_set_script_translations( 'email-opt-in-form', 'accessibility-checker', plugins_url( 'languages', EDAC_PLUGIN_FILE ) );
5859

5960
wp_localize_script(
6061
'email-opt-in-form',

includes/classes/Fixes/FixesManager.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ private function maybe_enqueue_frontend_scripts() {
107107
'wp_enqueue_scripts',
108108
function () {
109109
wp_enqueue_script( 'edac-frontend-fixes', EDAC_PLUGIN_URL . 'build/frontendFixes.bundle.js', [], EDAC_VERSION, true );
110+
wp_set_script_translations( 'edac-frontend-fixes', 'accessibility-checker', plugin_dir_path( EDAC_PLUGIN_FILE ) . 'languages' );
110111
wp_localize_script(
111112
'edac-frontend-fixes',
112113
'edac_frontend_fixes',

includes/classes/class-enqueue-frontend.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public static function maybe_enqueue_frontend_highlighter() {
110110
]
111111
);
112112

113-
wp_set_script_translations( 'edac-frontend-highlighter-app', 'accessibility-checker' );
113+
wp_set_script_translations( 'edac-frontend-highlighter-app', 'accessibility-checker', plugin_dir_path( EDAC_PLUGIN_FILE ) . 'languages' );
114114

115115
}
116116
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"translation-revision-date": "YEAR-MO-DA HO:MI+ZONE",
3+
"generator": "WP-CLI\/2.12.0",
4+
"source": "build\/admin.bundle.js",
5+
"domain": "messages",
6+
"locale_data": {
7+
"messages": {
8+
"": {
9+
"domain": "messages",
10+
"lang": "en",
11+
"plural-forms": "nplurals=2; plural=(n != 1);"
12+
},
13+
"Get Pro to unlock this feature, opens in a new window.": [
14+
"\u0627\u062d\u0635\u0644 \u0639\u0644\u0649 \u0627\u0644\u0646\u0633\u062e\u0629 \u0627\u0644\u0627\u062d\u062a\u0631\u0627\u0641\u064a\u0629 \u0644\u0641\u062a\u062d \u0647\u0630\u0647 \u0627\u0644\u0645\u064a\u0632\u0629\u060c \u064a\u0641\u062a\u062d \u0641\u064a \u0646\u0627\u0641\u0630\u0629 \u062c\u062f\u064a\u062f\u0629."
15+
],
16+
"Saving...": [
17+
"\u062c\u0627\u0631\u064d \u0627\u0644\u062d\u0641\u0638..."
18+
],
19+
"Settings saved successfully. You must %svisit the editor%s and save the post to rescan and remove fixed issues from Accessibility Checker reports.": [
20+
"\u062a\u0645 \u062d\u0641\u0638 \u0627\u0644\u0625\u0639\u062f\u0627\u062f\u0627\u062a \u0628\u0646\u062c\u0627\u062d. \u064a\u062c\u0628 \u0639\u0644\u064a\u0643 %s\u0632\u064a\u0627\u0631\u0629 \u0627\u0644\u0645\u062d\u0631\u0631%s \u0648\u062d\u0641\u0638 \u0627\u0644\u0645\u0646\u0634\u0648\u0631 \u0644\u0625\u0639\u0627\u062f\u0629 \u0627\u0644\u0641\u062d\u0635 \u0648\u0625\u0632\u0627\u0644\u0629 \u0627\u0644\u0645\u0634\u0643\u0644\u0627\u062a \u0627\u0644\u0645\u0635\u062d\u062d\u0629 \u0645\u0646 \u062a\u0642\u0627\u0631\u064a\u0631 \u0645\u062f\u0642\u0642 \u0627\u0644\u0648\u0635\u0648\u0644."
21+
],
22+
"Settings saved successfully.": [
23+
"\u062a\u0645 \u062d\u0641\u0638 \u0627\u0644\u0625\u0639\u062f\u0627\u062f\u0627\u062a \u0628\u0646\u062c\u0627\u062d."
24+
],
25+
"Saving failed.": [
26+
"\u0641\u0634\u0644 \u0627\u0644\u062d\u0641\u0638."
27+
],
28+
"Fix Settings": [
29+
"\u0625\u0639\u062f\u0627\u062f\u0627\u062a \u0627\u0644\u0625\u0635\u0644\u0627\u062d"
30+
]
31+
}
32+
}
33+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"translation-revision-date": "YEAR-MO-DA HO:MI+ZONE",
3+
"generator": "WP-CLI\/2.12.0",
4+
"source": "build\/emailOptIn.bundle.js",
5+
"domain": "messages",
6+
"locale_data": {
7+
"messages": {
8+
"": {
9+
"domain": "messages",
10+
"lang": "en",
11+
"plural-forms": "nplurals=2; plural=(n != 1);"
12+
},
13+
"There was a problem. Please try again.": [
14+
"\u062d\u062f\u062b\u062a \u0645\u0634\u0643\u0644\u0629. \u064a\u0631\u062c\u0649 \u0627\u0644\u0645\u062d\u0627\u0648\u0644\u0629 \u0645\u0631\u0629 \u0623\u062e\u0631\u0649."
15+
],
16+
"Sorry, your submission failed. Please shorten your responses and try again.": [
17+
"\u0639\u0630\u0631\u064b\u0627\u060c \u0641\u0634\u0644 \u0625\u0631\u0633\u0627\u0644\u0643. \u064a\u0631\u062c\u0649 \u062a\u0642\u0635\u064a\u0631 \u0625\u062c\u0627\u0628\u0627\u062a\u0643 \u0648\u0627\u0644\u0645\u062d\u0627\u0648\u0644\u0629 \u0645\u0631\u0629 \u0623\u062e\u0631\u0649."
18+
],
19+
"Sorry, your submission failed. Please try again.": [
20+
"\u0639\u0630\u0631\u064b\u0627\u060c \u0641\u0634\u0644 \u0625\u0631\u0633\u0627\u0644 \u0637\u0644\u0628\u0643. \u064a\u0631\u062c\u0649 \u0627\u0644\u0645\u062d\u0627\u0648\u0644\u0629 \u0645\u0631\u0629 \u0623\u062e\u0631\u0649."
21+
]
22+
}
23+
}
24+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"translation-revision-date": "YEAR-MO-DA HO:MI+ZONE",
3+
"generator": "WP-CLI\/2.12.0",
4+
"source": "build\/frontendFixes.bundle.js",
5+
"domain": "messages",
6+
"locale_data": {
7+
"messages": {
8+
"": {
9+
"domain": "messages",
10+
"lang": "en",
11+
"plural-forms": "nplurals=2; plural=(n != 1);"
12+
},
13+
"opens a new window": [
14+
"\u064a\u0641\u062a\u062d \u0646\u0627\u0641\u0630\u0629 \u062c\u062f\u064a\u062f\u0629"
15+
],
16+
"EDAC: Did not find a matching target ID on the page for the skip link.": [
17+
"EDAC: \u0644\u0645 \u064a\u062a\u0645 \u0627\u0644\u0639\u062b\u0648\u0631 \u0639\u0644\u0649 \u0645\u0639\u0631\u0641 \u0647\u062f\u0641 \u0645\u0637\u0627\u0628\u0642 \u0641\u064a \u0627\u0644\u0635\u0641\u062d\u0629 \u0644\u0631\u0627\u0628\u0637 \u0627\u0644\u062a\u062e\u0637\u064a."
18+
],
19+
"EDAC: Error updating history for skip link.": [
20+
"EDAC: \u062e\u0637\u0623 \u0641\u064a \u062a\u062d\u062f\u064a\u062b \u0627\u0644\u0633\u062c\u0644 \u0644\u0631\u0627\u0628\u0637 \u0627\u0644\u062a\u062e\u0637\u064a."
21+
]
22+
}
23+
}
24+
}
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
{
2+
"translation-revision-date": "YEAR-MO-DA HO:MI+ZONE",
3+
"generator": "WP-CLI\/2.12.0",
4+
"source": "build\/frontendHighlighterApp.bundle.js",
5+
"domain": "messages",
6+
"locale_data": {
7+
"messages": {
8+
"": {
9+
"domain": "messages",
10+
"lang": "en",
11+
"plural-forms": "nplurals=2; plural=(n != 1);"
12+
},
13+
"Save": [
14+
"\u062d\u0641\u0638"
15+
],
16+
"Saving...": [
17+
"\u062c\u0627\u0631\u064d \u0627\u0644\u062d\u0641\u0638..."
18+
],
19+
"Settings saved successfully. You must %svisit the editor%s and save the post to rescan and remove fixed issues from Accessibility Checker reports.": [
20+
"\u062a\u0645 \u062d\u0641\u0638 \u0627\u0644\u0625\u0639\u062f\u0627\u062f\u0627\u062a \u0628\u0646\u062c\u0627\u062d. \u064a\u062c\u0628 \u0639\u0644\u064a\u0643 %s\u0632\u064a\u0627\u0631\u0629 \u0627\u0644\u0645\u062d\u0631\u0631%s \u0648\u062d\u0641\u0638 \u0627\u0644\u0645\u0646\u0634\u0648\u0631 \u0644\u0625\u0639\u0627\u062f\u0629 \u0627\u0644\u0641\u062d\u0635 \u0648\u0625\u0632\u0627\u0644\u0629 \u0627\u0644\u0645\u0634\u0643\u0644\u0627\u062a \u0627\u0644\u0645\u0635\u062d\u062d\u0629 \u0645\u0646 \u062a\u0642\u0627\u0631\u064a\u0631 \u0645\u062f\u0642\u0642 \u0627\u0644\u0648\u0635\u0648\u0644."
21+
],
22+
"Settings saved successfully.": [
23+
"\u062a\u0645 \u062d\u0641\u0638 \u0627\u0644\u0625\u0639\u062f\u0627\u062f\u0627\u062a \u0628\u0646\u062c\u0627\u062d."
24+
],
25+
"Saving failed.": [
26+
"\u0641\u0634\u0644 \u0627\u0644\u062d\u0641\u0638."
27+
],
28+
"Fix Settings": [
29+
"\u0625\u0639\u062f\u0627\u062f\u0627\u062a \u0627\u0644\u0625\u0635\u0644\u0627\u062d"
30+
],
31+
"Close fixes modal": [
32+
"\u0625\u063a\u0644\u0627\u0642 \u0646\u0627\u0641\u0630\u0629 \u0627\u0644\u0625\u0635\u0644\u0627\u062d\u0627\u062a"
33+
],
34+
"Disable Page Styles": [
35+
"\u062a\u0639\u0637\u064a\u0644 \u0623\u0646\u0645\u0627\u0637 \u0627\u0644\u0635\u0641\u062d\u0629"
36+
],
37+
"Show Code": [
38+
"\u0639\u0631\u0636 \u0627\u0644\u0643\u0648\u062f"
39+
],
40+
"Issue type:": [
41+
"\u0646\u0648\u0639 \u0627\u0644\u0645\u0634\u0643\u0644\u0629:"
42+
],
43+
"Enable Styles": [
44+
"\u062a\u0641\u0639\u064a\u0644 \u0627\u0644\u0623\u0646\u0645\u0627\u0637"
45+
],
46+
"Disable Styles": [
47+
"\u062a\u0639\u0637\u064a\u0644 \u0627\u0644\u0623\u0646\u0645\u0627\u0637"
48+
],
49+
"There are no settings to display.": [
50+
"\u0644\u0627 \u062a\u0648\u062c\u062f \u0625\u0639\u062f\u0627\u062f\u0627\u062a \u0644\u0639\u0631\u0636\u0647\u0627."
51+
],
52+
"These settings enable global fixes across your entire site. Pages may need to be resaved or a full site scan run to see fixes reflected in reports.": [
53+
"\u062a\u0645\u0643\u0651\u0646 \u0647\u0630\u0647 \u0627\u0644\u0625\u0639\u062f\u0627\u062f\u0627\u062a \u0627\u0644\u0625\u0635\u0644\u0627\u062d\u0627\u062a \u0627\u0644\u0639\u0627\u0645\u0629 \u0639\u0628\u0631 \u0645\u0648\u0642\u0639\u0643 \u0628\u0623\u0643\u0645\u0644\u0647. \u0642\u062f \u062a\u062d\u062a\u0627\u062c \u0627\u0644\u0635\u0641\u062d\u0627\u062a \u0625\u0644\u0649 \u0625\u0639\u0627\u062f\u0629 \u062d\u0641\u0638 \u0623\u0648 \u0625\u062c\u0631\u0627\u0621 \u0641\u062d\u0635 \u0643\u0627\u0645\u0644 \u0644\u0644\u0645\u0648\u0642\u0639 \u0644\u0631\u0624\u064a\u0629 \u0627\u0644\u0625\u0635\u0644\u0627\u062d\u0627\u062a \u0627\u0644\u0645\u0646\u0639\u0643\u0633\u0629 \u0641\u064a \u0627\u0644\u062a\u0642\u0627\u0631\u064a\u0631."
54+
],
55+
"No issues detected.": [
56+
"\u0644\u0645 \u064a\u062a\u0645 \u0627\u0643\u062a\u0634\u0627\u0641 \u0623\u064a \u0645\u0634\u0627\u0643\u0644."
57+
],
58+
"error": [
59+
"\u062e\u0637\u0623",
60+
"\u0623\u062e\u0637\u0627\u0621"
61+
],
62+
"warning": [
63+
"\u062a\u062d\u0630\u064a\u0631",
64+
"\u062a\u062d\u0630\u064a\u0631\u0627\u062a"
65+
],
66+
"and": [
67+
"\u0648"
68+
],
69+
"ignored issue": [
70+
"\u0645\u0634\u0643\u0644\u0629 \u062a\u0645 \u062a\u062c\u0627\u0647\u0644\u0647\u0627",
71+
"\u0645\u0634\u0627\u0643\u0644 \u062a\u0645 \u062a\u062c\u0627\u0647\u0644\u0647\u0627"
72+
],
73+
"detected.": [
74+
"\u062a\u0645 \u0627\u0643\u062a\u0634\u0627\u0641\u0647\u0627."
75+
]
76+
}
77+
}
78+
}

0 commit comments

Comments
 (0)