@@ -3,6 +3,9 @@ version: '3'
33# https://taskfile.dev/usage/#env-files
44dotenv : ['.env.local', '.env']
55
6+ includes :
7+ translation : ./task/Taskfile.translation.yml
8+
69vars :
710 # https://taskfile.dev/reference/templating/
811 BASE_URL : ' {{.TASK_BASE_URL | default .COMPOSE_SERVER_DOMAIN | default .COMPOSE_DOMAIN | default "https://hoeringsportal.local.itkdev.dk"}}'
@@ -47,12 +50,12 @@ vars:
4750
4851 # - hoeringsportal_admin
4952
50- # During testing and development, you can override TRANSLATION_MODULES and TRANSLATION_THEMES to not process all modules and themes, e.g.
51- #
52- # TRANSLATION_MODULES:
53- # - hoeringsportal_citizen_proposal
54- #
55- # TRANSLATION_THEMES: []
53+ # # During testing and development, you can override TRANSLATION_MODULES and TRANSLATION_THEMES to not process all modules and themes, e.g.
54+ # #
55+ TRANSLATION_MODULES :
56+ - hoeringsportal_citizen_proposal
57+
58+ TRANSLATION_THEMES : []
5659
5760tasks :
5861 default :
@@ -286,124 +289,17 @@ tasks:
286289
287290 translations:import :
288291 cmds :
289- - task drush -- locale:import --type=not- customized --override=not-customized da ../translations/custom-translations.da.po
290- # - task drush -- php:eval "var_export(\Drupal::state()->get('locale.translation.formulae', []))"
291- # - 'task drush -- php:eval "var_export(array_map(static fn (\$count) => (new \Drupal\Core\StringTranslation\PluralTranslatableMarkup(\$count, ''1 item'', ''@count items'', options: [''langcode'' => ''da'']))->render(), range(0, 5)));"'
292- # - 'task drush -- php:eval "var_export(array_map(static fn (\$count) => (new \Drupal\Core\StringTranslation\PluralTranslatableMarkup(\$count, ''1 item'', ''@count items'', options: [''langcode'' => ''en'']))->render(), range(0, 5)));"'
292+ - task compose -- exec phpfpm bash -c '(cd web && ../vendor/bin/drush locale:import --type=customized --override=all da ../translations/custom-translations.da.po)'
293+ - task drush -- php:eval "var_export(\Drupal::state()->get('locale.translation.formulae', []))"
294+ - ' task drush -- php:eval "var_export(array_map(static fn (\$count) => (new \Drupal\Core\StringTranslation\PluralTranslatableMarkup(\$count, '' 1 item'' , '' @count items'' , options: ['' langcode'' => '' da'' ]))->render(), range(0, 5)));"'
295+ - ' task drush -- php:eval "var_export(array_map(static fn (\$count) => (new \Drupal\Core\StringTranslation\PluralTranslatableMarkup(\$count, '' 1 item'' , '' @count items'' , options: ['' langcode'' => '' en'' ]))->render(), range(0, 5)));"'
293296 silent : true
294297
295298 translations:export :
296299 cmds :
297- # @todo Which types should we use here?
298- - task drush -- locale:export da --types=customized > translations/custom-translations.da.po
300+ - task compose -- exec phpfpm bash -c '(cd web && ../vendor/bin/drush locale:export da --types=customized > ../translations/custom-translations.da.po)'
299301 # Fix plurals spec in PO file
300302 # https://drupalsun.com/eelke/2020/08/17/tale-mistranslated-plurals
301303 # https://www.drupal.org/project/drupal/issues/3496223
302304 - ' 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'
303305 silent : true
304-
305- translations:diff :
306- cmds :
307- # Ignore some PO metadata when git diff'ing, e.g.
308- #
309- # "POT-Creation-Date: 2025-03-12 18:18+0100\n"
310- # "PO-Revision-Date: 2025-03-12 18:18+0100\n"
311- - git diff --exit-code --ignore-blank-lines --ignore-matching-lines='^"PO.*-Date' web/*/custom/*/translations/*.po translations/*.po
312-
313- translations:checkout :
314- cmds :
315- - git checkout web/*/custom/*/translations/*.po translations/*.po
316- # https://taskfile.dev/reference/schema#precondition
317- preconditions :
318- - sh : task translations:diff
319- msg : |
320- Translations seem to have changed.
321-
322- Run
323-
324- task translations:diff
325-
326- to check.
327-
328- translations:extract :
329- cmds :
330- - task drush -- --yes pm:install potx
331- - task : translations:extract:modules
332- - task : translations:extract:themes
333- - task drush -- --yes pm:uninstall potx
334- silent : true
335-
336- translations:extract:modules :
337- cmds :
338- # https://github.com/go-task/task/discussions/1543
339- - for :
340- matrix :
341- MODULE :
342- ref : .TRANSLATION_MODULES
343- LANGUAGE :
344- - da
345- cmd : |
346- task drush -- potx single --folder=modules/custom/{{.ITEM.MODULE}}/ --language {{.ITEM.LANGUAGE}} --translations && \
347- mkdir -p web/modules/custom/{{.ITEM.MODULE}}/translations && \
348- mv web/general.pot web/modules/custom/{{.ITEM.MODULE}}/translations/{{.ITEM.MODULE}}.{{.ITEM.LANGUAGE}}.po
349- internal : true
350-
351- translations:extract:themes :
352- cmds :
353- # https://github.com/go-task/task/discussions/1543
354- - for :
355- matrix :
356- THEME :
357- ref : .TRANSLATION_THEMES
358- LANGUAGE :
359- - da
360- # `drush potx` always writes to web/general.pot, so we move this file
361- # into the desired destination in the `translations` folder inside the
362- # module folder.
363- cmd : |
364- task drush -- potx single --folder=themes/custom/{{.ITEM.THEME}}/ --language {{.ITEM.LANGUAGE}} --translations && \
365- mkdir -p web/themes/custom/{{.ITEM.THEME}}/translations && \
366- mv web/general.pot web/themes/custom/{{.ITEM.THEME}}/translations/{{.ITEM.THEME}}.{{.ITEM.LANGUAGE}}.po
367- internal : true
368-
369- # @todo Can we use `drush locale:check` and/or `drush locale:update` to update
370- # module translations without overriding existing translations?
371- # @todo Do we want to override (existing) translations?
372- translations:import:modules :
373- cmds :
374- - for :
375- matrix :
376- MODULE :
377- ref : .TRANSLATION_MODULES
378- cmd : task drush -- locale:import-all --override=none modules/custom/{{.ITEM.MODULE}}/translations/
379- internal : true
380-
381- translations:import:themes :
382- cmds :
383- - for :
384- matrix :
385- THEME :
386- ref : .TRANSLATION_THEMES
387- cmd : task drush -- locale:import-all --override=none themes/custom/{{.ITEM.THEME}}/translations/
388- internal : true
389-
390- translations:import:all :
391- cmds :
392- - task : translations:import:modules
393- - task : translations:import:themes
394- silent : true
395-
396- config-translations:export :
397- cmds :
398- - task drush -- config_translation_po:export da > translations/config-translations.da.po
399- # Fix plurals spec in PO file
400- # https://drupalsun.com/eelke/2020/08/17/tale-mistranslated-plurals
401- # https://www.drupal.org/project/drupal/issues/3496223
402- - ' task compose -- exec phpfpm sed -i "s/Plural-Forms: nplurals=2; plural=(n > 1);/Plural-Forms: nplurals=2; plural=(n != 1);/" translations/config-translations.da.po'
403- silent : true
404-
405- config-translations:import :
406- cmds :
407- # Note: We use an empty type to import as not-customized.
408- - task drush -- config_translation_po:import --type='' --override=not-customized da ../translations/config-translations.da.po
409- silent : true
0 commit comments