Explorar el Código

prepare localized slash command support

Markus-Rost hace 3 años
padre
commit
693cc5ab58

+ 53 - 0
.github/workflows/commands.yaml

@@ -0,0 +1,53 @@
+name: Update slash command localization
+on:
+  push:
+    branches: [ master ]
+    paths:
+      - 'interactions/i18n/*.json'
+  pull_request:
+    branches: [ master ]
+jobs:
+  translations:
+    runs-on: ubuntu-latest
+    steps:
+    - name: Load Repository
+      uses: actions/checkout@v2
+      with:
+        token: ${{ secrets.WIKIBOT_TOKEN }}
+    - name: Update slash commands
+      run: |
+        for language in interactions/i18n/*.json
+        do
+          language=$(basename $language .json)
+          for file in `jq -r 'keys[]' interactions/i18n/$language.json`
+          do
+            echo $file
+            for key in `jq -r ".$file | keys[]" interactions/i18n/$language.json`
+            do
+              echo $key
+              content="`jq \".$file.\\\"$key\\\"\" interactions/i18n/$language.json`"
+              echo $content
+              if [[ "$language" = "en" ]]
+              then
+                if [[ "$key" =~ description$ || "$key" =~ choices\[[0-9]+\]\.name$ ]]
+                then
+                  echo "`jq \".$key=$content\" interactions/commands/$file.json`" > interactions/commands/$file.json
+                fi
+                echo "`jq \".${key}_localizations.\\\"en-GB\\\"=$content\" interactions/commands/$file.json`" > interactions/commands/$file.json
+                echo "`jq \".${key}_localizations.\\\"en-US\\\"=$content\" interactions/commands/$file.json`" > interactions/commands/$file.json
+              else
+                echo "`jq \".${key}_localizations.$language=$content\" interactions/commands/$file.json`" > interactions/commands/$file.json
+              fi
+            done
+          done
+        done
+    - name: Commit changes
+      uses: EndBug/add-and-commit@v9
+      with:
+        author_name: WikiBot-bot
+        author_email: 69196528+WikiBot-bot@users.noreply.github.com
+        committer_name: WikiBot-bot
+        committer_email: 69196528+WikiBot-bot@users.noreply.github.com
+        message: "Update translation widgets"
+        add: "interactions/commands/*.json"
+        github_token: ${{ secrets.WIKIBOT_TOKEN }}

+ 4 - 1
.github/workflows/translations.yml

@@ -31,9 +31,12 @@ jobs:
           fi
         done
     - name: Commit changes
-      uses: EndBug/add-and-commit@v4
+      uses: EndBug/add-and-commit@v9
       with:
         author_name: WikiBot-bot
         author_email: 69196528+WikiBot-bot@users.noreply.github.com
+        committer_name: WikiBot-bot
+        committer_email: 69196528+WikiBot-bot@users.noreply.github.com
         message: "Update translation widgets"
         add: "i18n/widgets/*.png"
+        github_token: ${{ secrets.WIKIBOT_TOKEN }}

+ 24 - 0
interactions/commands/inline.json

@@ -0,0 +1,24 @@
+{
+  "id": "",
+  "application_id": "",
+  "name": "inline",
+  "name_localizations": {
+  },
+  "description": "Post a message with inline wiki links.",
+  "description_localizations": {
+  },
+  "default_permission": true,
+  "default_member_permissions": "68608",
+  "options": [
+    {
+      "type": 3,
+      "name": "text",
+      "name_localizations": {
+      },
+      "description": "Text including wikitext links.",
+      "description_localizations": {
+      },
+      "required": true
+    }
+  ]
+}

+ 24 - 0
interactions/commands/verify.json

@@ -0,0 +1,24 @@
+{
+  "id": "",
+  "application_id": "",
+  "name": "verify",
+  "name_localizations": {
+  },
+  "description": "Verify your Discord account with your wiki account.",
+  "description_localizations": {
+  },
+  "default_permission": false,
+  "default_member_permissions": "68608",
+  "options": [
+    {
+      "type": 3,
+      "name": "username",
+      "name_localizations": {
+      },
+      "description": "Your username on the wiki.",
+      "description_localizations": {
+      },
+      "required": false
+    }
+  ]
+}

+ 14 - 0
interactions/i18n/en.json

@@ -0,0 +1,14 @@
+{
+	"inline": {
+		"name": "inline",
+		"description": "Post a message with inline wiki links.",
+		"options[0].name": "text",
+		"options[0].description": "Text including wikitext links."
+	},
+	"verify": {
+		"name": "verify",
+		"description": "Verify your Discord account with your wiki account.",
+		"options[0].name": "username",
+		"options[0].description": "Your username on the wiki."
+	}
+}