mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-01 00:43:15 +00:00
fix(ci): the file import's words resolve through t, the unused key count drops
The KML skip reasons and the file errors were looked up from plain maps, which lint:i18n-keys cannot follow, so the new map keys counted as unused. Both are switches over t() now; the older file error keys are reached as well, so collection.ts holds 29 unused keys instead of 35.
This commit is contained in:
@@ -35,14 +35,22 @@ interface ImportCollectionModalProps {
|
||||
t: TranslationFn
|
||||
}
|
||||
|
||||
/** Keyed by the error type, so a new way for a file to fail does not build without its words. */
|
||||
const ERROR_KEYS: Record<CollectionFileError, string> = {
|
||||
'too-large': 'collections.file.errorTooLarge',
|
||||
unreadable: 'collections.file.errorUnreadable',
|
||||
'not-a-collection': 'collections.file.errorNotACollection',
|
||||
'not-gpx': 'collections.file.errorNotGpx',
|
||||
'not-map': 'collections.file.errorNotMap',
|
||||
'too-many-places': 'collections.file.errorTooManyPlaces',
|
||||
/** The words for each way a file can fail; a switch, so a new way does not build without its words. */
|
||||
function errorText(error: CollectionFileError, t: TranslationFn, count: number): string {
|
||||
switch (error) {
|
||||
case 'too-large':
|
||||
return t('collections.file.errorTooLarge')
|
||||
case 'unreadable':
|
||||
return t('collections.file.errorUnreadable')
|
||||
case 'not-a-collection':
|
||||
return t('collections.file.errorNotACollection')
|
||||
case 'not-gpx':
|
||||
return t('collections.file.errorNotGpx')
|
||||
case 'not-map':
|
||||
return t('collections.file.errorNotMap')
|
||||
case 'too-many-places':
|
||||
return t('collections.file.errorTooManyPlaces', { count })
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -270,7 +278,7 @@ export default function ImportCollectionModal({
|
||||
|
||||
const errorText = error === 'failed'
|
||||
? (failedMessage ?? t('common.error'))
|
||||
: error ? t(ERROR_KEYS[error], { count: MAX_COLLECTION_FILE_PLACES }) : null
|
||||
: error ? errorText(error, t, MAX_COLLECTION_FILE_PLACES) : null
|
||||
|
||||
// A GPX of nothing but a track would make an empty list, which is never what was meant.
|
||||
const nothingToImport = (!!leftovers || !!map) && !!file && (map ? picked.size === 0 : file.places.length === 0)
|
||||
|
||||
Reference in New Issue
Block a user