Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop separate download fallback #3395

Merged
merged 3 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions documentation/frontend/reference/i18n.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ processed and loaded into Nuxt via the Nuxt i18n module.
JED 1.x (derived from the flattened POT files) files are converted back into
the nested JSON as expected by Nuxt i18n.

This script uses the `wp-locales.json` file for the list of locales, if
downloading each locale separately and in parallel.
This script downloads all available translations in bulk as a ZIP file and
then extracts JSON files from the ZIP file. This prevents excessive calls to
GlotPress, which can be throttled and cause some locales to be missed.

**Script:** `i18n:get-translations`

Expand Down
1 change: 0 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@
"@vue/test-utils": "^1.1.3",
"adm-zip": "^0.5.10",
"autoprefixer": "^10.4.16",
"axios-rate-limit": "^1.3.0",
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "^26.6.3",
"babel-loader": "8.2.5",
Expand Down
12 changes: 3 additions & 9 deletions frontend/src/locales/scripts/axios.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
const axios = require("axios")
const rateLimit = require("axios-rate-limit")

const { userAgent } = require("../../constants/user-agent")

module.exports = rateLimit(
axios.create({
headers: { "User-Agent": userAgent },
}),
{
maxRPS: 50, // limit GlotPress calls to 50 requests per second
}
)
module.exports = module.exports = axios.create({
headers: { "User-Agent": userAgent },
})
20 changes: 7 additions & 13 deletions frontend/src/locales/scripts/get-translations.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const chokidar = require("chokidar")
const { parseJson } = require("./read-i18n")

const bulkDownload = require("./bulk-download")
const separateDownload = require("./separate-download")

/**
* Write `en.json` from `en.json5`.
Expand All @@ -37,16 +36,11 @@ if (process.argv.includes("--watch")) {
}

if (!process.argv.includes("--en-only")) {
bulkDownload()
.catch((err) => {
console.error(err)
return separateDownload()
})
.catch((err) => {
console.error(err)
console.error(":'-( Downloading translations failed.")
if (process.argv.includes("--require-complete")) {
process.exitCode = 1
}
})
bulkDownload().catch((err) => {
console.error(err)
console.error(":'-( Downloading translations failed.")
if (process.argv.includes("--require-complete")) {
process.exitCode = 1
}
})
}
57 changes: 0 additions & 57 deletions frontend/src/locales/scripts/separate-download.js

This file was deleted.

14 changes: 4 additions & 10 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading