mirror of
https://github.com/transloadit/uppy.git
synced 2026-07-17 16:50:22 +00:00
build: harden locale pack check for unused or duplicate key (#3081)
This commit is contained in:
parent
10f595e3a8
commit
d94c7d1232
2 changed files with 12 additions and 0 deletions
|
|
@ -128,6 +128,7 @@ function addLocaleToPack (localePack, plugin, pluginName) {
|
|||
console.error(` Value in plugin: ${chalk.cyan(valueInPlugin)}`)
|
||||
console.error(` Value in pack : ${chalk.yellow(valueInPack)}`)
|
||||
console.error()
|
||||
throw new Error(`Duplicate locale key: '${key}'`)
|
||||
}
|
||||
localePack[key] = localeStrings[key] // eslint-disable-line no-param-reassign
|
||||
}
|
||||
|
|
@ -139,6 +140,7 @@ function checkForUnused (fileContents, pluginName, localePack) {
|
|||
const regPat = new RegExp(`(i18n|i18nArray)\\([^\\)]*['\`"]${key}['\`"]`, 'g')
|
||||
if (!buff.match(regPat)) {
|
||||
console.error(`⚠ defaultLocale key: ${chalk.magenta(key)} not used in plugin: ${chalk.cyan(pluginName)}`)
|
||||
throw new Error(`Unused locale key: '${key}'`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -174,6 +174,16 @@ class AddFiles extends Component {
|
|||
)
|
||||
}
|
||||
|
||||
[Symbol.for('uppy test: disable unused locale key warning')] () {
|
||||
// Those are actually used in `renderDropPasteBrowseTagline` method.
|
||||
this.props.i18nArray('dropPasteBoth')
|
||||
this.props.i18nArray('dropPasteFiles')
|
||||
this.props.i18nArray('dropPasteFolders')
|
||||
this.props.i18nArray('dropPasteImportBoth')
|
||||
this.props.i18nArray('dropPasteImportFiles')
|
||||
this.props.i18nArray('dropPasteImportFolders')
|
||||
}
|
||||
|
||||
renderAcquirer = (acquirer) => {
|
||||
return (
|
||||
<div
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue