diff --git a/src/lib/server/LanguageService.ts b/src/lib/server/LanguageService.ts index d52b1a9..34c3e46 100644 --- a/src/lib/server/LanguageService.ts +++ b/src/lib/server/LanguageService.ts @@ -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 = {} - const translations: Record = {} - - 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)) + } } }