mirror of
https://github.com/transloadit/uppy.git
synced 2026-07-21 01:15:35 +00:00
* first swing at building locale pack
* expose default locale on the plugin instance
* write a pretty en_US locale to a file, using stringify-object and template.js
* generated locale pack
* start adding a script that checks for unused locale strings
Co-Authored-By: Kevin van Zonneveld <kevin@transloadit.com>
* Update bin/build-locale-pack.js
* Console output improvements
* Also sort plugin locale keys
* Support dependencies when digging up sources
because e.g. 'emptyFolderAdded' is used in provider-views but set in Dashboard's defaultLocale
* More complex matching
So can can support cases like: `uppy.i18n(error.isAuthError ? 'companionAuthError' : 'companionError')`
* Remaining const defaultLocale -> this.defaultLocale
* Update packages/@uppy/locales/en_US.js
* Mock browser environment so all plugins can be instantiated
* Clean up output a bit
* Update bin/build-locale-pack.js
* Add all remaining plugin's locales to en_US bundle
* Update packages/@uppy/dashboard/src/index.js
* Update en_US.js
Co-Authored-By: Kevin van Zonneveld <kevin@transloadit.com>
* remove unused strings
Co-Authored-By: Kevin van Zonneveld <kevin@transloadit.com>
* Also write csv because that makes it real easy to import to friendlier places for translators /cc @arturi
* don’t set locale: this.defaultLocale — it overrides the lang pack
Co-Authored-By: Kevin van Zonneveld <kevin@transloadit.com>
* Add 'russian plural' for english, for consistency
Allows us to signal that this is possible in new target languages, and also run better linting
* Cleanup
* No longer write csv
* WIP for NL
* Create package.json
Co-Authored-By: Kevin van Zonneveld <kevin@transloadit.com>
* move locales to /src
Co-Authored-By: Kevin van Zonneveld <kevin@transloadit.com>
* ignore locales themselves
Co-Authored-By: Kevin van Zonneveld <kevin@transloadit.com>
* build minified locale packs
Co-Authored-By: Kevin van Zonneveld <kevin@transloadit.com>
* expose Uppy.locale = {} placeholder object
Co-Authored-By: Kevin van Zonneveld <kevin@transloadit.com>
* Update ru_RU.js
Co-Authored-By: Kevin van Zonneveld <kevin@transloadit.com>
* add locale bundles to example
Co-Authored-By: Kevin van Zonneveld <kevin@transloadit.com>
* Upload locales to cdn
* Allow to run tests with upload-to-cdn by setting a versionSuffix
* Move locale build to function, to make room for test()
* Bring ru_RU in sync with English
now that we've added 3 plural types across the board
* Document using locales as a consuming dev, and plugin dev
* Add linting for missing/excess locale strings
* Add the locales we had to remove to the legacy folder
and explain why they cannot make it back
* Move legacy outside of src so they are definitely not transpiled, etc
* Update packages/@uppy/locales/src/nl_NL.js
* Update website/src/docs/uppy.md
81 lines
2.3 KiB
JavaScript
81 lines
2.3 KiB
JavaScript
var fs = require('fs')
|
|
var chalk = require('chalk')
|
|
var mkdirp = require('mkdirp')
|
|
var babelify = require('babelify')
|
|
var tinyify = require('tinyify')
|
|
var browserify = require('browserify')
|
|
var exorcist = require('exorcist')
|
|
var glob = require('glob')
|
|
var path = require('path')
|
|
|
|
function handleErr (err) {
|
|
console.error(chalk.red('✗ Error:'), chalk.red(err.message))
|
|
}
|
|
|
|
function buildBundle (srcFile, bundleFile, { minify = false, standalone = '' } = {}) {
|
|
var b = browserify(srcFile, { debug: true, standalone })
|
|
if (minify) {
|
|
b.plugin(tinyify)
|
|
}
|
|
b.transform(babelify)
|
|
b.on('error', handleErr)
|
|
|
|
return new Promise(function (resolve, reject) {
|
|
b.bundle()
|
|
.pipe(exorcist(bundleFile + '.map'))
|
|
.pipe(fs.createWriteStream(bundleFile), 'utf8')
|
|
.on('error', handleErr)
|
|
.on('finish', function () {
|
|
if (minify) {
|
|
console.info(chalk.green(`✓ Built Minified Bundle [${standalone}]:`), chalk.magenta(bundleFile))
|
|
} else {
|
|
console.info(chalk.green(`✓ Built Bundle [${standalone}]:`), chalk.magenta(bundleFile))
|
|
}
|
|
resolve()
|
|
})
|
|
})
|
|
}
|
|
|
|
mkdirp.sync('./packages/uppy/dist')
|
|
mkdirp.sync('./packages/@uppy/robodog/dist')
|
|
mkdirp.sync('./packages/@uppy/locales/dist')
|
|
|
|
const methods = [
|
|
buildBundle(
|
|
'./packages/uppy/bundle.js',
|
|
'./packages/uppy/dist/uppy.js',
|
|
{ standalone: 'Uppy' }
|
|
),
|
|
buildBundle(
|
|
'./packages/uppy/bundle.js',
|
|
'./packages/uppy/dist/uppy.min.js',
|
|
{ standalone: 'Uppy', minify: true }
|
|
),
|
|
buildBundle(
|
|
'./packages/@uppy/robodog/bundle.js',
|
|
'./packages/@uppy/robodog/dist/robodog.js',
|
|
{ standalone: 'Robodog' }
|
|
),
|
|
buildBundle(
|
|
'./packages/@uppy/robodog/bundle.js',
|
|
'./packages/@uppy/robodog/dist/robodog.min.js',
|
|
{ standalone: 'Robodog', minify: true }
|
|
)
|
|
]
|
|
|
|
// Build minified versions of all the locales
|
|
const localePackagePath = path.join(__dirname, '..', 'packages', '@uppy', 'locales', 'src', '*.js')
|
|
glob.sync(localePackagePath).forEach((localePath) => {
|
|
const localeName = path.basename(localePath, '.js')
|
|
methods.push(
|
|
buildBundle(
|
|
`./packages/@uppy/locales/src/${localeName}.js`,
|
|
`./packages/@uppy/locales/dist/${localeName}.min.js`,
|
|
{ minify: true }
|
|
)
|
|
)
|
|
})
|
|
|
|
Promise.all(methods).then(function () {
|
|
console.info(chalk.yellow('✓ JS bundles 🎉'))
|
|
})
|