You've already forked AstralRinth
forked from didirus/AstralRinth
Add handling for locale files parsing errors (#1408)
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
import { promises as fs } from 'fs'
|
||||
import { pathToFileURL } from 'node:url'
|
||||
import svgLoader from 'vite-svg-loader'
|
||||
import { resolve, basename } from 'pathe'
|
||||
import { resolve, basename, relative } from 'pathe'
|
||||
import { defineNuxtConfig } from 'nuxt/config'
|
||||
import { $fetch } from 'ofetch'
|
||||
import { globIterate } from 'glob'
|
||||
import { match as matchLocale } from '@formatjs/intl-localematcher'
|
||||
import { consola } from 'consola'
|
||||
|
||||
const STAGING_API_URL = 'https://staging-api.modrinth.com/v2/'
|
||||
|
||||
@@ -310,6 +311,31 @@ export default defineNuxtConfig({
|
||||
seo: {
|
||||
defaultLocaleHasParameter: false,
|
||||
},
|
||||
onParseError({ error, message, messageId, moduleId, parseMessage, parserOptions }) {
|
||||
const errorMessage = String(error)
|
||||
const modulePath = relative(__dirname, moduleId)
|
||||
|
||||
try {
|
||||
const fallback = parseMessage(message, { ...parserOptions, ignoreTag: true })
|
||||
|
||||
consola.warn(
|
||||
`[i18n] ${messageId} in ${modulePath} cannot be parsed normally due to ${errorMessage}. The tags will will not be parsed.`
|
||||
)
|
||||
|
||||
return fallback
|
||||
} catch (err) {
|
||||
const secondaryErrorMessage = String(err)
|
||||
|
||||
const reason =
|
||||
errorMessage === secondaryErrorMessage
|
||||
? errorMessage
|
||||
: `${errorMessage} and ${secondaryErrorMessage}`
|
||||
|
||||
consola.warn(
|
||||
`[i18n] ${messageId} in ${modulePath} cannot be parsed due to ${reason}. It will be skipped.`
|
||||
)
|
||||
}
|
||||
},
|
||||
},
|
||||
turnstile: {
|
||||
siteKey: '0x4AAAAAAAHWfmKCm7cUG869',
|
||||
|
||||
@@ -19,9 +19,9 @@
|
||||
"@types/node": "^20.1.0",
|
||||
"@typescript-eslint/eslint-plugin": "^5.59.8",
|
||||
"@typescript-eslint/parser": "^5.59.8",
|
||||
"@vintl/compact-number": "^2.0.4",
|
||||
"@vintl/compact-number": "^2.0.5",
|
||||
"@vintl/how-ago": "^3.0.1",
|
||||
"@vintl/nuxt": "^1.5.0",
|
||||
"@vintl/nuxt": "^1.7.0",
|
||||
"eslint": "^8.41.0",
|
||||
"eslint-config-prettier": "^8.8.0",
|
||||
"eslint-import-resolver-typescript": "^3.5.5",
|
||||
|
||||
657
pnpm-lock.yaml
generated
657
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user