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

@actionpower/i18n-spreadsheet-to-json

v0.0.33

Published

Converts a Google Sheets spreadsheet to a JSON file

Downloads

1,161

Readme

English | 한국어

English

🌐 i18n-spreadsheet-to-json

Provides functionality to parse Google Sheets data and generate and synchronize JSON files. Helps with internationalization (i18n) for applications supporting multiple languages.

Google Sheets 데이터를 파싱하여 JSON 파일을 생성 및 동기화하는 기능을 제공합니다. 여러 언어를 지원하는 애플리케이션을 위한 국제화(i18n)를 도와줍니다.

Installation

npm install @actionpower/i18n-spreadsheet-to-json --save-dev
yarn add @actionpower/i18n-spreadsheet-to-json --dev

Usage

i18nconfig.json

Library configuration is done in the i18nconfig.json file.

Create i18nconfig.json at the root path.

//example
{
  "GOOGLE_API_KEY": "YOUR_GOOGLE_API_KEY",
  "GOOGLE_SHEET_ID": "YOUR_GOOGLE_SHEET_ID",
  "targetDir": "./locales",
  "languages": ["ko", "en", "zh"]
}

| Variable | Description | Required | Default | | ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------- | ------------ | | GOOGLE_API_KEY | API key for using Google Sheets API. How to get it | required | - | | GOOGLE_SHEET_ID | 데 ID of the Google Sheets document to fetch data from. You can find it in the spreadsheet's URL. docs.google.com/spreadsheets/d/[GOOGLE_SHEET_ID]/edit?usp=sharing | required | - | | targetDir | Directory path where the parsed JSON files will be saved. | required | - | | languages | Array of supported language codes. JSON files corresponding to each language code will be created in targetDir. | optional | ["ko", "en"] |

Execution

Use the following command in the terminal to update all sheets:

npm run i18n
yarn i18n

If you specify a sheet name, only the sheet corresponding to that name will be updated.

npm run i18n [sheetName]
yarn i18n [sheetName]

Example

  • Create a spreadsheet.

⚠Ensure that the sharing access permission is set to "Anyone with the link" (Viewer). If it is set to restricted, API requests will not be possible.

  • Open the terminal in your project directory and run the yarn i18n [sheetName] command. A JSON file will be created in the targetDir specified in the i18nconfig.json file.

./locales/ko/person.json

{
  "person": {
    "address": "서울특별시 종로구 사직로 161",
    "hobbies": ["독서", "수영", "악기 연주"]
  }
}

./locales/en/person.json

{
  "person": {
    "address": "161 Sajik-ro, Jongno-gu, Seoul, South Korea",
    "hobbies": ["Reading", "Swimming", "Playing an instrument"]
  }
}

./locales/zh/person.json

{
  "person": {
    "address": "韩国首尔特别市鐘路區社稷路161号",
    "hobbies": ["阅读", "游泳", "演奏乐器"]
  }
}

한국어

설치

npm install @actionpower/i18n-spreadsheet-to-json --save-dev
yarn add @actionpower/i18n-spreadsheet-to-json --dev

사용법

i18nconfig.json

라이브러리 설정은 i18nconfig.json 파일에서 이루어집니다.

루트 경로에 i18nconfig.json을 생성합니다.

//example
{
  "GOOGLE_API_KEY": "YOUR_GOOGLE_API_KEY",
  "GOOGLE_SHEET_ID": "YOUR_GOOGLE_SHEET_ID",
  "targetDir": "./locales",
  "languages": ["ko", "en", "zh"]
}

| 변수 | 설명 | 필수 여부 | 기본값 | | ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------- | ------------ | | GOOGLE_API_KEY | Google Sheets API를 사용하기 위한 API 키입니다. 발급방법 | required | - | | GOOGLE_SHEET_ID | 데이터를 가져올 Google Sheets 문서의 ID입니다. spreadSheets의 url을 통해 ID를 알 수 있습니다. docs.google.com/spreadsheets/d/[GOOGLE_SHEET_ID]/edit?usp=sharing | required | - | | targetDir | 파싱된 JSON 파일이 저장될 디렉토리 경로입니다. | required | - | | languages | 지원하는 언어 코드의 배열입니다. 각 언어 코드에 해당하는 JSON 파일이 targetDir에 생성됩니다. | optional | ["ko", "en"] |

실행

터미널에서 아래의 명령어를 이용해 모든 스프레드 시트를 업데이트할 수 있습니다.

npm run i18n
yarn i18n

sheetName에 특정 시트 이름을 넣어 실행하면 sheetName에 해당하는 시트만 업데이트 됩니다.

npm run i18n [sheetName]
yarn i18n [sheetName]

Example

  • 스프레드 시트를 작성합니다.

⚠공유 엑세스 권한이 링크가 있는 모든 사용자(뷰어)로 되어있는지 확인해주세요. 제한됨으로 되어있으면 api 요청이 불가능합니다.

  • 프로젝트 경로에서 터미널을 열고 yarn i18n [sheetName] 명령어를 입력하면 i18nconfig.json 파일에 지정한 targetDir 경로에 [sheetName].json파일이 생성됩니다.

./locales/ko/person.json

{
  "person": {
    "address": "서울특별시 종로구 사직로 161",
    "hobbies": ["독서", "수영", "악기 연주"]
  }
}

./locales/en/person.json

{
  "person": {
    "address": "161 Sajik-ro, Jongno-gu, Seoul, South Korea",
    "hobbies": ["Reading", "Swimming", "Playing an instrument"]
  }
}

./locales/zh/person.json

{
  "person": {
    "address": "韩国首尔特别市鐘路區社稷路161号",
    "hobbies": ["阅读", "游泳", "演奏乐器"]
  }
}