@@ -231,15 +231,6 @@ tasks:
231231 - task : theme-translations:import
232232 silent : true
233233
234- clean-up-translations :
235- internal : true
236- cmds :
237- # Fix plurals spec in Danish PO file
238- # https://drupalsun.com/eelke/2020/08/17/tale-mistranslated-plurals
239- # https://www.drupal.org/project/drupal/issues/3496223
240- - |
241- docker run --user=${COMPOSE_USER:-deploy} --rm --volume "$PWD:/app" itkdev/php8.3-fpm sed --in-place 's/Plural-Forms: nplurals=2; plural=(n > 1);/Plural-Forms: nplurals=2; plural=(n != 1);/' $(find translations config/translations web/*/custom/*/translations -name '*.da.po')
242-
243234 # ------------------------------------------------------------------------------
244235 # Internal helper tasks.
245236 # ------------------------------------------------------------------------------
@@ -291,3 +282,29 @@ tasks:
291282 - TYPE
292283 - NAMES
293284 silent : true
285+
286+ clean-up-translations :
287+ internal : true
288+ cmds :
289+ # Replace \r\n with \n PO files (cf. "warning: internationalized messages should not contain the '\r' escape sequence")
290+ - |
291+ {{.SHELL}} sed --in-place 's/\\r\\n/\\n/g' $(find translations config/translations web/*/custom/*/translations -name '*.po')
292+ # Fix plurals spec in Danish PO files
293+ # https://drupalsun.com/eelke/2020/08/17/tale-mistranslated-plurals
294+ # https://www.drupal.org/project/drupal/issues/3496223
295+ - |
296+ {{.SHELL}} sed --in-place 's/Plural-Forms: nplurals=2; plural=(n > 1);/Plural-Forms: nplurals=2; plural=(n != 1);/' $(find translations config/translations web/*/custom/*/translations -name '*.da.po')
297+ # Set 'Language' field in the header entry in Danish PO files
298+ - |
299+ for f in $(find translations config/translations web/*/custom/*/translations -name '*.da.po'); do
300+ {{.SHELL}} msgcat --lang=da "$f" > {{.TMP_FILE_PATH}} && mv {{.TMP_FILE_PATH}} "$f"
301+ done
302+ # Make translations unique and sort them
303+ # (cf. https://www.man7.org/linux/man-pages/man1/msguniq.1.html)
304+ - |
305+ for f in $(find translations config/translations web/*/custom/*/translations -name '*.po'); do
306+ {{.SHELL}} msguniq --unique --sort-output --no-wrap "$f" > {{.TMP_FILE_PATH}} && mv {{.TMP_FILE_PATH}} "$f"
307+ done
308+ vars :
309+ SHELL : docker run --user=${COMPOSE_USER:-deploy} --rm --volume "$PWD:/app" itkdev/php8.4-fpm
310+ TMP_FILE_PATH : /tmp/translations.tmp
0 commit comments