Skip to content

Commit ce6cfc2

Browse files
committed
🌐(action) upload sources translation on crowdin
Crowdin has released its own github action to automatize translation workflow. We want to use to upload sources when a PR is merged.
1 parent 4b3b441 commit ce6cfc2

File tree

4 files changed

+86
-8
lines changed

4 files changed

+86
-8
lines changed

.github/workflows/crowdin_upload.yml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: Update crowdin sources
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
9+
jobs:
10+
synchronize-with-crowdin:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout
15+
uses: actions/checkout@v4
16+
# Backend i18n
17+
- name: Install Python
18+
uses: actions/setup-python@v3
19+
with:
20+
python-version: "3.12.6"
21+
- name: Upgrade pip and setuptools
22+
run: pip install --upgrade pip setuptools
23+
- name: Install development dependencies
24+
run: pip install --user .
25+
working-directory: src/backend
26+
- name: Install gettext
27+
run: |
28+
sudo apt-get update
29+
sudo apt-get install -y gettext pandoc
30+
- name: generate pot files
31+
working-directory: src/backend
32+
run: |
33+
DJANGO_CONFIGURATION=Build python manage.py compilemessages
34+
DJANGO_CONFIGURATION=Build python manage.py makemessages -a --keep-pot
35+
# frontend i18n
36+
- name: Setup Node.js
37+
uses: actions/setup-node@v4
38+
with:
39+
node-version: "20.x"
40+
- name: Restore the frontend cache
41+
uses: actions/cache@v4
42+
id: front-node_modules
43+
with:
44+
path: "src/frontend/**/node_modules"
45+
key: front-node_modules-${{ hashFiles('src/frontend/**/yarn.lock') }}
46+
- name: Install dependencies
47+
if: steps.front-node_modules.outputs.cache-hit != 'true'
48+
run: cd src/frontend/ && yarn install --frozen-lockfile
49+
- name: Cache install frontend
50+
if: steps.front-node_modules.outputs.cache-hit != 'true'
51+
uses: actions/cache@v4
52+
with:
53+
path: "src/frontend/**/node_modules"
54+
key: front-node_modules-${{ hashFiles('src/frontend/**/yarn.lock') }}
55+
- name: generate source translation file
56+
working-directory: src/frontend
57+
run: yarn i18n:extract
58+
# crowdin workflow
59+
- name: crowdin action
60+
uses: crowdin/github-action@v2
61+
with:
62+
config: crowdin/config.yml
63+
upload_sources: true
64+
upload_translations: false
65+
download_translations: false
66+
create_pull_request: false
67+
env:
68+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
69+
# A numeric ID, found at https://crowdin.com/project/<projectName>/tools/api
70+
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
71+
72+
# Visit https://crowdin.com/settings#api-key to create this token
73+
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
74+
75+
CROWDIN_BASE_PATH: "../src/"

CHANGELOG.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,17 @@ and this project adheres to
99

1010
## [Unreleased]
1111

12+
## Added
13+
14+
- github actions to managed Crowdin workflow
15+
1216
## [2.0.1] - 2025-01-17
1317

1418
## Fixed
1519

1620
-🐛(frontend) share modal is shown when you don't have the abilities #557
1721
-🐛(frontend) title copy break app #564
1822

19-
2023
## [2.0.0] - 2025-01-13
2124

2225
## Added

crowdin/config.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#
22
# Your crowdin's credentials
33
#
4-
api_token_env: CROWDIN_API_TOKEN
4+
api_token_env: CROWDIN_PERSONAL_TOKEN
55
project_id_env: CROWDIN_PROJECT_ID
66
base_path_env: CROWDIN_BASE_PATH
77

@@ -15,11 +15,11 @@ preserve_hierarchy: true
1515
# Files configuration
1616
#
1717
files: [
18-
{
19-
source : "/backend/locale/django.pot",
20-
dest: "/backend-impress.pot",
21-
translation : "/backend/locale/%locale_with_underscore%/LC_MESSAGES/django.po"
22-
},
18+
{
19+
source : "/backend/locale/django.pot",
20+
dest: "/backend-impress.pot",
21+
translation : "/backend/locale/%locale_with_underscore%/LC_MESSAGES/django.po"
22+
},
2323
{
2424
source: "/frontend/packages/i18n/locales/impress/translations-crowdin.json",
2525
dest: "/frontend-impress.json",

env.d/development/crowdin.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
CROWDIN_API_TOKEN=Your-Api-Token
1+
CROWDIN_PERSONAL_TOKEN=Your-Personal-Token
22
CROWDIN_PROJECT_ID=Your-Project-Id
33
CROWDIN_BASE_PATH=/app/src

0 commit comments

Comments
 (0)