Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions .github/workflows/translation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Translation

on:
pull_request:
push:
branches:
- main
- develop

env:
COMPOSE_USER: runner

jobs:
check-translations:
runs-on: ubuntu-latest
strategy:
matrix:
task:
- translation:contrib-translations:export
- translation:config-translations:export
- translation:module-translations:export
- translation:theme-translations:export
steps:
- uses: actions/checkout@v4
# https://github.com/actions/checkout/issues/881
# https://github.com/actions/checkout/issues/504
# https://github.com/actions/checkout?tab=readme-ov-file#checkout-pull-request-head-commit-instead-of-merge-commit
with:
ref: ${{ github.event.pull_request.head.sha }}
- uses: arduino/setup-task@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Install site
run: |
docker network create frontend
task site-install --yes

- name: Export translations (${{ matrix.task }})
run: |
task ${{ matrix.task }}

# https://github.com/mxschmitt/action-tmate?tab=readme-ov-file#manually-triggered-debug
# Enable tmate debugging if debug logging is enabled (cf.
# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/accessing-contextual-information-about-workflow-runs#runner-context)
- name: Setup tmate session
uses: mxschmitt/action-tmate@v3
if: 1 == runner.debug

- run: |
task translation:translations:diff
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,5 @@ private-files
/playwright/.cache/

config/sync/**/webform.webform.*

web/*/custom/*/translations/*.*.mo
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]

* [PR-468](https://github.com/itk-dev/hoeringsportal/pull/468)
Added module and theme translations
* [PR-428](https://github.com/itk-dev/hoeringsportal/pull/428)
Upgraded to PHP 8.4
* [PR-494](https://github.com/itk-dev/hoeringsportal/pull/494)
Expand Down
76 changes: 54 additions & 22 deletions Taskfile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,54 @@ version: '3'
# https://taskfile.dev/usage/#env-files
dotenv: ['.env.local', '.env']

includes:
translation:
taskfile: ./task/Taskfile.translation.yml
vars:
TRANSLATION_MODULES:
# Run `ls web/modules/custom/*/*.info.yml | xargs basename -s '.info.yml'` to get this list
- aarhus_hero

# Only used for development.
# - hoeringsportal_base_fixtures

- hoeringsportal_citizen_proposal
- hoeringsportal_citizen_proposal_archiving
- hoeringsportal_config_settings
- hoeringsportal_content_access
- hoeringsportal_content_blocks
- hoeringsportal_data
- hoeringsportal_deskpro
- hoeringsportal_forms
- hoeringsportal_hearing
- hoeringsportal_openid_connect
- hoeringsportal_project_timeline
- hoeringsportal_public_meeting
- hoeringsportal_quicklinks
- hoeringsportal_test_delta_sync_fixtures

- itk_admin
- itk_admin_links

# - itk_media_entity
# - migrate_subject_data

TRANSLATION_THEMES:
# Run `ls web/themes/custom/*/*.info.yml | xargs basename -s '.info.yml'` to get this []
- hoeringsportal

# - hoeringsportal_admin

TRANSLATION_LANGUAGES:
- da

# During testing and development, you can override TRANSLATION_MODULES and TRANSLATION_THEMES to not process all modules and themes, e.g.
#
# TRANSLATION_MODULES:
# - hoeringsportal_citizen_proposal
#
# TRANSLATION_THEMES: []

vars:
# https://taskfile.dev/reference/templating/
BASE_URL: '{{.TASK_BASE_URL | default .COMPOSE_SERVER_DOMAIN | default .COMPOSE_DOMAIN | default "https://hoeringsportal.local.itkdev.dk"}}'
Expand All @@ -26,10 +74,10 @@ tasks:
- task compose -- pull
- task compose-up
- task composer-install
- task assets-build
- task drush -- --yes site:install --existing-config
- task: translations:import
- task: translation:import
- task drush -- --yes cache:rebuild
- task assets-build
- task site-open
- task site-open-admin
silent: true
Expand All @@ -41,7 +89,7 @@ tasks:
- task composer-install
- task assets-build
- task drush -- deploy
- task: translations:import
- task: translation:import
- task drush -- --yes cache:rebuild
silent: true

Expand All @@ -52,12 +100,13 @@ tasks:

site-open:
cmds:
- if command -v open 2>&1 >/dev/null; then open "$(task site-url)"; else echo "$(task site-url)"; fi
# `open` is defined in GitHub Actions (ubuntu-latest), but cannot actually be run without error. Therefore we add `|| true` to prevent errors.
- if command -v open 2>&1 >/dev/null; then open "$(task site-url)" || true; else echo "$(task site-url)"; fi
silent: true

site-open-admin:
cmds:
- if command -v open 2>&1 >/dev/null; then open "{{.URL}}"; else echo "{{.URL}}"; fi
- if command -v open 2>&1 >/dev/null; then open "{{.URL}}" || true; else echo "{{.URL}}"; fi
vars:
URL:
sh: task drush -- user:login --no-browser
Expand Down Expand Up @@ -241,20 +290,3 @@ tasks:
- task drush -- --yes pm:uninstall content_fixtures
- task compose-up
silent: true

translations:import:
cmds:
- task compose -- exec phpfpm bash -c '(cd web && ../vendor/bin/drush locale:import --type=customized --override=all da ../translations/custom-translations.da.po)'
- task drush -- php:eval "var_export(\Drupal::state()->get('locale.translation.formulae', []))"
- '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)));"'
- '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)));"'
silent: true

translations:export:
cmds:
- task compose -- exec phpfpm bash -c '(cd web && ../vendor/bin/drush locale:export da --types=customized > ../translations/custom-translations.da.po)'
# Fix plurals spec in PO file
# https://drupalsun.com/eelke/2020/08/17/tale-mistranslated-plurals
# https://www.drupal.org/project/drupal/issues/3496223
- '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'
silent: true
11 changes: 10 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"drupal/color_field": "^3.0",
"drupal/config_ignore": "^3.2",
"drupal/config_import_locale": "^2.0",
"drupal/config_translation_po": "dev-3439416-added-drush-command",
"drupal/core": "^10.0",
"drupal/core-composer-scaffold": "^10.0",
"drupal/core-project-message": "^10.0",
Expand Down Expand Up @@ -84,6 +85,7 @@
"drupal/content_fixtures": "dev-3498162-not-compatible-with",
"drupal/core-dev": "^10.0",
"drupal/masquerade": "^2.0",
"drupal/potx": "^1.1",
"drupal/webprofiler": "^10.3",
"ergebnis/composer-normalize": "^2.44",
"mglaman/phpstan-drupal": "^1.1",
Expand All @@ -102,7 +104,10 @@
},
"drupal": {
"type": "composer",
"url": "https://packages.drupal.org/8"
"url": "https://packages.drupal.org/8",
"exclude": [
"drupal/config_translation_po"
]
},
"asset-packagist": {
"type": "composer",
Expand Down Expand Up @@ -188,6 +193,10 @@
"reference": "hotfix/change-psr-log-dependency"
}
}
},
"drupal/config_translation_po": {
"type": "git",
"url": "https://git.drupalcode.org/issue/config_translation_po-3439416.git"
}
},
"minimum-stability": "dev",
Expand Down
98 changes: 91 additions & 7 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions config/sync/core.extension.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ module:
config: 0
config_ignore: 0
config_import_locale: 0
config_translation: 0
config_translation_po: 0
crop: 0
csv_serialization: 0
ctools: 0
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
settings:
label: 'Aarhus kommune'
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
settings:
label: 'Status messages'
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
label: Token
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
label: Token
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
label: Token
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
label: Token
Loading
Loading