mirror of
https://github.com/langgenius/dify.git
synced 2026-04-28 20:17:29 +08:00
update
This commit is contained in:
parent
bb6617491f
commit
d9a3e421eb
@ -15,24 +15,23 @@ const getSupportedLocales = (): string[] => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Helper function to load translation file content
|
// Helper function to load translation file content
|
||||||
const loadTranslationContent = (locale: string): Record<string, unknown> => {
|
const loadTranslationContent = (locale: string): string => {
|
||||||
const filePath = path.join(I18N_DIR, locale, 'app-debug.json')
|
const filePath = path.join(I18N_DIR, locale, 'app-debug.json')
|
||||||
|
|
||||||
if (!fs.existsSync(filePath))
|
if (!fs.existsSync(filePath))
|
||||||
throw new Error(`Translation file not found: ${filePath}`)
|
throw new Error(`Translation file not found: ${filePath}`)
|
||||||
|
|
||||||
return JSON.parse(fs.readFileSync(filePath, 'utf-8'))
|
return fs.readFileSync(filePath, 'utf-8')
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper function to check if upload features exist
|
// Helper function to check if upload features exist
|
||||||
const hasUploadFeatures = (content: Record<string, unknown>): { [key: string]: boolean } => {
|
const hasUploadFeatures = (content: string): { [key: string]: boolean } => {
|
||||||
const feature = content.feature as Record<string, unknown> | undefined
|
|
||||||
return {
|
return {
|
||||||
fileUpload: !!(feature?.fileUpload && typeof feature.fileUpload === 'object'),
|
fileUpload: /"fileUpload"\s*:\s*\{/.test(content),
|
||||||
imageUpload: !!(feature?.imageUpload && typeof feature.imageUpload === 'object'),
|
imageUpload: /"imageUpload"\s*:\s*\{/.test(content),
|
||||||
documentUpload: !!(feature?.documentUpload && typeof feature.documentUpload === 'object'),
|
documentUpload: /"documentUpload"\s*:\s*\{/.test(content),
|
||||||
audioUpload: !!(feature?.audioUpload && typeof feature.audioUpload === 'object'),
|
audioUpload: /"audioUpload"\s*:\s*\{/.test(content),
|
||||||
featureBar: !!(feature?.bar && typeof feature.bar === 'object'),
|
featureBar: /"bar"\s*:\s*\{/.test(content),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,15 +75,13 @@ describe('Upload Features i18n Translations - Issue #23062', () => {
|
|||||||
|
|
||||||
previouslyMissingLocales.forEach((locale) => {
|
previouslyMissingLocales.forEach((locale) => {
|
||||||
const content = loadTranslationContent(locale)
|
const content = loadTranslationContent(locale)
|
||||||
const feature = content.feature as Record<string, unknown> | undefined
|
|
||||||
const audioUpload = feature?.audioUpload as Record<string, unknown> | undefined
|
|
||||||
|
|
||||||
// Verify audioUpload exists
|
// Verify audioUpload exists
|
||||||
expect(audioUpload && typeof audioUpload === 'object').toBe(true)
|
expect(/"audioUpload"\s*:\s*\{/.test(content)).toBe(true)
|
||||||
|
|
||||||
// Verify it has title and description
|
// Verify it has title and description
|
||||||
expect(audioUpload?.title).toBeDefined()
|
expect(/"audioUpload"[^}]*"title"\s*:/.test(content)).toBe(true)
|
||||||
expect(audioUpload?.description).toBeDefined()
|
expect(/"audioUpload"[^}]*"description"\s*:/.test(content)).toBe(true)
|
||||||
|
|
||||||
console.log(`✅ ${locale} - Issue #23062 resolved: audioUpload feature present`)
|
console.log(`✅ ${locale} - Issue #23062 resolved: audioUpload feature present`)
|
||||||
})
|
})
|
||||||
@ -93,34 +90,29 @@ describe('Upload Features i18n Translations - Issue #23062', () => {
|
|||||||
it('upload features should have required properties', () => {
|
it('upload features should have required properties', () => {
|
||||||
supportedLocales.forEach((locale) => {
|
supportedLocales.forEach((locale) => {
|
||||||
const content = loadTranslationContent(locale)
|
const content = loadTranslationContent(locale)
|
||||||
const feature = content.feature as Record<string, unknown> | undefined
|
|
||||||
|
|
||||||
// Check fileUpload has required properties
|
// Check fileUpload has required properties
|
||||||
const fileUpload = feature?.fileUpload as Record<string, unknown> | undefined
|
if (/"fileUpload"\s*:\s*\{/.test(content)) {
|
||||||
if (fileUpload && typeof fileUpload === 'object') {
|
expect(/"fileUpload"[^}]*"title"\s*:/.test(content)).toBe(true)
|
||||||
expect(fileUpload.title).toBeDefined()
|
expect(/"fileUpload"[^}]*"description"\s*:/.test(content)).toBe(true)
|
||||||
expect(fileUpload.description).toBeDefined()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check imageUpload has required properties
|
// Check imageUpload has required properties
|
||||||
const imageUpload = feature?.imageUpload as Record<string, unknown> | undefined
|
if (/"imageUpload"\s*:\s*\{/.test(content)) {
|
||||||
if (imageUpload && typeof imageUpload === 'object') {
|
expect(/"imageUpload"[^}]*"title"\s*:/.test(content)).toBe(true)
|
||||||
expect(imageUpload.title).toBeDefined()
|
expect(/"imageUpload"[^}]*"description"\s*:/.test(content)).toBe(true)
|
||||||
expect(imageUpload.description).toBeDefined()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check documentUpload has required properties
|
// Check documentUpload has required properties
|
||||||
const documentUpload = feature?.documentUpload as Record<string, unknown> | undefined
|
if (/"documentUpload"\s*:\s*\{/.test(content)) {
|
||||||
if (documentUpload && typeof documentUpload === 'object') {
|
expect(/"documentUpload"[^}]*"title"\s*:/.test(content)).toBe(true)
|
||||||
expect(documentUpload.title).toBeDefined()
|
expect(/"documentUpload"[^}]*"description"\s*:/.test(content)).toBe(true)
|
||||||
expect(documentUpload.description).toBeDefined()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check audioUpload has required properties
|
// Check audioUpload has required properties
|
||||||
const audioUpload = feature?.audioUpload as Record<string, unknown> | undefined
|
if (/"audioUpload"\s*:\s*\{/.test(content)) {
|
||||||
if (audioUpload && typeof audioUpload === 'object') {
|
expect(/"audioUpload"[^}]*"title"\s*:/.test(content)).toBe(true)
|
||||||
expect(audioUpload.title).toBeDefined()
|
expect(/"audioUpload"[^}]*"description"\s*:/.test(content)).toBe(true)
|
||||||
expect(audioUpload.description).toBeDefined()
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user