Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve import and export of translation strings #955

Merged
merged 1 commit into from
Jul 5, 2024
Merged
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
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
name: Upload All Translations
name: Export All Translations
on:
workflow_dispatch: {}

@@ -16,8 +16,8 @@ jobs:
- name: Install Python dependencies
run: pip install -r .github/scripts/requirements.txt

- name: Upload CurseForge Translations
run: make push-all-locales
- name: Export All Translations
run: make translations-export-all
env:
CF_API_KEY: ${{ secrets.CF_API_KEY }}

36 changes: 36 additions & 0 deletions .github/workflows/export-translations.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
---
name: Export Translations
on:
push:
branches:
- main
workflow_dispatch: {}

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: '3.10'
cache: 'pip'

- name: Install Python dependencies
run: pip install -r .github/scripts/requirements.txt

- name: Export Translations
run: make translations-export
env:
CF_API_KEY: ${{ secrets.CF_API_KEY }}

- name: Send Webhook Notification
if: failure()
run: |
git clone https://github.com/DiscordHooks/github-actions-discord-webhook.git webhook
bash webhook/send.sh $JOB_STATUS $WEBHOOK_URL
env:
JOB_STATUS: ${{ job.status }}
HOOK_OS_NAME: ${{ runner.os }}
WEBHOOK_URL: ${{ secrets.WEBHOOK_URL }}
WORKFLOW_NAME: ${{ github.workflow }}
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
---
name: Process CurseForge Translations
name: Import External Translations
on:
push:
branches:
- main
schedule:
- cron: '0 18 * * *'
workflow_dispatch: {}
@@ -21,24 +18,19 @@ jobs:
- name: Install Python dependencies
run: pip install -r .github/scripts/requirements.txt

- name: Upload CurseForge Translations
run: make push-locales
env:
CF_API_KEY: ${{ secrets.CF_API_KEY }}

- name: Download CurseForge Translations
run: make pull-locales
- name: Import External Translations
run: make translations-import
env:
CF_API_KEY: ${{ secrets.CF_API_KEY }}

- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
with:
commit-message: Import CurseForge Localization
branch: actions/import-cf-localization
commit-message: Import External Translations
branch: actions/import-external-translations
delete-branch: true
title: Import CurseForge Localization
body: Automated import of CurseForge localization.
title: Import External Translations
body: Automated import of external translation strings.
author: GitHub <[email protected]>
reviewers: Meorawr, Solanya

50 changes: 20 additions & 30 deletions Makefile
Original file line number Diff line number Diff line change
@@ -10,53 +10,43 @@ CF_PROJECT_ID := 75973

LOCALES := enUS deDE esES esMX frFR itIT koKR ptBR ruRU zhCN zhTW
LOCALES_DIR := totalRP3/Locales
LOCALE_PUSH_TARGETS := $(addprefix push-locales-,$(LOCALES))
LOCALE_PULL_TARGETS := $(addprefix pull-locales-,$(LOCALES))
PUSH_LOCALES := enUS
PULL_LOCALES := $(filter-out enUS,$(LOCALES))
LOCALES_SCRIPT := $(PYTHON) .github/scripts/localization.py
EXPORT_LOCALES := enUS
IMPORT_LOCALES := $(filter-out $(EXPORT_LOCALES),$(LOCALES))

.DEFAULT: all
.DELETE_ON_ERROR:
.FORCE:
.PHONY: all check dist libs schema

.PHONY: all
all: dist

.PHONY: check
check: .github/scripts/ui.xsd
check: schema
pre-commit run --all-files

.PHONY: dist
dist:
curl -s $(PACKAGER_URL) | bash -s -- -dS

.PHONY: libs
libs:
curl -s $(PACKAGER_URL) | bash -s -- -cdlz
cp -aTv .release/$(LIBDIR) $(LIBDIR)

.PHONY: locales
locales: push-locales pull-locales
schema:
curl -s $(SCHEMA_URL) -o .github/scripts/ui.xsd

.PHONY: push-all-locales
push-all-locales: $(addprefix push-locales-,$(LOCALES))
.PHONY: translations translations-export translations-export-all translations-import translations-import-all
translations: translations-export translations-import
translations-export: $(addprefix translations-export-,$(EXPORT_LOCALES))
translations-export-all: $(addprefix translations-export-,$(LOCALES))
translations-import: $(addprefix translations-import-,$(IMPORT_LOCALES))
translations-import-all: $(addprefix translations-import-,$(LOCALES))

.PHONY: push-locales
push-locales: $(addprefix push-locales-,$(PUSH_LOCALES))
translations-export-enUS: EXPORT_OPTIONS := --delete-missing-phrases

.PHONY: $(LOCALE_PUSH_TARGETS)
$(LOCALE_PUSH_TARGETS): push-locales-%:
$(PYTHON) .github/scripts/localization.py upload --locale $* --project-id $(CF_PROJECT_ID) <$(LOCALES_DIR)/$*.lua
.PHONY: $(addprefix translations-export-,$(LOCALES))
$(addprefix translations-export-,$(LOCALES)): translations-export-%:
$(LOCALES_SCRIPT) upload --locale $* --project-id $(CF_PROJECT_ID) $(EXPORT_OPTIONS) <$(LOCALES_DIR)/$*.lua

.PHONY: pull-all-locales
pull-all-locales: $(addprefix pull-locales-,$(LOCALES))

.PHONY: pull-locales
pull-locales: $(addprefix pull-locales-,$(PULL_LOCALES))

.PHONY: $(LOCALE_PULL_TARGETS)
$(LOCALE_PULL_TARGETS): pull-locales-%:
$(PYTHON) .github/scripts/localization.py download --locale $* --project-id $(CF_PROJECT_ID) >$(LOCALES_DIR)/$*.lua

.github/scripts/ui.xsd: .FORCE
curl -s $(SCHEMA_URL) -o $@
.PHONY: $(addprefix translations-import-,$(LOCALES))
$(addprefix translations-import-,$(LOCALES)): translations-import-%:
$(LOCALES_SCRIPT) download --locale $* --project-id $(CF_PROJECT_ID) $(IMPORT_OPTIONS) >$(LOCALES_DIR)/$*.lua