Skip to content

Commit

Permalink
Various fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
GarboMuffin committed Jan 7, 2025
1 parent c0b996d commit 6aca32d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/download-translations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
for branch in $all_branches; do
if [[ $branch == update-translations-* ]]; then
echo "Deleting branch: $branch"
GH_TOKEN="$FORK_GH_TOKEN" gh api "repos/$FORK_REPO/git/refs/heads/$branch" -X DELETE
git branch -d origin "$branch"
else
echo "Keeping branch: $branch"
fi
Expand All @@ -75,7 +75,11 @@ jobs:
git push origin "$new_branch"
# Create pull request
gh pr create --head --fill --repo "$UPSTREAM_REPO"
GH_TOKEN="$UPSTREAM_GH_TOKEN" gh pr create \
--head "$new_branch" \
--repo "$UPSTREAM_REPO" \
--title "[Automated] Update translations $(date -u "+%Y-%m-%d")" \
--body "This pull request was made by a robot."
env:
FORK_REPO: "DangoCat/extensions"
# This token has contents write permissions on fork repository
Expand Down
16 changes: 6 additions & 10 deletions development/download-translations.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,7 @@ const downloadTranslatedResource = async (resource, locale) => {
});
}

const translationsResponse = await fetch(urlToDownload, {
signal: AbortSignal.timeout(10000 * 60),
});
const translationsResponse = await fetch(urlToDownload);
const rawTranslations = await translationsResponse.json();
const withoutDeveloperComments = removeDeveloperComments(rawTranslations);
const withoutEmptyTranslations = removeEmptyTranslations(
Expand Down Expand Up @@ -193,18 +191,16 @@ const downloadAllResourceTranslations = async (resource) => {
const run = async () => {
console.log("This is going to take a while.");

const [runtimeStrings, metadataStrings] = await Promise.all([
downloadAllResourceTranslations(RUNTIME_RESOURCE),
downloadAllResourceTranslations(METADATA_RESOURCE),
]);

console.log('Downloading runtime...');
fs.writeFileSync(
pathUtil.join(__dirname, "../translations/extension-runtime.json"),
JSON.stringify(runtimeStrings, null, 4)
JSON.stringify(await downloadAllResourceTranslations(RUNTIME_RESOURCE), null, 4)
);

console.log('Downloading metadata...');
fs.writeFileSync(
pathUtil.join(__dirname, "../translations/extension-metadata.json"),
JSON.stringify(metadataStrings, null, 4)
JSON.stringify(await downloadAllResourceTranslations(METADATA_RESOURCE), null, 4)
);
};

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"lint": "eslint development extensions --max-warnings=0",
"format": "prettier . --write",
"check-format": "prettier . --check",
"upload-translations": "node development/upload-translations.js"
"upload-translations": "node development/upload-translations.js",
"download-translations": "node development/download-translations.js"
},
"repository": {
"type": "git",
Expand Down

0 comments on commit 6aca32d

Please sign in to comment.