Support locale variants (#1614)

This commit is contained in:
Kevin van Zonneveld 2019-05-31 16:28:35 +02:00
parent 6ac5253a6f
commit f9f4b5d74b

View file

@ -191,13 +191,21 @@ function injectLocaleList () {
glob.sync(localePackagePath).forEach((localePath) => {
const localeName = path.basename(localePath, '.js')
const localeNameWithDash = localeName.replace('_', '-')
let localeNameWithDash = localeName.replace('_', '-')
const parts = localeNameWithDash.split('-')
let variant = ''
if (parts.length > 2) {
variant = parts.pop()
localeNameWithDash = parts.join('-')
}
const languageName = LocaleCode.getLanguageName(localeNameWithDash)
const countryName = LocaleCode.getCountryName(localeNameWithDash)
const npmPath = `<code><a href="https://www.npmjs.com/package/@uppy/locales">@uppy/locales</a>/lib/${localeName}</code>`
const cdnPath = `[\`${localeName}.min.js\`](https://transloadit.edgly.net/releases/uppy/v${localePackageVersion}/locales/${localeName}.min.js)`
const githubSource = `[\`${localeName}.js\`](https://github.com/transloadit/uppy/blob/master/packages/%40uppy/locales/src/${localeName}.js)`
const mdTableRow = `| ${languageName}<br/> <small>(${countryName})</small> | ${npmPath} | ${cdnPath} | ✏️ ${githubSource} |`
const mdTableRow = `| ${languageName}<br/> <small>(${countryName}${variant ? `, ${variant}` : ''})</small> | ${npmPath} | ${cdnPath} | ✏️ ${githubSource} |`
mdRows.push(mdTableRow)
})