Skip to content

Commit d76ad43

Browse files
committed
Initial scaffold for ml translation
0 parents  commit d76ad43

5 files changed

Lines changed: 138 additions & 0 deletions

File tree

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Rebase Translation PRs
2+
#
3+
# Install this workflow in the TARGET (translated) repository.
4+
# When a translation PR is merged, this workflow automatically rebases the
5+
# other open translation PRs against the updated main branch. It covers both
6+
# kinds this tool creates: `translation-sync-*` branches from the Action's sync
7+
# mode, and `resync/*` branches from the CLI's `translate forward --github`.
8+
#
9+
# This eliminates merge conflicts caused by multiple upstream PRs
10+
# modifying the same files. See: https://github.com/QuantEcon/action-translation/issues/63
11+
#
12+
# Place this file at: .github/workflows/rebase-translations.yml
13+
14+
name: Rebase Translation PRs
15+
16+
on:
17+
pull_request:
18+
types: [closed]
19+
20+
jobs:
21+
rebase:
22+
# Only run when a translation PR is merged. Both prefixes must be listed:
23+
# sync mode creates `translation-sync-*`, while the CLI's `translate forward --github`
24+
# creates `resync/*`, and a wave of resync PRs goes stale the same way.
25+
# Keep this in step with `isTranslationBranch` in the action's src/branch-naming.ts
26+
# — this `if` decides whether the job runs, that predicate decides which open PRs
27+
# it then rebases, so a prefix matching only one of them is a no-op run.
28+
# The head-repo check is belt-and-braces: fork PRs never receive secrets, so
29+
# the PAT is not exposed either way — but a merged fork PR whose branch happens
30+
# to match a prefix would otherwise start this job with an empty token and fail
31+
# red. Same-repo branches matching these prefixes only come from the tooling.
32+
if: >
33+
github.event.pull_request.merged == true &&
34+
github.event.pull_request.head.repo.full_name == github.repository &&
35+
(startsWith(github.event.pull_request.head.ref, 'translation-sync-') ||
36+
startsWith(github.event.pull_request.head.ref, 'resync/'))
37+
runs-on: ubuntu-latest
38+
39+
permissions:
40+
contents: write
41+
pull-requests: write
42+
43+
# Prevent concurrent rebases from overlapping
44+
concurrency:
45+
group: rebase-translations
46+
cancel-in-progress: false
47+
48+
steps:
49+
- name: Rebase open translation PRs
50+
uses: QuantEcon/action-translation@v0
51+
with:
52+
mode: rebase
53+
anthropic-api-key: ${{ secrets.ANTHROPIC_API_KEY }}
54+
# Commits pushed with the default GITHUB_TOKEN do not trigger workflows
55+
# (GitHub's recursion guard), so rebased/refreshed branches will get their
56+
# new commit but NO CI runs on it. If checks must re-run — and with
57+
# required checks a run-less head blocks merging — pass a PAT or App
58+
# token here instead, as the sync workflows do.
59+
github-token: ${{ secrets.GITHUB_TOKEN }}
60+
# Uncomment during a drift-recovery wave. `forward` opens one PR per lecture,
61+
# so siblings never share a file and none of them are conflict-rebased — but
62+
# every merge still leaves their checks stale. This refreshes them against the
63+
# new base without re-translating. Off by default: mid-wave it touches every
64+
# other open PR on every merge. See action-translation#123.
65+
# rebase-stale-siblings: 'true'
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Review Translation PRs
2+
#
3+
# Install this workflow in the TARGET (translated) repository at:
4+
# .github/workflows/review-translations.yml
5+
#
6+
# It posts an AI quality review on every translation PR the sync opens.
7+
# The review's target language is not an input: it is detected from the
8+
# repository-name suffix (lecture-python-intro.zh-cn -> zh-cn).
9+
#
10+
# This file is the single canonical template: `translate setup` scaffolds
11+
# new target repos from it (substituting source-repo, source-language and
12+
# docs-folder), and the docs quote the same shape. A drift test
13+
# (src/cli/__tests__/workflow-templates.test.ts) keeps every copy aligned.
14+
15+
name: Review Translations
16+
17+
on:
18+
pull_request:
19+
types: [opened, synchronize, labeled, reopened]
20+
21+
jobs:
22+
review:
23+
# `labeled` in the trigger list matters: the sync applies its labels after
24+
# opening the PR, so without it a PR labeled late is never reviewed. The
25+
# second clause then ignores `labeled` events for every OTHER label — a
26+
# sync applies labels one call at a time, and each would otherwise start
27+
# a full (billed) review of the same diff (#96).
28+
if: >
29+
contains(github.event.pull_request.labels.*.name, 'action-translation') &&
30+
(github.event.action != 'labeled' || github.event.label.name == 'action-translation')
31+
runs-on: ubuntu-latest
32+
33+
permissions:
34+
contents: read
35+
pull-requests: write
36+
37+
# One review per PR — supersede an in-flight review instead of running both
38+
concurrency:
39+
group: review-translations-${{ github.event.pull_request.number }}
40+
cancel-in-progress: true
41+
42+
steps:
43+
- uses: actions/checkout@v7
44+
with:
45+
fetch-depth: 2
46+
47+
- uses: QuantEcon/action-translation@v0
48+
with:
49+
mode: review
50+
source-repo: 'QuantEcon/lecture-python-programming'
51+
source-language: 'en'
52+
docs-folder: 'lectures'
53+
anthropic-api-key: ${{ secrets.ANTHROPIC_API_KEY }}
54+
github-token: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Build outputs
2+
_build/
3+
__pycache__/
4+
5+
# OS files
6+
.DS_Store
7+
Thumbs.db
8+
9+
# Environment
10+
.env

.translate/config.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
source-language: en
2+
target-language: ml
3+
docs-folder: lectures
4+
tool-version: 0.24.0

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# lecture-python-programming.ml
2+
3+
ml translation of [QuantEcon/lecture-python-programming](https://github.com/QuantEcon/lecture-python-programming).
4+
5+
Generated by [`translate setup`](https://github.com/QuantEcon/action-translation).

0 commit comments

Comments
 (0)