-
Couldn't load subscription status.
- Fork 132
Added i18n component and related scripts #1082
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
base: master
Are you sure you want to change the base?
Changes from all commits
e82194a 7e793de 098de27 10856a1 4922e98 9f21e76 29f1441 f0316dc e45ede2 ba88b63 d443ffb da52eb5 3370e50 d48e425 806a152 3329c54 7a835c5 d110429 a115312 89841d6 b37b503 48fe8df 8e0e318 f0c039f b9ce30a 5f23def 429cff5 a28c5f8 c3be2c0 74a4cf5 3578a86 162b943 462bf46 cb6dce0 b40d775 e807621 851b85c 0b4097a 63e0d21 9caca4b dec7c1d 4ca88aa 8989ffa f87d8af 8cb0bd5 3637fef da45b5e 0483909 28ded1d ffdb9ae ee03f0b 4f25151 d448d72 9ca1eae 2653bd9 e6a13cf 48d7c93 ba25b24 f994790 4c118b7 23da84c 12531b3 cdf91c6 d0c95f7 fbf8f6a 4bbb406 bbe00bd f3eb480 ebeed10 3d0d5e3 7ec10f1 6f0c85c a53b54d 4125ea4 626b0d2 71395f4 1d4307e a5c1a03 92d1ce1 af25668 ea0351a b4b3c67 c44cce6 File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you explain what these new workflows are for? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This workflow is for triggering translations for all those English XMLs that are changed. The workflow is not set to be triggered on pushes yet because the AI translation is not very stable yet. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the translate-everything workflow is for translating all English XMLs |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| on: | ||
| workflow_dispatch: | ||
| workflow_call: | ||
| | ||
| concurrency: | ||
| group: translate-changed | ||
| cancel-in-progress: true | ||
| | ||
| jobs: | ||
| translate-changed: | ||
| runs-on: ubuntu-20.04 | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: cd | ||
| run: | | ||
| cd i18n | ||
| - name: Use Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 20 | ||
| cache: yarn | ||
| - name: Fetch Yarn Dependencies | ||
| run: | | ||
| yarn install | ||
| - name: Clone translated_xmls | ||
| run: | | ||
| git clone -b translated_xmls https://github.com/source-academy/sicp.git translation_output | ||
| - name: Get Changed Files | ||
| id: changed-files | ||
| uses: tj-actions/changed-files@ed68ef82c095e0d48ec87eccea555d944a631a4c # v46 | ||
| with: | ||
| files: | | ||
| xml/**.xml | ||
| - name: Create .env | ||
| run: | | ||
| touch .env | ||
| echo API_MODEL=gpt-4.1-nano >> .env | ||
| echo API_KEY=${{ secrets.OPENAI_KEY }} >> .env | ||
| # echo API_KEY=${{ secrets.OPENAI_KEY2 }} >> .env | ||
| Comment on lines +38 to +39 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If they are no longer used, the secret should be deleted. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the start of the project, me and Yi Hao were both given an API key, so there are two secrets. Now one is used as a backup. | ||
| echo MAX_LEN=5000 >> .env | ||
| echo MAX_TRANSLATION_NO=10 >> .env | ||
| echo CONTEXT=3 >> .env | ||
| echo TOKEN_WARNING=7000 >> .env | ||
| - name: Translate Changed Files | ||
| if: steps.changed-files.outputs.anychanged == 'true' | ||
| env: | ||
| CHANGED_FILES: ${{ steps.changed_files.outputs.all_changed_files }} | ||
| run: | | ||
| npx tsx index.ts "${CHANGED_FILES[@]}" | ||
| - name: Deploy | ||
| uses: peaceiris/actions-gh-pages@v4 | ||
| with: | ||
| github_token: ${{ secrets.GITHUB_TOKEN }} | ||
| publish_dir: ./translation_output | ||
| force_orphan: false # leave the possibility for direct modification on translated xmls | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| on: | ||
| workflow_dispatch: | ||
| workflow_call: | ||
| | ||
| concurrency: | ||
| group: translate-everything | ||
| cancel-in-progress: true | ||
| | ||
| jobs: | ||
| translate-everything: | ||
| runs-on: ubuntu-20.04 | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| - name: cd | ||
| run: | | ||
| cd i18n | ||
| - name: Use Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 20 | ||
| cache: yarn | ||
| - name: Fetch Yarn Dependencies | ||
| run: | | ||
| yarn install | ||
| - name: Create .env | ||
| run: | | ||
| touch .env | ||
| echo API_MODEL=gpt-4.1-nano >> .env | ||
| echo API_KEY=${{ secrets.OPENAI_KEY }} >> .env | ||
| # echo API_KEY=${{ secrets.OPENAI_KEY2 }} >> .env | ||
| Comment on lines +29 to +30 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto. | ||
| echo MAX_LEN=5000 >> .env | ||
| echo MAX_TRANSLATION_NO=10 >> .env | ||
| echo CONTEXT=3 >> .env | ||
| echo TOKEN_WARNING=7000 >> .env | ||
| - name: Run Translation | ||
| run: | | ||
| npx tsx index.ts | ||
| - name: Deploy | ||
| uses: peaceiris/actions-gh-pages@v4 | ||
| with: | ||
| github_token: ${{ secrets.GITHUB_TOKEN }} | ||
| publish_dir: ./translation_output | ||
| force_orphan: false # leave the possiblity for direct modification on translated xmls | ||
| Comment on lines +41 to +43 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you do this, it will overwrite the deployment no? | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| API_KEY= | ||
| | ||
| # Model to be used for translation | ||
| # ensure that selected assistant supports file search API | ||
| # models that are tried and shown to work includes: o3-mini, 4o and 4o mini | ||
| AI_MODEL=gpt-4.1-nano | ||
| | ||
| # maximum number of characters to be sent for translation per batch, default: 3000 | ||
| # smaller number of characters could lead to greater translation quality | ||
| # but worse continuity | ||
| MAX_LEN=5000 | ||
| | ||
| #Optional, only specify if calling alternative LLM provider | ||
| # Note: We require the Assistant API which only OpenAI provides as of 13 April 2025 | ||
| AI_BASEURL= | ||
| | ||
| # maximum number of concurent translations that are allowed | ||
| # if unspecified default to 5 | ||
| MAX_TRANSLATION_NO=10 | ||
| | ||
| # Number of previous messages to be referred to in a thread for LLM Translation, if unspecified, default to 3 | ||
| # Higher context size might lead to greater continuity in translation but higher cost and lower speed. | ||
| CONTEXT=3 | ||
| | ||
| # Number of token per query which when exceeded will log an error | ||
| # Formula to derive an adequate value: MAX_LEN * CONTEXT * k, where k is a constant | ||
| # Recommended k = 1.5 | ||
| TOKEN_WARNING=7000 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| /node_modules | ||
| /translation_output | ||
| /logs |
| There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are these files autogenerated? What is the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @RichDom2185, I have been out of the loop for a while. But I believe that ai_files are files for ai to refer to. While it hasn't been properly implemented/put to use, the plan is that it will have a folder structure that mirrors the xml/en directory where each file contains specific terms/instructions to translate the corresponding source file. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| function: 函数 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we cloning from a specific branch instead of merging it to the default branch?