commands.yaml 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. name: Update slash command localization
  2. on:
  3. push:
  4. branches: [ master ]
  5. paths:
  6. - 'interactions/i18n/*.json'
  7. jobs:
  8. translations:
  9. runs-on: ubuntu-latest
  10. steps:
  11. - name: Load Repository
  12. uses: actions/checkout@v2
  13. with:
  14. token: ${{ secrets.WIKIBOT_TOKEN }}
  15. - name: Update slash commands
  16. run: |
  17. for language in interactions/i18n/*.json
  18. do
  19. language=$(basename $language .json)
  20. for file in `jq -r 'keys[]' interactions/i18n/$language.json`
  21. do
  22. if [[ "$file" =~ ^_ ]]
  23. then
  24. continue
  25. fi
  26. echo $file
  27. for key in `jq -r ".$file | keys[]" interactions/i18n/$language.json`
  28. do
  29. echo $key
  30. content="`jq \".$file.\\\"$key\\\"\" interactions/i18n/$language.json`"
  31. if ! [[ "$key" =~ description$ || "$key" =~ choices\[[0-9]+\]\.name$ ]]
  32. then
  33. content=${content,,}
  34. fi
  35. echo $content
  36. if [[ "$language" = "en" ]]
  37. then
  38. if [[ "$key" =~ description$ || "$key" =~ choices\[[0-9]+\]\.name$ ]]
  39. then
  40. echo "`jq \".$key=$content\" interactions/commands/$file.json`" > interactions/commands/$file.json
  41. fi
  42. echo "`jq \".${key}_localizations.\\\"en-GB\\\"=$content\" interactions/commands/$file.json`" > interactions/commands/$file.json
  43. echo "`jq \".${key}_localizations.\\\"en-US\\\"=$content\" interactions/commands/$file.json`" > interactions/commands/$file.json
  44. else
  45. echo "`jq \".${key}_localizations.\\\"$language\\\"=$content\" interactions/commands/$file.json`" > interactions/commands/$file.json
  46. fi
  47. done
  48. done
  49. done
  50. - name: Commit changes
  51. uses: EndBug/add-and-commit@v9
  52. with:
  53. author_name: WikiBot-bot
  54. author_email: 69196528+WikiBot-bot@users.noreply.github.com
  55. committer_name: WikiBot-bot
  56. committer_email: 69196528+WikiBot-bot@users.noreply.github.com
  57. message: "Update slash command localization"
  58. add: "interactions/commands/*.json"
  59. github_token: ${{ secrets.WIKIBOT_TOKEN }}