From 5a987b5d09a494d0be96178e57e3ef5397e9df80 Mon Sep 17 00:00:00 2001 From: mahula Date: Fri, 10 Feb 2023 08:16:55 +0100 Subject: [PATCH 01/12] add yarn locales functionality to backend --- backend/package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backend/package.json b/backend/package.json index f58a1ddd3..413ddeb4c 100644 --- a/backend/package.json +++ b/backend/package.json @@ -15,7 +15,8 @@ "lint": "eslint --max-warnings=0 --ext .js,.ts .", "test": "cross-env TZ=UTC NODE_ENV=development jest --runInBand --coverage --forceExit --detectOpenHandles", "seed": "cross-env TZ=UTC NODE_ENV=development ts-node -r tsconfig-paths/register src/seeds/index.ts", - "klicktipp": "cross-env TZ=UTC NODE_ENV=development ts-node -r tsconfig-paths/register src/util/klicktipp.ts" + "klicktipp": "cross-env TZ=UTC NODE_ENV=development ts-node -r tsconfig-paths/register src/util/klicktipp.ts", + "locales": "scripts/sort.sh" }, "dependencies": { "@hyperswarm/dht": "^6.2.0", From fa72f9666a0038071c575034cc6092be8932a7c1 Mon Sep 17 00:00:00 2001 From: mahula Date: Fri, 10 Feb 2023 08:21:39 +0100 Subject: [PATCH 02/12] sort backend locales using yarn lint --fix --- backend/src/locales/de.json | 10 +++++----- backend/src/locales/en.json | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/backend/src/locales/de.json b/backend/src/locales/de.json index 304ae2adc..530e8db10 100644 --- a/backend/src/locales/de.json +++ b/backend/src/locales/de.json @@ -1,10 +1,5 @@ { "emails": { - "addedContributionMessage": { - "commonGoodContributionMessage": "du hast zu deinem Gemeinwohl-Beitrag „{contributionMemo}“ eine Nachricht von {senderFirstName} {senderLastName} erhalten.", - "subject": "Gradido: Nachricht zu deinem Gemeinwohl-Beitrag", - "toSeeAndAnswerMessage": "Um die Nachricht zu sehen und darauf zu antworten, gehe in deinem Gradido-Konto ins Menü „Gemeinschaft“ auf den Tab „Meine Beiträge zum Gemeinwohl“!" - }, "accountActivation": { "duration": "Der Link hat eine Gültigkeit von {hours} Stunden und {minutes} Minuten. Sollte die Gültigkeit des Links bereits abgelaufen sein, kannst du dir hier einen neuen Link schicken lassen:", "emailRegistered": "deine E-Mail-Adresse wurde soeben bei Gradido registriert.", @@ -19,6 +14,11 @@ "onForgottenPasswordCopyLink": "oder kopiere den obigen Link in dein Browserfenster.", "subject": "Gradido: Erneuter Registrierungsversuch mit deiner E-Mail" }, + "addedContributionMessage": { + "commonGoodContributionMessage": "du hast zu deinem Gemeinwohl-Beitrag „{contributionMemo}“ eine Nachricht von {senderFirstName} {senderLastName} erhalten.", + "subject": "Gradido: Nachricht zu deinem Gemeinwohl-Beitrag", + "toSeeAndAnswerMessage": "Um die Nachricht zu sehen und darauf zu antworten, gehe in deinem Gradido-Konto ins Menü „Gemeinschaft“ auf den Tab „Meine Beiträge zum Gemeinwohl“!" + }, "contributionConfirmed": { "commonGoodContributionConfirmed": "dein Gemeinwohl-Beitrag „{contributionMemo}“ wurde soeben von {senderFirstName} {senderLastName} bestätigt und in deinem Gradido-Konto gutgeschrieben.", "subject": "Gradido: Dein Gemeinwohl-Beitrag wurde bestätigt" diff --git a/backend/src/locales/en.json b/backend/src/locales/en.json index bdc92b2cf..269c38629 100644 --- a/backend/src/locales/en.json +++ b/backend/src/locales/en.json @@ -1,10 +1,5 @@ { "emails": { - "addedContributionMessage": { - "commonGoodContributionMessage": "you have received a message from {senderFirstName} {senderLastName} regarding your common good contribution “{contributionMemo}”.", - "subject": "Gradido: Message about your common good contribution", - "toSeeAndAnswerMessage": "To view and reply to the message, go to the “Community” menu in your Gradido account and click on the “My contributions to the common good” tab!" - }, "accountActivation": { "duration": "The link has a validity of {hours} hours and {minutes} minutes. If the validity of the link has already expired, you can have a new link sent to you here:", "emailRegistered": "Your email address has just been registered with Gradido.", @@ -19,6 +14,11 @@ "onForgottenPasswordCopyLink": "or copy the link above into your browser window.", "subject": "Gradido: Try To Register Again With Your Email" }, + "addedContributionMessage": { + "commonGoodContributionMessage": "you have received a message from {senderFirstName} {senderLastName} regarding your common good contribution “{contributionMemo}”.", + "subject": "Gradido: Message about your common good contribution", + "toSeeAndAnswerMessage": "To view and reply to the message, go to the “Community” menu in your Gradido account and click on the “My contributions to the common good” tab!" + }, "contributionConfirmed": { "commonGoodContributionConfirmed": "Your public good contribution “{contributionMemo}” has just been confirmed by {senderFirstName} {senderLastName} and credited to your Gradido account.", "subject": "Gradido: Your contribution to the common good was confirmed" From a3e2b34ff33f778d0bae754a5a7ff63aec27dc62 Mon Sep 17 00:00:00 2001 From: mahula Date: Fri, 10 Feb 2023 08:30:58 +0100 Subject: [PATCH 03/12] add backend linting to github test workflow --- .github/workflows/test.yml | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index da8521a76..695011c11 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -360,6 +360,35 @@ jobs: - name: backend | Lint run: docker run --rm gradido/backend:test yarn run lint + ############################################################################## + # JOB: LOCALES BACKEND ####################################################### + ############################################################################## + locales_frontend: + name: Locales - Backend + runs-on: ubuntu-latest + needs: [build_test_backend] + steps: + ########################################################################## + # CHECKOUT CODE ########################################################## + ########################################################################## + - name: Checkout code + uses: actions/checkout@v3 + ########################################################################## + # DOWNLOAD DOCKER IMAGE ################################################## + ########################################################################## + - name: Download Docker Image (Backend) + uses: actions/download-artifact@v3 + with: + name: docker-backendend-test + path: /tmp + - name: Load Docker Image + run: docker load < /tmp/backend.tar + ########################################################################## + # LOCALES FRONTEND ####################################################### + ########################################################################## + - name: Backendend | Locales + run: docker run --rm gradido/backend:test yarn run locales + ############################################################################## # JOB: LINT DATABASE UP ###################################################### ############################################################################## From ee5aea4c85dc85b6b42ac794c2edf1b52708379d Mon Sep 17 00:00:00 2001 From: mahula Date: Fri, 10 Feb 2023 08:47:28 +0100 Subject: [PATCH 04/12] fix typo in github test workflow --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 695011c11..7b9bf09f2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -363,7 +363,7 @@ jobs: ############################################################################## # JOB: LOCALES BACKEND ####################################################### ############################################################################## - locales_frontend: + locales_backend: name: Locales - Backend runs-on: ubuntu-latest needs: [build_test_backend] From 592e1c11c51515ff93af70d1b4590db5848d102e Mon Sep 17 00:00:00 2001 From: mahula Date: Fri, 10 Feb 2023 08:47:28 +0100 Subject: [PATCH 05/12] fix typo in github test workflow --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7b9bf09f2..c1ff5b97c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -379,7 +379,7 @@ jobs: - name: Download Docker Image (Backend) uses: actions/download-artifact@v3 with: - name: docker-backendend-test + name: docker-backend-test path: /tmp - name: Load Docker Image run: docker load < /tmp/backend.tar From cf0e7f18ff4a5d7e37c6b847107d5fcff72644f5 Mon Sep 17 00:00:00 2001 From: mahula Date: Fri, 10 Feb 2023 09:04:36 +0100 Subject: [PATCH 06/12] add scripts for locales check to backend --- backend/scripts/sort.sh | 25 +++++++++++++++++++++++++ backend/scripts/sort_filter.jq | 13 +++++++++++++ 2 files changed, 38 insertions(+) create mode 100755 backend/scripts/sort.sh create mode 100644 backend/scripts/sort_filter.jq diff --git a/backend/scripts/sort.sh b/backend/scripts/sort.sh new file mode 100755 index 000000000..e5c5c41c6 --- /dev/null +++ b/backend/scripts/sort.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +ROOT_DIR=$(dirname "$0")/.. + +tmp=$(mktemp) +exit_code=0 + +for locale_file in $ROOT_DIR/src/locales/*.json +do + jq -f $(dirname "$0")/sort_filter.jq $locale_file > "$tmp" + if [ "$*" == "--fix" ] + then + mv "$tmp" $locale_file + else + if diff -q "$tmp" $locale_file > /dev/null ; + then + : # all good + else + exit_code=$? + echo "$(basename -- $locale_file) is not sorted by keys" + fi + fi +done + +exit $exit_code diff --git a/backend/scripts/sort_filter.jq b/backend/scripts/sort_filter.jq new file mode 100644 index 000000000..9d108f8f0 --- /dev/null +++ b/backend/scripts/sort_filter.jq @@ -0,0 +1,13 @@ +def walk(f): + . as $in + | if type == "object" then + reduce keys_unsorted[] as $key + ( {}; . + { ($key): ($in[$key] | walk(f)) } ) | f + elif type == "array" then map( walk(f) ) | f + else f + end; + +def keys_sort_by(f): + to_entries | sort_by(.key|f ) | from_entries; + +walk(if type == "object" then keys_sort_by(ascii_upcase) else . end) \ No newline at end of file From 7be46f5e681a49d2a5d8f3dd1ead93666d4da385 Mon Sep 17 00:00:00 2001 From: elweyn Date: Fri, 10 Feb 2023 12:25:42 +0100 Subject: [PATCH 07/12] Add pwd before yarn run locales --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c1ff5b97c..83a3f5cd6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -358,7 +358,7 @@ jobs: # LINT BACKEND ########################################################### ########################################################################## - name: backend | Lint - run: docker run --rm gradido/backend:test yarn run lint + run: docker run --rm gradido/backend:test pwd && yarn run lint ############################################################################## # JOB: LOCALES BACKEND ####################################################### From 73c38d7ecbfe1fafa9f4172d56dc4104869c30cb Mon Sep 17 00:00:00 2001 From: Hannes Heine Date: Fri, 10 Feb 2023 13:56:55 +0100 Subject: [PATCH 08/12] Update .github/workflows/test.yml --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 83a3f5cd6..c1ff5b97c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -358,7 +358,7 @@ jobs: # LINT BACKEND ########################################################### ########################################################################## - name: backend | Lint - run: docker run --rm gradido/backend:test pwd && yarn run lint + run: docker run --rm gradido/backend:test yarn run lint ############################################################################## # JOB: LOCALES BACKEND ####################################################### From 5fdd056623974b7aa035fe7bef3c468488f8aa17 Mon Sep 17 00:00:00 2001 From: Hannes Heine Date: Fri, 10 Feb 2023 13:57:02 +0100 Subject: [PATCH 09/12] Update .github/workflows/test.yml --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c1ff5b97c..db1fc6099 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -387,7 +387,7 @@ jobs: # LOCALES FRONTEND ####################################################### ########################################################################## - name: Backendend | Locales - run: docker run --rm gradido/backend:test yarn run locales + run: docker run --rm gradido/backend:test pwd && yarn run locales ############################################################################## # JOB: LINT DATABASE UP ###################################################### From da8f371823a434b95edd4b79e9ca9c2b8df7b06c Mon Sep 17 00:00:00 2001 From: elweyn Date: Fri, 10 Feb 2023 14:11:49 +0100 Subject: [PATCH 10/12] Debugging docker... --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index db1fc6099..548a858a6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -387,7 +387,7 @@ jobs: # LOCALES FRONTEND ####################################################### ########################################################################## - name: Backendend | Locales - run: docker run --rm gradido/backend:test pwd && yarn run locales + run: docker run --rm gradido/backend:test pwd && ls -halt && yarn run locales ############################################################################## # JOB: LINT DATABASE UP ###################################################### From 786876a46deac1bc886103dace18720d8f6822de Mon Sep 17 00:00:00 2001 From: elweyn Date: Fri, 10 Feb 2023 14:24:50 +0100 Subject: [PATCH 11/12] Yarn locales is in backend not under gradido. --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 548a858a6..b9d9edd5f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -387,7 +387,7 @@ jobs: # LOCALES FRONTEND ####################################################### ########################################################################## - name: Backendend | Locales - run: docker run --rm gradido/backend:test pwd && ls -halt && yarn run locales + run: docker run --rm gradido/backend:test cd backend && yarn run locales ############################################################################## # JOB: LINT DATABASE UP ###################################################### From a88968d3da3f1996500382b1ca297b2bd5c66ad8 Mon Sep 17 00:00:00 2001 From: elweyn Date: Fri, 10 Feb 2023 15:14:13 +0100 Subject: [PATCH 12/12] Change structure to locales check --- .github/workflows/test.yml | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b9d9edd5f..c204eb321 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -374,20 +374,10 @@ jobs: - name: Checkout code uses: actions/checkout@v3 ########################################################################## - # DOWNLOAD DOCKER IMAGE ################################################## + # LOCALES BACKEND ##################################################### ########################################################################## - - name: Download Docker Image (Backend) - uses: actions/download-artifact@v3 - with: - name: docker-backend-test - path: /tmp - - name: Load Docker Image - run: docker load < /tmp/backend.tar - ########################################################################## - # LOCALES FRONTEND ####################################################### - ########################################################################## - - name: Backendend | Locales - run: docker run --rm gradido/backend:test cd backend && yarn run locales + - name: Backend | Locales + run: cd backend && yarn && yarn locales ############################################################################## # JOB: LINT DATABASE UP ######################################################