Prechádzať zdrojové kódy

Support locale variants (#1614)

Kevin van Zonneveld 5 rokov pred
rodič
commit
f9f4b5d74b
1 zmenil súbory, kde vykonal 10 pridanie a 2 odobranie
  1. 10 2
      website/inject.js

+ 10 - 2
website/inject.js

@@ -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)
   })