|
13 | 13 | PRETIX_URL: '{{.TASK_PRETIX_URL | default "http://pretix.hoeringsportal.local.itkdev.dk"}}' |
14 | 14 | PRETIX_ORGANIZER: '{{.TASK_PRETIX_ORGANIZER | default "dpl-cms"}}' |
15 | 15 |
|
| 16 | + CUSTOM_MODULES: |
| 17 | + sh: ls web/modules/custom/*/*.info.yml | xargs basename -s '.info.yml' |
| 18 | + |
| 19 | + CUSTOM_THEMES: |
| 20 | + sh: ls web/themes/custom/*/*.info.yml | xargs basename -s '.info.yml' |
| 21 | + |
16 | 22 | tasks: |
17 | 23 | default: |
18 | 24 | cmds: |
@@ -52,12 +58,13 @@ tasks: |
52 | 58 |
|
53 | 59 | site-open: |
54 | 60 | cmds: |
55 | | - - if command -v open 2>&1 >/dev/null; then open "$(task site-url)"; else echo "$(task site-url)"; fi |
| 61 | + # `open` is defined in GitHub Actions (ubuntu-latest), but cannot actually be run without error. Therefore we add `|| true` to prevent errors. |
| 62 | + - if command -v open 2>&1 >/dev/null; then open "$(task site-url)" || true; else echo "$(task site-url)"; fi |
56 | 63 | silent: true |
57 | 64 |
|
58 | 65 | site-open-admin: |
59 | 66 | cmds: |
60 | | - - if command -v open 2>&1 >/dev/null; then open "{{.URL}}"; else echo "{{.URL}}"; fi |
| 67 | + - if command -v open 2>&1 >/dev/null; then open "{{.URL}}" || true; else echo "{{.URL}}"; fi |
61 | 68 | vars: |
62 | 69 | URL: |
63 | 70 | sh: task drush -- user:login --no-browser |
@@ -258,3 +265,79 @@ tasks: |
258 | 265 | # https://www.drupal.org/project/drupal/issues/3496223 |
259 | 266 | - 'task compose -- exec phpfpm sed -i "s/Plural-Forms: nplurals=2; plural=(n > 1);/Plural-Forms: nplurals=2; plural=(n != 1);/" translations/custom-translations.da.po' |
260 | 267 | silent: true |
| 268 | + |
| 269 | + translations:extract:modules: |
| 270 | + cmds: |
| 271 | + # https://github.com/go-task/task/discussions/1543 |
| 272 | + - for: |
| 273 | + matrix: |
| 274 | + MODULE: |
| 275 | + ref: .CUSTOM_MODULES |
| 276 | + LANGUAGE: |
| 277 | + - da |
| 278 | + cmd: | |
| 279 | + task drush -- potx single --folder=modules/custom/{{.ITEM.MODULE}}/ --language {{.ITEM.LANGUAGE}} --translations && \ |
| 280 | + mkdir -p web/modules/custom/{{.ITEM.MODULE}}/translations && \ |
| 281 | + mv web/general.pot web/modules/custom/{{.ITEM.MODULE}}/translations/{{.ITEM.MODULE}}.{{.ITEM.LANGUAGE}}.po |
| 282 | + internal: true |
| 283 | + |
| 284 | + translations:extract:themes: |
| 285 | + cmds: |
| 286 | + # https://github.com/go-task/task/discussions/1543 |
| 287 | + - for: |
| 288 | + matrix: |
| 289 | + THEME: |
| 290 | + ref: .CUSTOM_THEMES |
| 291 | + LANGUAGE: |
| 292 | + - da |
| 293 | + # `drush potx` always writes to web/general.pot, so we move this file |
| 294 | + # into the desired destination in the `translations` folder inside the |
| 295 | + # module folder. |
| 296 | + cmd: | |
| 297 | + task drush -- potx single --folder=themes/custom/{{.ITEM.THEME}}/ --language {{.ITEM.LANGUAGE}} --translations && \ |
| 298 | + mkdir -p web/themes/custom/{{.ITEM.THEME}}/translations && \ |
| 299 | + mv web/general.pot web/themes/custom/{{.ITEM.THEME}}/translations/{{.ITEM.THEME}}.{{.ITEM.LANGUAGE}}.po |
| 300 | + internal: true |
| 301 | + |
| 302 | + translations:diff: |
| 303 | + cmds: |
| 304 | + # Ignore some PO metadata when git diff'ing, e.g. |
| 305 | + # |
| 306 | + # "POT-Creation-Date: 2025-03-12 18:18+0100\n" |
| 307 | + # "PO-Revision-Date: 2025-03-12 18:18+0100\n" |
| 308 | + - git diff --exit-code --ignore-blank-lines --ignore-matching-lines='^"PO.*-Date' web/*/custom/*/translations |
| 309 | + |
| 310 | + translations:extract: |
| 311 | + cmds: |
| 312 | + - task drush -- --yes pm:install potx |
| 313 | + - task: translations:extract:modules |
| 314 | + - task: translations:extract:themes |
| 315 | + - task drush -- --yes pm:uninstall potx |
| 316 | + silent: true |
| 317 | + |
| 318 | + # @todo Can we use `drush locale:check` and/or `drush locale:update` to update |
| 319 | + # module translations without overriding existing translations? |
| 320 | + # @todo Do we want to override (existing) translations? |
| 321 | + translations:import:modules: |
| 322 | + cmds: |
| 323 | + - for: |
| 324 | + matrix: |
| 325 | + MODULE: |
| 326 | + ref: .CUSTOM_MODULES |
| 327 | + cmd: task drush -- locale:import-all --override=none modules/custom/{{.ITEM.MODULE}}/translations/ |
| 328 | + silent: true |
| 329 | + |
| 330 | + translations:import:themes: |
| 331 | + cmds: |
| 332 | + - for: |
| 333 | + matrix: |
| 334 | + THEME: |
| 335 | + ref: .CUSTOM_THEMES |
| 336 | + cmd: task drush -- locale:import-all --override=none themes/custom/{{.ITEM.THEME}}/translations/ |
| 337 | + silent: true |
| 338 | + |
| 339 | + translations:import:all: |
| 340 | + cmds: |
| 341 | + - task: translations:import:modules |
| 342 | + - task: translations:import:themes |
| 343 | + silent: true |
0 commit comments