Skip to content

Commit 2ab39c9

Browse files
committed
Add translation files check
1 parent 1fbc5ef commit 2ab39c9

File tree

3 files changed

+33
-4
lines changed

3 files changed

+33
-4
lines changed

.github/workflows/files-changed.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ jobs:
3333
docker: ${{ steps.changes.outputs.docker }}
3434
swagger: ${{ steps.changes.outputs.swagger }}
3535
yaml: ${{ steps.changes.outputs.yaml }}
36+
locale: ${{ steps.changes.outputs.locale }}
3637
steps:
3738
- uses: actions/checkout@v4
3839
- uses: dorny/paths-filter@v3
@@ -48,7 +49,6 @@ jobs:
4849
- "Makefile"
4950
- ".golangci.yml"
5051
- ".editorconfig"
51-
- "options/locale/locale_en-US.json"
5252
5353
frontend:
5454
- "*.js"
@@ -63,6 +63,9 @@ jobs:
6363
- ".eslintrc.cjs"
6464
- ".npmrc"
6565
66+
locale:
67+
- "options/locale/*.json"
68+
6669
docs:
6770
- "**/*.md"
6871
- ".markdownlint.yaml"

.github/workflows/pull-compliance.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,14 @@ jobs:
110110
env:
111111
TAGS: bindata gogit sqlite sqlite_unlock_notify
112112

113+
checks-locale:
114+
if: needs.files-changed.outputs.locale == 'true'
115+
needs: files-changed
116+
runs-on: ubuntu-latest
117+
steps:
118+
- uses: actions/checkout@v4
119+
- run: make translation-check
120+
113121
checks-backend:
114122
if: needs.files-changed.outputs.backend == 'true' || needs.files-changed.outputs.actions == 'true'
115123
needs: files-changed

Makefile

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -914,14 +914,32 @@ lockfile-check:
914914
exit 1; \
915915
fi
916916

917+
LOCALE_DIR := options/locale
918+
LOCALE_FILES := $(wildcard $(LOCALE_DIR)/*.json)
919+
920+
.PHONY: translation-check
921+
translation-check:
922+
npm install -g jsonlint find-duplicated-property-keys
923+
@echo "Checking JSON files in $(LOCALE_DIR)"
924+
@for f in $(LOCALE_FILES); do \
925+
echo "==> $$f"; \
926+
if ! jsonlint -q $$f > /dev/null 2>&1; then \
927+
echo "❌ Invalid JSON syntax: $$f"; \
928+
exit 1; \
929+
fi; \
930+
if ! find-duplicated-property-keys -s $$f > /dev/null 2>&1; then \
931+
echo "❌ Duplicate key found in: $$f"; \
932+
exit 1; \
933+
fi; \
934+
done
935+
@echo "✅ All JSON files passed"
936+
917937
.PHONY: update-translations
918938
update-translations:
919939
mkdir -p ./translations
920940
cd ./translations && curl -L https://crowdin.com/download/project/gitea.zip > gitea.zip && unzip gitea.zip
921941
rm ./translations/gitea.zip
922-
$(SED_INPLACE) -e 's/="/=/g' -e 's/"$$//g' ./translations/*.ini
923-
$(SED_INPLACE) -e 's/\\"/"/g' ./translations/*.ini
924-
mv ./translations/*.ini ./options/locale/
942+
mv ./translations/*.json ./options/locale/
925943
rmdir ./translations
926944

927945
.PHONY: generate-gitignore

0 commit comments

Comments
 (0)