Prechádzať zdrojové kódy

meta: drop `stringify-object` dependency to generate locales (#3344)

We can use `JSON.stringify` and rely on ESLint auto-fixing.
Antoine du Hamel 3 rokov pred
rodič
commit
12e2fab273

+ 1 - 1
.eslintrc.js

@@ -193,7 +193,7 @@ module.exports = {
       ],
       rules: {
         camelcase: ['off'],
-        'quote-props': ['off'],
+        'quote-props': ['error', 'as-needed', { 'numbers': true }],
       },
     },
 

+ 0 - 1
package.json

@@ -109,7 +109,6 @@
     "resolve": "^1.17.0",
     "sass": "^1.29.0",
     "size-limit": "4.5.6",
-    "stringify-object": "^3.3.0",
     "stylelint": "^13.13.1",
     "stylelint-config-rational-order": "^0.1.2",
     "stylelint-config-standard": "^22.0.0",

+ 2 - 1
packages/@uppy/locales/src/en_US.js

@@ -92,7 +92,7 @@ en_US.strings = {
   noAudioTitle: 'Microphone Not Available',
   noCameraDescription: 'In order to take pictures or record video, please connect a camera device',
   noCameraTitle: 'Camera Not Available',
-  noDuplicates: 'Cannot add the duplicate file \'%{fileName}\', it already exists',
+  noDuplicates: "Cannot add the duplicate file '%{fileName}', it already exists",
   noFilesFound: 'You have no files or folders here',
   noInternetConnection: 'No Internet connection',
   noMoreFilesAllowed: 'Cannot add more files',
@@ -139,6 +139,7 @@ en_US.strings = {
     '1': 'Select %{smart_count}',
   },
   sessionRestored: 'Session restored',
+  showErrorDetails: 'Show error details',
   signInWithGoogle: 'Sign in with Google',
   smile: 'Smile!',
   startAudioRecording: 'Begin audio recording',

+ 24 - 24
packages/@uppy/locales/src/nb_NO.js

@@ -2,8 +2,8 @@ const nb_NO = {}
 
 nb_NO.strings = {
   addBulkFilesFailed: {
-    0: 'Kunne ikke legge til %{smart_count} fil på grunn av en intern feil',
-    1: 'Kunne ikke legge til %{smart_count} filer på grunn av en intern feil',
+    '0': 'Kunne ikke legge til %{smart_count} fil på grunn av en intern feil',
+    '1': 'Kunne ikke legge til %{smart_count} filer på grunn av en intern feil',
   },
   addMore: 'Legg til',
   addMoreFiles: 'Legg til filer',
@@ -58,15 +58,15 @@ nb_NO.strings = {
   failedToUpload: 'Opplasting feilet for %{file}',
   fileSource: 'Filkilde: %{name}',
   filesUploadedOfTotal: {
-    0: '%{complete} av %{smart_count} fil opplastet',
-    1: '%{complete} av %{smart_count} filer opplastet',
+    '0': '%{complete} av %{smart_count} fil opplastet',
+    '1': '%{complete} av %{smart_count} filer opplastet',
   },
   filter: 'Filtrer',
   finishEditingFile: 'Avslutt redigering av fil',
   flipHorizontal: 'Snu horisontalt',
   folderAdded: {
-    0: 'La til %{smart_count} fil fra %{folder}',
-    1: 'La til %{smart_count} filer fra %{folder}',
+    '0': 'La til %{smart_count} fil fra %{folder}',
+    '1': 'La til %{smart_count} filer fra %{folder}',
   },
   generatingThumbnails: 'Genererer miniatyrbilde...',
   import: 'Importer',
@@ -88,8 +88,8 @@ nb_NO.strings = {
   paused: 'Midlertidig stoppet',
   poweredBy: 'Drevet av %{uppy}',
   processingXFiles: {
-    0: 'Prosesserer %{smart_count} fil',
-    1: 'Prosesserer %{smart_count} filer',
+    '0': 'Prosesserer %{smart_count} fil',
+    '1': 'Prosesserer %{smart_count} filer',
   },
   recording: 'Opptak pågår',
   recordingLength: 'Lengde på opptak: %{recording_length}',
@@ -107,8 +107,8 @@ nb_NO.strings = {
   searchImages: 'Søk etter bilder',
   selectFileNamed: 'Velg fil %{name}',
   selectX: {
-    0: 'Velg %{smart_count}',
-    1: 'Velg %{smart_count}',
+    '0': 'Velg %{smart_count}',
+    '1': 'Velg %{smart_count}',
   },
   smile: 'Smil!',
   startCapturing: 'Start skjermopptak',
@@ -126,35 +126,35 @@ nb_NO.strings = {
   uploadFailed: 'Opplasting feilet',
   uploadPaused: 'Opplasting midlertidig stoppet',
   uploadXFiles: {
-    0: 'Last opp %{smart_count} fil',
-    1: 'Last opp %{smart_count} filer',
+    '0': 'Last opp %{smart_count} fil',
+    '1': 'Last opp %{smart_count} filer',
   },
   uploadXNewFiles: {
-    0: 'Last opp +%{smart_count} fil',
-    1: 'Last opp +%{smart_count} filer',
+    '0': 'Last opp +%{smart_count} fil',
+    '1': 'Last opp +%{smart_count} filer',
   },
   uploading: 'Laster opp',
   uploadingXFiles: {
-    0: 'Laster opp %{smart_count} fil',
-    1: 'Laster opp %{smart_count} filer',
+    '0': 'Laster opp %{smart_count} fil',
+    '1': 'Laster opp %{smart_count} filer',
   },
   xFilesSelected: {
-    0: '%{smart_count} fil valgt',
-    1: '%{smart_count} filer valgt',
+    '0': '%{smart_count} fil valgt',
+    '1': '%{smart_count} filer valgt',
   },
   xMoreFilesAdded: {
-    0: '%{smart_count} fil lagt til',
-    1: '%{smart_count} filer lagt til',
+    '0': '%{smart_count} fil lagt til',
+    '1': '%{smart_count} filer lagt til',
   },
   xTimeLeft: '%{time} igjen',
   youCanOnlyUploadFileTypes: 'Du kan bare laste opp: %{types}',
   youCanOnlyUploadX: {
-    0: 'Du kan bare laste opp %{smart_count} fil',
-    1: 'Du kan bare laste opp %{smart_count} filer',
+    '0': 'Du kan bare laste opp %{smart_count} fil',
+    '1': 'Du kan bare laste opp %{smart_count} filer',
   },
   youHaveToAtLeastSelectX: {
-    0: 'Du må velge minst %{smart_count} fil',
-    1: 'Du må velge minst %{smart_count} filer',
+    '0': 'Du må velge minst %{smart_count} fil',
+    '1': 'Du må velge minst %{smart_count} filer',
   },
   zoomIn: 'Zoom inn',
   zoomOut: 'Zoom ut',

+ 22 - 22
packages/@uppy/locales/src/pt_BR.js

@@ -51,14 +51,14 @@ pt_BR.strings = {
   failedToUpload: 'Falha para enviar %{file}',
   fileSource: 'Origem do arquivo: %{name}',
   filesUploadedOfTotal: {
-    0: '%{complete} de %{smart_count} arquivo enviado',
-    1: '%{complete} de %{smart_count} arquivos enviados',
+    '0': '%{complete} de %{smart_count} arquivo enviado',
+    '1': '%{complete} de %{smart_count} arquivos enviados',
   },
   filter: 'Filtrar',
   finishEditingFile: 'Finalizar edição de arquivo',
   folderAdded: {
-    0: 'Adicionado %{smart_count} arquivo de %{folder}',
-    1: 'Adicionado %{smart_count} arquivos de %{folder}',
+    '0': 'Adicionado %{smart_count} arquivo de %{folder}',
+    '1': 'Adicionado %{smart_count} arquivos de %{folder}',
   },
   import: 'Importar',
   importFrom: 'Importar de %{name}',
@@ -72,8 +72,8 @@ pt_BR.strings = {
   paused: 'Pausado',
   poweredBy: 'Desenvolvido por %{uppy}',
   processingXFiles: {
-    0: 'Processando %{smart_count} arquivo',
-    1: 'Processando %{smart_count} arquivos',
+    '0': 'Processando %{smart_count} arquivo',
+    '1': 'Processando %{smart_count} arquivos',
   },
   removeFile: 'Remover arquivo',
   resetFilter: 'Resetar filtro',
@@ -83,8 +83,8 @@ pt_BR.strings = {
   retryUpload: 'Tentar enviar novamente',
   saveChanges: 'Salvar alterações',
   selectX: {
-    0: 'Selecionar %{smart_count}',
-    1: 'Selecionar %{smart_count}',
+    '0': 'Selecionar %{smart_count}',
+    '1': 'Selecionar %{smart_count}',
   },
   smile: 'Sorria!',
   startRecording: 'Começar gravação de vídeo',
@@ -96,35 +96,35 @@ pt_BR.strings = {
   uploadFailed: 'Envio de arquivos falhou',
   uploadPaused: 'Envio de arquivos pausado',
   uploadXFiles: {
-    0: 'Enviar %{smart_count} arquivo',
-    1: 'Enviar %{smart_count} arquivos',
+    '0': 'Enviar %{smart_count} arquivo',
+    '1': 'Enviar %{smart_count} arquivos',
   },
   uploadXNewFiles: {
-    0: 'Enviar +%{smart_count} arquivo',
-    1: 'Enviar +%{smart_count} arquivos',
+    '0': 'Enviar +%{smart_count} arquivo',
+    '1': 'Enviar +%{smart_count} arquivos',
   },
   uploading: 'Enviando',
   uploadingXFiles: {
-    0: 'Enviando %{smart_count} arquivo',
-    1: 'Enviando %{smart_count} arquivos',
+    '0': 'Enviando %{smart_count} arquivo',
+    '1': 'Enviando %{smart_count} arquivos',
   },
   xFilesSelected: {
-    0: '%{smart_count} arquivo selecionado',
-    1: '%{smart_count} arquivos selecionados',
+    '0': '%{smart_count} arquivo selecionado',
+    '1': '%{smart_count} arquivos selecionados',
   },
   xMoreFilesAdded: {
-    0: '%{smart_count} arquivo adicionados',
-    1: '%{smart_count} arquivos adicionados',
+    '0': '%{smart_count} arquivo adicionados',
+    '1': '%{smart_count} arquivos adicionados',
   },
   xTimeLeft: '%{time} restantes',
   youCanOnlyUploadFileTypes: 'Você pode enviar apenas arquivos: %{types}',
   youCanOnlyUploadX: {
-    0: 'Você pode enviar apenas %{smart_count} arquivo',
-    1: 'Você pode enviar apenas %{smart_count} arquivos',
+    '0': 'Você pode enviar apenas %{smart_count} arquivo',
+    '1': 'Você pode enviar apenas %{smart_count} arquivos',
   },
   youHaveToAtLeastSelectX: {
-    0: 'Você precisa selecionar pelo menos %{smart_count} arquivo',
-    1: 'Você precisa selecionar pelo menos %{smart_count} arquivos',
+    '0': 'Você precisa selecionar pelo menos %{smart_count} arquivo',
+    '1': 'Você precisa selecionar pelo menos %{smart_count} arquivos',
   },
   selectFileNamed: 'Selecione o arquivo %{name}',
   unselectFileNamed: 'Deselecionar arquivo %{name}',

+ 22 - 22
packages/@uppy/locales/src/pt_PT.js

@@ -51,14 +51,14 @@ pt_PT.strings = {
   failedToUpload: 'Falha ao enviar %{file}',
   fileSource: 'Origem do ficheiro: %{name}',
   filesUploadedOfTotal: {
-    0: '%{complete} de %{smart_count} ficheiro enviado',
-    1: '%{complete} de %{smart_count} ficheiros enviados',
+    '0': '%{complete} de %{smart_count} ficheiro enviado',
+    '1': '%{complete} de %{smart_count} ficheiros enviados',
   },
   filter: 'Filtrar',
   finishEditingFile: 'Concluir edição de ficheiro',
   folderAdded: {
-    0: 'Adicionado %{smart_count} ficheiro de %{folder}',
-    1: 'Adicionado %{smart_count} ficheiros de %{folder}',
+    '0': 'Adicionado %{smart_count} ficheiro de %{folder}',
+    '1': 'Adicionado %{smart_count} ficheiros de %{folder}',
   },
   import: 'Importar',
   importFrom: 'Importar de %{name}',
@@ -72,8 +72,8 @@ pt_PT.strings = {
   paused: 'Pausado',
   poweredBy: 'Desenvolvido por %{uppy}',
   processingXFiles: {
-    0: 'A processar %{smart_count} ficheiro',
-    1: 'A processar %{smart_count} ficheiros',
+    '0': 'A processar %{smart_count} ficheiro',
+    '1': 'A processar %{smart_count} ficheiros',
   },
   removeFile: 'Remover ficheiro',
   resetFilter: 'Limpar filtro',
@@ -83,8 +83,8 @@ pt_PT.strings = {
   retryUpload: 'Tentar enviar novamente',
   saveChanges: 'Salvar alterações',
   selectX: {
-    0: 'Selecionar %{smart_count}',
-    1: 'Selecionar %{smart_count}',
+    '0': 'Selecionar %{smart_count}',
+    '1': 'Selecionar %{smart_count}',
   },
   smile: 'Sorria!',
   startRecording: 'Começar gravação de vídeo',
@@ -96,35 +96,35 @@ pt_PT.strings = {
   uploadFailed: 'Envio de ficheiros falhou',
   uploadPaused: 'Envio de ficheiros pausado',
   uploadXFiles: {
-    0: 'Enviar %{smart_count} ficheiro',
-    1: 'Enviar %{smart_count} ficheiros',
+    '0': 'Enviar %{smart_count} ficheiro',
+    '1': 'Enviar %{smart_count} ficheiros',
   },
   uploadXNewFiles: {
-    0: 'Enviar +%{smart_count} ficheiro',
-    1: 'Enviar +%{smart_count} ficheiros',
+    '0': 'Enviar +%{smart_count} ficheiro',
+    '1': 'Enviar +%{smart_count} ficheiros',
   },
   uploading: 'A enviar',
   uploadingXFiles: {
-    0: 'A enviar %{smart_count} ficheiro',
-    1: 'A enviar %{smart_count} ficheiros',
+    '0': 'A enviar %{smart_count} ficheiro',
+    '1': 'A enviar %{smart_count} ficheiros',
   },
   xFilesSelected: {
-    0: '%{smart_count} ficheiro selecionado',
-    1: '%{smart_count} ficheiros selecionados',
+    '0': '%{smart_count} ficheiro selecionado',
+    '1': '%{smart_count} ficheiros selecionados',
   },
   xMoreFilesAdded: {
-    0: '%{smart_count} ficheiro adicionados',
-    1: '%{smart_count} ficheiros adicionados',
+    '0': '%{smart_count} ficheiro adicionados',
+    '1': '%{smart_count} ficheiros adicionados',
   },
   xTimeLeft: '%{time} restantes',
   youCanOnlyUploadFileTypes: 'Só pode enviar ficheiros: %{types}',
   youCanOnlyUploadX: {
-    0: 'Só pode enviar %{smart_count} ficheiro',
-    1: 'Só pode enviar %{smart_count} ficheiros',
+    '0': 'Só pode enviar %{smart_count} ficheiro',
+    '1': 'Só pode enviar %{smart_count} ficheiros',
   },
   youHaveToAtLeastSelectX: {
-    0: 'Precisa de selecionar pelo menos %{smart_count} ficheiro',
-    1: 'Precisa de selecionar pelo menos %{smart_count} ficheiros',
+    '0': 'Precisa de selecionar pelo menos %{smart_count} ficheiro',
+    '1': 'Precisa de selecionar pelo menos %{smart_count} ficheiros',
   },
   selectFileNamed: 'Selecione o ficheiro %{name}',
   unselectFileNamed: 'Deselecionar ficheiro %{name}',

+ 1 - 6
private/locale-pack/index.mjs

@@ -5,7 +5,6 @@ import { readFile, writeFile } from 'node:fs/promises'
 import { fileURLToPath } from 'node:url'
 
 import dedent from 'dedent'
-import stringifyObject from 'stringify-object'
 import { remark } from 'remark'
 import { headingRange } from 'mdast-util-heading-range'
 import remarkFrontmatter from 'remark-frontmatter'
@@ -88,11 +87,7 @@ function createCombinedLocale (locales) {
 }
 
 function populateTemplate (fileString, combinedLocale) {
-  const formattedLocale = stringifyObject(combinedLocale, {
-    indent: '  ',
-    singleQuotes: true,
-    inlineCharacterLimit: 12,
-  })
+  const formattedLocale = JSON.stringify(combinedLocale, null, ' ')
   return fileString.replace('en_US.strings = {}', `en_US.strings = ${formattedLocale}`)
 }
 

+ 1 - 2
private/locale-pack/package.json

@@ -14,7 +14,6 @@
     "glob": "^7.2.0",
     "mdast-util-heading-range": "^3.1.0",
     "remark": "^14.0.1",
-    "remark-frontmatter": "^4.0.1",
-    "stringify-object": "^4.0.0"
+    "remark-frontmatter": "^4.0.1"
   }
 }

+ 2 - 29
yarn.lock

@@ -19994,7 +19994,7 @@ __metadata:
   languageName: node
   linkType: hard
 
-"get-own-enumerable-property-symbols@npm:^3.0.0, get-own-enumerable-property-symbols@npm:^3.0.2":
+"get-own-enumerable-property-symbols@npm:^3.0.0":
   version: 3.0.2
   resolution: "get-own-enumerable-property-symbols@npm:3.0.2"
   checksum: 8f0331f14159f939830884799f937343c8c0a2c330506094bc12cbee3665d88337fe97a4ea35c002cc2bdba0f5d9975ad7ec3abb925015cdf2a93e76d4759ede
@@ -23108,13 +23108,6 @@ hexo-filter-github-emojis@arturi/hexo-filter-github-emojis:
   languageName: node
   linkType: hard
 
-"is-obj@npm:^3.0.0":
-  version: 3.0.0
-  resolution: "is-obj@npm:3.0.0"
-  checksum: 75e97a99ed0b0884778887f8e913791864151307774914283b068b06b57ca86f695b024aa1ba5ed04411918edef93e2bfd8f84d68c6b6aab417802cc76f5061b
-  languageName: node
-  linkType: hard
-
 "is-object@npm:^1.0.1":
   version: 1.0.2
   resolution: "is-object@npm:1.0.2"
@@ -23277,13 +23270,6 @@ hexo-filter-github-emojis@arturi/hexo-filter-github-emojis:
   languageName: node
   linkType: hard
 
-"is-regexp@npm:^3.0.0":
-  version: 3.1.0
-  resolution: "is-regexp@npm:3.1.0"
-  checksum: d39dbd9892f0a25d01ee1a8e650c3f2e045bf7b1fa87eafb50b31dd29342869aa9135fd372628202254398956bf7f4b62094bdda39283ec2a9bb749fbb7f427c
-  languageName: node
-  linkType: hard
-
 "is-resolvable@npm:^1.0.0, is-resolvable@npm:^1.1.0":
   version: 1.1.0
   resolution: "is-resolvable@npm:1.1.0"
@@ -25706,7 +25692,6 @@ hexo-filter-github-emojis@arturi/hexo-filter-github-emojis:
     mdast-util-heading-range: ^3.1.0
     remark: ^14.0.1
     remark-frontmatter: ^4.0.1
-    stringify-object: ^4.0.0
   languageName: unknown
   linkType: soft
 
@@ -37654,7 +37639,7 @@ hexo-filter-github-emojis@arturi/hexo-filter-github-emojis:
   languageName: node
   linkType: hard
 
-"stringify-object@npm:3.3.0, stringify-object@npm:^3.3.0":
+"stringify-object@npm:3.3.0":
   version: 3.3.0
   resolution: "stringify-object@npm:3.3.0"
   dependencies:
@@ -37665,17 +37650,6 @@ hexo-filter-github-emojis@arturi/hexo-filter-github-emojis:
   languageName: node
   linkType: hard
 
-"stringify-object@npm:^4.0.0":
-  version: 4.0.0
-  resolution: "stringify-object@npm:4.0.0"
-  dependencies:
-    get-own-enumerable-property-symbols: ^3.0.2
-    is-obj: ^3.0.0
-    is-regexp: ^3.0.0
-  checksum: 8fffae04044f0a4f7fa70e05b857750e35a54e6117cdf69cad2d1ef318ff4b0c8fec57a7731646fca0ca7c07ae723cb12edbbbc863377607aec9c83adb9ff5a3
-  languageName: node
-  linkType: hard
-
 "strip-ansi@npm:6.0.0":
   version: 6.0.0
   resolution: "strip-ansi@npm:6.0.0"
@@ -40646,7 +40620,6 @@ hexo-filter-github-emojis@arturi/hexo-filter-github-emojis:
     resolve: ^1.17.0
     sass: ^1.29.0
     size-limit: 4.5.6
-    stringify-object: ^3.3.0
     stylelint: ^13.13.1
     stylelint-config-rational-order: ^0.1.2
     stylelint-config-standard: ^22.0.0