You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

translate-i18n-base-on-english.yml 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. name: Check i18n Files and Create PR
  2. on:
  3. push:
  4. branches: [main]
  5. paths:
  6. - 'web/i18n/en-US/*.ts'
  7. permissions:
  8. contents: write
  9. pull-requests: write
  10. jobs:
  11. check-and-update:
  12. if: github.repository == 'langgenius/dify'
  13. runs-on: ubuntu-latest
  14. defaults:
  15. run:
  16. working-directory: web
  17. steps:
  18. - uses: actions/checkout@v4
  19. with:
  20. fetch-depth: 2
  21. token: ${{ secrets.GITHUB_TOKEN }}
  22. - name: Check for file changes in i18n/en-US
  23. id: check_files
  24. run: |
  25. recent_commit_sha=$(git rev-parse HEAD)
  26. second_recent_commit_sha=$(git rev-parse HEAD~1)
  27. changed_files=$(git diff --name-only $recent_commit_sha $second_recent_commit_sha -- 'i18n/en-US/*.ts')
  28. echo "Changed files: $changed_files"
  29. if [ -n "$changed_files" ]; then
  30. echo "FILES_CHANGED=true" >> $GITHUB_ENV
  31. file_args=""
  32. for file in $changed_files; do
  33. filename=$(basename "$file" .ts)
  34. file_args="$file_args --file=$filename"
  35. done
  36. echo "FILE_ARGS=$file_args" >> $GITHUB_ENV
  37. echo "File arguments: $file_args"
  38. else
  39. echo "FILES_CHANGED=false" >> $GITHUB_ENV
  40. fi
  41. - name: Install pnpm
  42. uses: pnpm/action-setup@v4
  43. with:
  44. version: 10
  45. run_install: false
  46. - name: Set up Node.js
  47. if: env.FILES_CHANGED == 'true'
  48. uses: actions/setup-node@v4
  49. with:
  50. node-version: 'lts/*'
  51. cache: pnpm
  52. cache-dependency-path: ./web/package.json
  53. - name: Install dependencies
  54. if: env.FILES_CHANGED == 'true'
  55. run: pnpm install --frozen-lockfile
  56. - name: Generate i18n translations
  57. if: env.FILES_CHANGED == 'true'
  58. run: pnpm run auto-gen-i18n ${{ env.FILE_ARGS }}
  59. - name: Create Pull Request
  60. if: env.FILES_CHANGED == 'true'
  61. uses: peter-evans/create-pull-request@v6
  62. with:
  63. token: ${{ secrets.GITHUB_TOKEN }}
  64. commit-message: Update i18n files based on en-US changes
  65. title: 'chore: translate i18n files'
  66. body: This PR was automatically created to update i18n files based on changes in en-US locale.
  67. branch: chore/automated-i18n-updates