-
Notifications
You must be signed in to change notification settings - Fork 0
115 lines (104 loc) · 3.4 KB
/
l10n.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
on:
workflow_call:
secrets:
CROWDIN_PROJECT_ID:
required: true
CROWDIN_PERSONAL_TOKEN:
required: true
jobs:
template:
name: L10N Sync with Crowdin
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.ref }}
- name: Setup Docker BuildX
uses: docker/setup-buildx-action@v2
- name: Build WordPress image
uses: docker/build-push-action@v3
with:
context: .docker
file: .docker/wordpress.Dockerfile
cache-from: type=gha
cache-to: type=gha,mode=max
pull: true
load: true
tags: grueneschweiz/collectme:latest
- name: Generate translation template
run: >-
docker-compose
run
-u root:root
--no-deps
wordpress
bash
-c 'XDEBUG_MODE=off php -d memory_limit=1G $(which wp) --allow-root i18n make-pot wp-content/plugins/collectme/ wp-content/plugins/collectme/languages/collectme.pot --slug=collectme --domain=collectme --exclude=tmp,vendor --skip-js --skip-block-json --skip-theme-json'
- name: Setup git config
run: |
git config user.name "GitHub Actions L10N"
git config user.email "<>"
- name: If translation template has changes
run: >-
(
git diff -U0
| grep '^[+-]'
| grep -Ev '^(--- a/|\+\+\+ b/)'
| grep -v 'Project-Id-Version'
| grep -v 'POT-Creation-Date:'
| grep -v 'PO-Revision-Date:'
| grep -v '^:#'
&& echo "CHANGES=1" >> $GITHUB_ENV
)
|| true
- name: Commit changed translation template
run: |
git add languages/collectme.pot
git commit -m "[L10N] Update pot file"
git push
if: env.CHANGES
- name: Sync with crowdin
uses: crowdin/github-action@1.4.10
with:
upload_sources: true
download_translations: true
localization_branch_name: ${{ github.event.pull_request.head.ref }}
skip_untranslated_strings: true
export_only_approved: true
create_pull_request: false
push_translations: false
config: crowdin.yml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
- name: If translations have changed
run: >-
(
git diff -U0 languages/*.po
| grep '^[+-]'
| grep -Ev '^(--- a/|\+\+\+ b/)'
| grep -v 'Project-Id-Version'
| grep -v 'POT-Creation-Date:'
| grep -v 'PO-Revision-Date:'
| grep -v '^:#'
&& echo "CHANGES=1" >> $GITHUB_ENV
)
|| true
- name: Generate mo files
run: >-
docker-compose
run
-u root:root
--no-deps
wordpress
bash
-c 'XDEBUG_MODE=off $(which wp) --allow-root i18n make-mo wp-content/plugins/collectme/languages'
if: env.CHANGES
- name: Commit changed translations
run: |
git add languages/*.{po,mo}
git commit -m "[L10N] New translations from Crowdin"
git push
if: env.CHANGES