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.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. package_json_file: web/package.json
  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. working-directory: ./web
  56. run: pnpm install --frozen-lockfile
  57. - name: Generate i18n translations
  58. if: env.FILES_CHANGED == 'true'
  59. working-directory: ./web
  60. run: pnpm run auto-gen-i18n ${{ env.FILE_ARGS }}
  61. - name: Create Pull Request
  62. if: env.FILES_CHANGED == 'true'
  63. uses: peter-evans/create-pull-request@v6
  64. with:
  65. token: ${{ secrets.GITHUB_TOKEN }}
  66. commit-message: Update i18n files based on en-US changes
  67. title: 'chore: translate i18n files'
  68. body: This PR was automatically created to update i18n files based on changes in en-US locale.
  69. branch: chore/automated-i18n-updates