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

Implement Crowdin Translation Automation #216

Open
wants to merge 76 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
895dd07
update gitignore
Oct 17, 2023
a83262b
Add workflow
Oct 17, 2023
7faed15
change to main
Oct 17, 2023
3377dc5
Merge pull request #1 from ManindraDeMel/automate-language
ManindraDeMel Oct 17, 2023
4170c59
add manual dispatch
Oct 17, 2023
c28d90b
Merge pull request #2 from ManindraDeMel/automate-language
ManindraDeMel Oct 17, 2023
0aabeaa
Add translated README.es.md
actions-user Oct 17, 2023
240f9ae
add debug
Oct 17, 2023
64102eb
attempt fix API call + dont translate links
Oct 17, 2023
d1f0bf9
use file translate endpoint
ManindraDeMel Oct 18, 2023
b0f2219
Add translated README.es.md
actions-user Oct 18, 2023
77501c8
Merge branch 'OpenBMB:main' into main
ManindraDeMel Oct 19, 2023
fad93d9
revert to text translation
ManindraDeMel Oct 19, 2023
7c73e9a
Merge branch 'main' of https://github.com/ManindraDeMel/ChatDev
ManindraDeMel Oct 19, 2023
4491efa
Add translated README.es.md
actions-user Oct 19, 2023
0be1375
added debugging to translate
ManindraDeMel Oct 19, 2023
73c6e01
Merge branch 'main' of https://github.com/ManindraDeMel/ChatDev
ManindraDeMel Oct 19, 2023
5c10d56
Translations using crowdin
ManindraDeMel Oct 19, 2023
fab7348
added required permissions
ManindraDeMel Oct 19, 2023
fd6517e
Added pre-translate
ManindraDeMel Oct 19, 2023
ef3bd2a
Switched to using DeepL
ManindraDeMel Oct 21, 2023
b21d614
Added translate py file
ManindraDeMel Oct 22, 2023
5f5596b
Change to google translate
ManindraDeMel Oct 25, 2023
b1ba888
Merge branch 'OpenBMB:main' into main
ManindraDeMel Oct 26, 2023
e208188
Test crowdin integration
ManindraDeMel Oct 26, 2023
30282da
Merge branch 'main' into readme-translation
ManindraDeMel Oct 26, 2023
ab4d5e2
Merge pull request #5 from ManindraDeMel/readme-translation
ManindraDeMel Oct 26, 2023
8172b37
on push test
ManindraDeMel Oct 26, 2023
05a1dc5
add workflow dispatch
ManindraDeMel Oct 26, 2023
66d7a10
capitalize readme
ManindraDeMel Oct 26, 2023
1aedbcc
Update config
ManindraDeMel Oct 26, 2023
6b6b14a
Fix github token
ManindraDeMel Oct 26, 2023
19a2c28
change to PR to main
ManindraDeMel Oct 26, 2023
c5413ee
change to main
ManindraDeMel Oct 26, 2023
6f06ed8
change the mapping
ManindraDeMel Oct 26, 2023
1d68795
fix translations
ManindraDeMel Oct 26, 2023
8fda0ed
test on readme change
ManindraDeMel Oct 26, 2023
3d7c046
test read me merge
ManindraDeMel Oct 26, 2023
7dc2d9a
Merge pull request #8 from ManindraDeMel/test-merge-readme
ManindraDeMel Oct 26, 2023
dd1c6d2
added on merge
ManindraDeMel Oct 26, 2023
8e6fca0
Merge branch 'main' of https://github.com/ManindraDeMel/ChatDev
ManindraDeMel Oct 26, 2023
a87f2b4
Merge branch 'OpenBMB:main' into main
ManindraDeMel Oct 26, 2023
628c158
update filename mappings
ManindraDeMel Oct 26, 2023
0df38c6
Merge branch 'main' of https://github.com/ManindraDeMel/ChatDev
ManindraDeMel Oct 26, 2023
1f3ac5c
change
ManindraDeMel Oct 26, 2023
6ce7e47
add MT
ManindraDeMel Oct 26, 2023
7ab5638
add engine id
ManindraDeMel Oct 26, 2023
e1a9f04
add all lang
ManindraDeMel Oct 26, 2023
4675b76
removed branch
ManindraDeMel Oct 26, 2023
fcb60f5
added all
ManindraDeMel Oct 26, 2023
131b4cf
test for ar
ManindraDeMel Oct 26, 2023
212af9f
Added langs to translate
ManindraDeMel Oct 26, 2023
8279ae6
fixed workflow langs
ManindraDeMel Oct 26, 2023
685602b
revert git ignore changes
ManindraDeMel Oct 26, 2023
8ff6809
revert unrelated changes
ManindraDeMel Oct 26, 2023
50ee17e
removed unsupported crowdin langs
ManindraDeMel Oct 26, 2023
007d0e0
add -l? for multiple langs?
ManindraDeMel Oct 26, 2023
5f2c801
changed to two code
ManindraDeMel Oct 26, 2023
23e234f
changed swedish & portuguese
ManindraDeMel Oct 26, 2023
b24364c
removed portugese and swedish
ManindraDeMel Oct 26, 2023
e2ac5f2
learnt that korean was the problem, not the others
ManindraDeMel Oct 26, 2023
cd91f75
Merge branch 'OpenBMB:main' into main
ManindraDeMel Oct 26, 2023
a4454c5
test translation
ManindraDeMel Oct 26, 2023
5cd21a1
Merge branch 'main' of https://github.com/ManindraDeMel/ChatDev
ManindraDeMel Oct 26, 2023
0c3a044
revert readme + Combine Download & PR req
ManindraDeMel Oct 26, 2023
869dfc9
attempt to fix PR capabilities
ManindraDeMel Oct 26, 2023
4208877
update paths for readme
ManindraDeMel Oct 26, 2023
d67a259
Merge branch 'OpenBMB:main' into main
ManindraDeMel Oct 26, 2023
daf0b8d
Merge branch 'OpenBMB:main' into main
ManindraDeMel Oct 26, 2023
9d51b3f
added commit for link refactor
ManindraDeMel Oct 26, 2023
c12cb02
Merge branch 'main' of https://github.com/ManindraDeMel/ChatDev
ManindraDeMel Oct 26, 2023
ed53f7e
added git user to link refactor
ManindraDeMel Oct 26, 2023
2733742
split up git work
ManindraDeMel Oct 26, 2023
03075d6
add permissions
ManindraDeMel Oct 26, 2023
cf9e4a2
changed from https to match different quotes
ManindraDeMel Oct 26, 2023
a06b123
added docs
ManindraDeMel Oct 26, 2023
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
90 changes: 90 additions & 0 deletions .github/workflows/translate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: Translate Readme

on: # This workflow triggers on pushes and PRs to the main branch, specifically affecting the README.md
push:
branches: [ main ]
paths:
- 'README.md'
pull_request:
branches: [ main ]
paths:
- 'README.md'
workflow_dispatch: # Also provides a manual trigger option

jobs:
Translate:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write

steps:
- name: Checkout # Fetches the current repo's content
uses: actions/checkout@v3

- name: Upload to Crowdin # Uploads any changes in specified files to Crowdin
uses: crowdin/github-action@v1
with:
command: 'upload'
upload_sources: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}

- name: Apply Machine Translation # Applies machine translation to the new content in various languages
uses: crowdin/github-action@v1
with:
command: 'pre-translate'
command_args: '-l zh-CN -l nl -l fr -l ja -l ar -l pt-PT -l ru -l sv-SE -l de -l es-ES --method mt --engine-id 409836'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}

- name: Download from Crowdin # Downloads the translated files from Crowdin
uses: crowdin/github-action@v1
with:
download_translations: true
localization_branch_name: l10n_crowdin_translations
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}

- name: Set Git Identity # This sets the identity for the git user to clearly indicate that changes are made by the GitHub Action.
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"

- name: Adjust .git permissions # Adjusting permissions ensures that the GitHub Action has the required permissions to perform subsequent operations.
run: sudo chmod -R 777 .git

- name: Switch to new branch # It switches to a dedicated branch for Crowdin translations. This keeps translations separate until they're ready to be merged.
run: |
git checkout l10n_crowdin_translations

- name: Update paths for translated READMEs # This step updates the paths in the translated READMEs, ensuring links and image sources point to the correct locations.
run: |
find readme -name "README-*.md" -exec sed -i 's|href="\./|href="../|g' {} \;
find readme -name "README-*.md" -exec sed -i 's|src="\./|src="../|g' {} \;
find readme -name "README-*.md" -exec sed -i "s|href='\./|href='../|g" {} \;
find readme -name "README-*.md" -exec sed -i "s|src='\./|src='../|g" {} \;

- name: Commit changes # After updating paths, it commits and pushes the changes to the branch designated for translations.
run: |
git add -A
git commit -m "Update paths in translated READMEs"
git push origin l10n_crowdin_translations

- name: Create PR with new translations # The final step in the process is to create a Pull Request with the new translations. Once reviewed and approved, the translations can be merged into the main branch.
uses: crowdin/github-action@v1
with:
create_pull_request: true
pull_request_title: 'New Crowdin Translations'
pull_request_body: 'New Crowdin translations by [Crowdin GH Action](https://github.com/crowdin/github-action)'
pull_request_base_branch_name: 'main'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CROWDIN_PROJECT_ID: ${{ secrets.CROWDIN_PROJECT_ID }}
CROWDIN_PERSONAL_TOKEN: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
28 changes: 28 additions & 0 deletions crowdin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
"project_id_env": "CROWDIN_PROJECT_ID"
"api_token_env": "CROWDIN_PERSONAL_TOKEN"
"base_path": "."

"preserve_hierarchy": true

"files": [
{
"source": "README.md",
"translation": "readme/README-%two_letters_code%.md",
"languages_mapping": {
"two_letters_code": {
"zh-CN": "Chinese Simplified",
"nl": "Dutch",
"fr": "French",
"ja": "Japanese",
"ko": "Korean",
"es": "Spanish",
"ar": Arabic,
"pt-PT": Portuguese,
"ru", "Russian",
"sv-SE": "Swedish",
"de": "German",
"es-ES": "Spanish"
}
}
}
]
File renamed without changes.