npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

i18n-export

v1.0.11

Published

Convert between JSON and Excel files

Downloads

46

Readme

Simple Convert JSON to Excel and Back

This Node.js script offers a user-friendly tool for translating JSON files into Excel and vice versa, preserving multi-language translations.

Features

  • Effortlessly convert JSON files containing translations into a single Excel sheet.
  • Reverse the process, extracting translations from an Excel sheet back into separate JSON files for each language.
  • Supports nested objects within JSON structures.

Installation

  1. Clone this repository or download the project files.

  2. Install dependencies using npm:

    npm install -g

Usage:

Convert JSON to Excel Pass the paths to your JSON files (comma-separated) and their corresponding language codes (comma-separated) using the -f and -k flags, respectively:

i18n-export -f 'path/to/file1.json,path/to/file2.json' -k 'en,vi'

Replace path/to/file1.json and path/to/file2.json with the actual paths to your JSON files. Replace en,vi with the language codes for your JSON files (e.g., en for English, vi for Vietnamese).

The generated Excel file (output.xlsx) will have the following structure:

| KEY | en | vi | | -------------------------- | ------------------------ | ----------------------- | | confirm-employment | Confirm employment | Xác nhận việc làm | | contract-page.reset-filter | Reset filter | Xoá bộ lọc | | contract-page.normal | Normal | Bình thường | | remove-contract-success | Remove contract success! | Xóa hợp đồng thành công |

Convert Excel to JSON Provide the path to the generated Excel file (output.xlsx) using the -i flag:

i18n-import -i 'path/to/output.xlsx'

Replace path/to/output.xlsx with the actual path to your Excel file.

Two separate JSON files named vi.json and en.json will be created in your project's root directory, containing the extracted translations for each language.

Example

JSON

  • file1.json (en)
 {
   "confirm-employment": "Confirm employment",
   "contract-page": {
     "reset-filter": "Reset filter",
     "normal": "Normal"
   },
   "remove-contract-success": "Remove contract success!"
 }
  • file2.json (vi)
      {
        "confirm-employment": "Xác nhận việc làm",
        "contract-page": {
          "reset-filter": "Xoá bộ lọc",
          "normal": "Bình thường"
        },
        "remove-contract-success": "Xóa hợp đồng thành công"
      }

Command (convert to Excel)

  • i18n-export -f 'file1.json,file2.json' -k 'en,vi'

Output Excel (output.xlsx)

| KEY | en | vi | | -------------------------- | ------------------------ | ----------------------- | | confirm-employment | Confirm employment | Xác nhận việc làm | | contract-page.reset-filter | Reset filter | Xoá bộ lọc | | contract-page.normal | Normal | Bình thường | | remove-contract-success | Remove contract success! | Xóa hợp đồng thành công |

Command (convert back to JSON)

  • i18n-import -i 'output.xlsx'
  • Output JSON files (vi.json and en.json)

  • (content will be the same as the original JSON files)

[Additional Notes] The script assumes your JSON files have valid JSON syntax. Ensure the Excel file generated (output.xlsx) is not modified manually, as this may affect the JSON conversion process.