Skip to content

Commit

Permalink
chore: v1.1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
MounirAbdousNventive committed Jul 23, 2024
1 parent 125a97a commit ccc0dfd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion bin/sheet2i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const currentDir = process.cwd();
const resolvedConfigPath = path.resolve(currentDir, configPath);

try {
sheet2i18n(resolvedConfigPath);
sheet2i18n(resolvedConfigPath, currentDir);
} catch (error) {
console.error(
`Failed to execute sheet2i18n with config path: ${resolvedConfigPath}`
Expand Down
9 changes: 6 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ const fetch = require("node-fetch");
/**
* Load CSV files, parse them, and generate JSON files for localization.
* @param {string} configPath - Path to the configuration file.
* @param {string} currentDir - Path to the root folder.
*/
async function loadCsv(configPath) {
async function loadCsv(configPath, currentDir) {
const { exportPath, tabsUrl, localesKey } = require(configPath);

console.log("[+] IMPORTING LOCALES");
Expand All @@ -20,8 +21,10 @@ async function loadCsv(configPath) {
})
);

const completeExportPath = path.resolve(currentDir, exportPath);

const rows = responses.flatMap((response) => getParsedCSV(response));
await handleResponse(localesKey, rows, exportPath);
await handleResponse(localesKey, rows, completeExportPath);
} catch (error) {
console.error("Error fetching or processing CSV files:", error);
}
Expand Down Expand Up @@ -87,7 +90,7 @@ function writeTranslation(localesKey, rows, locale) {
*/
async function createJson(exportPath, locale, content) {
try {
const filePath = path.resolve(__dirname, `${exportPath}/${locale}.json`);
const filePath = `${exportPath}/${locale}.json`;
await fs.writeFile(filePath, content);
console.log(`JSON in ${locale} is saved.`);
} catch (error) {
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"name": "sheet2i18n",
"version": "1.1.0",
"version": "1.1.2",
"description": "Import locale from Google Sheet into Json file.",
"main": "index.js",
"bin": {
"sheet2i18n": "./bin/sheet2i18n.js"
"sheet2i18n": "bin/sheet2i18n.js"
},
"scripts": {
"start": "node bin/sheet2i18n.js"
},
"repository": {
"type": "git",
"url": "https://github.com/AbdousMounir/sheet2i18n.git"
"url": "git+https://github.com/AbdousMounir/sheet2i18n.git"
},
"dependencies": {
"csv-parse": "^5.5.6"
Expand Down

0 comments on commit ccc0dfd

Please sign in to comment.