feat(SPA): media library indications for custom medial field type usage
This commit is contained in:
1 parent
3e7fc9a4a5
commit
0fc3511e2b
28 files changed
+2060
-131
No files matched your search
@@ -0,0 +1,49 @@
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { join } from 'node:path'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { messages } from './messages'
|
||||
|
||||
const SOURCES = [
|
||||
'components/MediaDetailPanel.vue',
|
||||
'components/DeleteMediaDialog.vue',
|
||||
'components/MediaCardBadges.vue',
|
||||
'components/BulkDeleteMediaDialog.vue',
|
||||
'components/MergeMediaDialog.vue',
|
||||
'lib/mediaUsage.ts',
|
||||
'lib/mediaFormat.ts',
|
||||
]
|
||||
|
||||
const SAME_IN_FRENCH = new Set<string>(['Type', 'Dimensions', '{0} copies'])
|
||||
|
||||
const LITERAL = /\bt\(\s*(?:'((?:\\.|[^'\\])*)'|"((?:\\.|[^"\\])*)")/g
|
||||
|
||||
function keysIn(source: string) {
|
||||
return [...source.matchAll(LITERAL)].map((match) =>
|
||||
(match[1] ?? match[2] ?? '').replace(/\\u0022/g, '"').replace(/\\(['"\\])/g, '$1'),
|
||||
)
|
||||
}
|
||||
|
||||
describe('Media usage messages', () => {
|
||||
const keys = SOURCES.flatMap((file) =>
|
||||
keysIn(readFileSync(join(import.meta.dirname, '..', file), 'utf8')).map((key) => ({
|
||||
file,
|
||||
key,
|
||||
})),
|
||||
)
|
||||
|
||||
it('finds the strings of the usage UI', () => {
|
||||
expect(keys.length).toBeGreaterThan(30)
|
||||
})
|
||||
|
||||
it.each(keys.map(({ file, key }) => [file, key]))(
|
||||
'%s: "%s" has its own French entry',
|
||||
(_file, key) => {
|
||||
const french = (messages as Record<string, string>)[key as string]
|
||||
|
||||
expect(french).toMatch(/\S/)
|
||||
if (!SAME_IN_FRENCH.has(key as string)) {
|
||||
expect(french).not.toBe(key)
|
||||
}
|
||||
},
|
||||
)
|
||||
})
|
||||
@@ -508,7 +508,22 @@ export const messages = {
|
||||
"This can't be undone.": 'Cette action est irréversible.',
|
||||
'None of them are used in any article. {0}': 'Aucune n’est utilisée dans un article. {0}',
|
||||
"It isn't used in any article. {0}": 'Elle n’est utilisée dans aucun article. {0}',
|
||||
'which will show a broken image.': 'qui afficheront une image manquante.',
|
||||
'which will show a broken image or a missing-image notice.':
|
||||
'qui afficheront une image manquante ou un avis d’image absente.',
|
||||
'Used in articles: {0}': 'Utilisée dans les articles : {0}',
|
||||
'Used in entries: {0}': 'Utilisée dans les entrées : {0}',
|
||||
'Used in entries': 'Utilisée dans les entrées',
|
||||
'and {0} more': 'et {0} autres',
|
||||
'1 place': '1 emplacement',
|
||||
'{0} places': '{0} emplacements',
|
||||
'No article shows it.': 'Aucun article ne l’affiche.',
|
||||
"Couldn't load where this image is used.": 'Impossible de charger où cette image est utilisée.',
|
||||
'"{0}" is used in {1} and {2}. Those entry fields will show "This image is no longer in the library", and the articles will show a broken image. This can\'t be undone.':
|
||||
'« {0} » est utilisée dans {1} et {2}. Ces champs d’entrée afficheront « Cette image n’est plus dans la bibliothèque », et les articles afficheront une image manquante. Cette action est irréversible.',
|
||||
'"{0}" is used in {1}. Those entry fields will show "This image is no longer in the library". This can\'t be undone.':
|
||||
'« {0} » est utilisée dans {1}. Ces champs d’entrée afficheront « Cette image n’est plus dans la bibliothèque ». Cette action est irréversible.',
|
||||
'"{0}" is in use. Articles will show a broken image and entry fields will show "This image is no longer in the library". This can\'t be undone.':
|
||||
'« {0} » est utilisée. Les articles afficheront une image manquante et les champs d’entrée afficheront « Cette image n’est plus dans la bibliothèque ». Cette action est irréversible.',
|
||||
'{0} of them are used in {1}, {2} {3} {4}': '{0} sont utilisées dans {1}, {2} {3} {4}',
|
||||
'{0} deleted': '{0} supprimées',
|
||||
'{0} deleted. {1} {2} still in your library. Try again.':
|
||||
|
||||
Reference in new issue
Block a user