i18nexus-cli
Advanced tools
Comparing version 3.3.0 to 3.3.1
@@ -64,15 +64,11 @@ const fs = require('fs'); | ||
let url = usingVersion | ||
? `https://cdn.i18nexus.com/versions/${opt.version}/translations.json` | ||
: `${baseUrl}/project_resources/translations.json`; | ||
url += `?api_key=${opt.apiKey}`; | ||
console.log(`Downloading translations to ${path}...`); | ||
const response = await handleFetch(url); | ||
const lngResponse = await handleFetch( | ||
`${baseUrl}/project_resources/languages.json?api_key=${opt.apiKey}` | ||
); | ||
if (response.status !== 200) { | ||
if (lngResponse.status !== 200) { | ||
return handleError( | ||
response, | ||
lngResponse, | ||
usingVersion | ||
@@ -84,4 +80,33 @@ ? 'There was a problem fetching your translations. Please ensure you are using the correct API key and a valid version number.' | ||
const translations = await response.json(); | ||
const languageCodes = (await lngResponse.json()).collection.map( | ||
lng => lng.full_code | ||
); | ||
const translations = {}; | ||
for (let index = 0; index < languageCodes.length; index++) { | ||
const lng = languageCodes[index]; | ||
let url = usingVersion | ||
? `https://cdn.i18nexus.com/versions/${opt.version}/translations/${lng}.json` | ||
: `${baseUrl}/project_resources/translations/${lng}.json`; | ||
url += `?api_key=${opt.apiKey}`; | ||
const response = await handleFetch(url); | ||
if (response.status !== 200) { | ||
return handleError( | ||
response, | ||
usingVersion | ||
? 'There was a problem fetching your translations. Please ensure you are using the correct API key and a valid version number.' | ||
: 'There was a problem fetching your translations. Please try again in a moment.' | ||
); | ||
} | ||
const lngTranslations = await response.json(); | ||
translations[lng] = lngTranslations; | ||
} | ||
if (opt.clean) { | ||
@@ -88,0 +113,0 @@ cleanDirectory(path); |
{ | ||
"name": "i18nexus-cli", | ||
"version": "3.3.0", | ||
"version": "3.3.1", | ||
"description": "Command line interface (CLI) for accessing the i18nexus API", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
26492
533