This commit is contained in:
@@ -77,30 +77,33 @@ class LanguageService {
|
||||
if (!env.TOLGEE_API_KEY) {
|
||||
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, {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'X-API-Key': env.TOLGEE_API_KEY,
|
||||
Accept: 'application/*',
|
||||
},
|
||||
})
|
||||
const zippedBuffer = await response.arrayBuffer()
|
||||
|
||||
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')) {
|
||||
const content = await file.async('string')
|
||||
const locale = filename.replace('.json', '')
|
||||
translations[locale] = JSON.parse(content)
|
||||
for (const [filename, file] of Object.entries(zip.files)) {
|
||||
if (!file.dir && filename.endsWith('.json')) {
|
||||
const content = await file.async('string')
|
||||
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