mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Merge pull request #13909 from overleaf/jpa-i18n-script-tweaks
[web] scripts: translateLocales: tweaks GitOrigin-RevId: 79deb3ccae9c55ab71b0e8f44fe08f240c9f695f
This commit is contained in:
parent
cce1a91205
commit
9b6dfef590
1 changed files with 13 additions and 1 deletions
|
@ -22,10 +22,14 @@ const argv = yargs(hideBin(process.argv))
|
||||||
description: 'Target 2-letter locale code',
|
description: 'Target 2-letter locale code',
|
||||||
choices: VALID_LOCALES,
|
choices: VALID_LOCALES,
|
||||||
})
|
})
|
||||||
|
.option('skip-until', {
|
||||||
|
type: 'string',
|
||||||
|
description: 'Skip locales until after the provided key',
|
||||||
|
})
|
||||||
.parse()
|
.parse()
|
||||||
|
|
||||||
async function translateLocales() {
|
async function translateLocales() {
|
||||||
const { locale } = argv
|
let { locale, skip } = argv
|
||||||
console.log(`Looking for missing [${locale}] translations...`)
|
console.log(`Looking for missing [${locale}] translations...`)
|
||||||
|
|
||||||
const keysToUploadFolder = Path.join(__dirname, `translated-keys-to-upload`)
|
const keysToUploadFolder = Path.join(__dirname, `translated-keys-to-upload`)
|
||||||
|
@ -48,6 +52,10 @@ async function translateLocales() {
|
||||||
)
|
)
|
||||||
|
|
||||||
for (const key of englishKeys) {
|
for (const key of englishKeys) {
|
||||||
|
if (skip) {
|
||||||
|
if (key === skip) skip = ''
|
||||||
|
continue
|
||||||
|
}
|
||||||
const translation = localeTranslations[key]
|
const translation = localeTranslations[key]
|
||||||
if (!translation || translation.length === 0) {
|
if (!translation || translation.length === 0) {
|
||||||
let value = await prompt(
|
let value = await prompt(
|
||||||
|
@ -58,6 +66,10 @@ async function translateLocales() {
|
||||||
`\nTranslations should not contain single-quote characters, please use curvy quotes (‘ or ’) instead:\n`
|
`\nTranslations should not contain single-quote characters, please use curvy quotes (‘ or ’) instead:\n`
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
if (!value) {
|
||||||
|
console.log(`Skipping ${key}`)
|
||||||
|
continue
|
||||||
|
}
|
||||||
localeTranslations[key] = value
|
localeTranslations[key] = value
|
||||||
|
|
||||||
const path = Path.join(LOCALES, `${locale}.json`)
|
const path = Path.join(LOCALES, `${locale}.json`)
|
||||||
|
|
Loading…
Reference in a new issue