This commit is contained in:
@@ -77,30 +77,33 @@ class LanguageService {
|
|||||||
if (!env.TOLGEE_API_KEY) {
|
if (!env.TOLGEE_API_KEY) {
|
||||||
throw new Error('TOLGEE_API_KEY not set')
|
throw new Error('TOLGEE_API_KEY not set')
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
const response = await fetch(url, {
|
||||||
|
method: 'GET',
|
||||||
|
headers: {
|
||||||
|
'X-API-Key': env.TOLGEE_API_KEY,
|
||||||
|
Accept: 'application/*',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
const response = await fetch(url, {
|
const zippedBuffer = await response.arrayBuffer()
|
||||||
method: 'GET',
|
|
||||||
headers: {
|
|
||||||
'X-API-Key': env.TOLGEE_API_KEY,
|
|
||||||
Accept: 'application/*',
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
const zippedBuffer = await response.arrayBuffer()
|
const zip = await loadAsync(zippedBuffer)
|
||||||
|
|
||||||
const zip = await loadAsync(zippedBuffer)
|
const translations: Record<string, TolgeeStaticData> = {}
|
||||||
|
|
||||||
const translations: Record<string, TolgeeStaticData> = {}
|
for (const [filename, file] of Object.entries(zip.files)) {
|
||||||
|
if (!file.dir && filename.endsWith('.json')) {
|
||||||
for (const [filename, file] of Object.entries(zip.files)) {
|
const content = await file.async('string')
|
||||||
if (!file.dir && filename.endsWith('.json')) {
|
const locale = filename.replace('.json', '')
|
||||||
const content = await file.async('string')
|
translations[locale] = JSON.parse(content)
|
||||||
const locale = filename.replace('.json', '')
|
}
|
||||||
translations[locale] = JSON.parse(content)
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return translations
|
return translations
|
||||||
|
} catch (e) {
|
||||||
|
console.error('Failed to get language data', e, JSON.stringify(e))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user