Skip to content

About

This project automatically creates string resources for Android and ios by reading excel files in Google Drive.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Repository files navigation

StringResGenerator

License: MIT

KO Google Drive에 있는 엑셀(xlsx) 파일을 읽어 Android와 iOS용 문자열 리소스를 자동으로 만들어 주는 스크립트입니다. EN Scripts that read an Excel (xlsx) file on Google Drive and automatically generate string resources for Android and iOS.

📖 Blog / 블로그 · DN_Developer – Python 글 모음 / Python posts


How it works / 동작 방식

Google Sheets (Google Drive)
        │  download_google_drive.py  (xlsx로 내보내기 / export as xlsx)
        ▼
   ./string_generate.xlsx
        ├── xlsx2string_res_for_AOS.py  →  ./src/main/res/values*/strings_generate.xml
        └── xlsx2string_res_for_IOS.py  →  ./*.lproj/Localizable.strings

KO 출력 예시 (템플릿 기준): EN Example output (from the template):

<!-- src/main/res/values-en/strings_generate.xml -->
<resources>
   <string name="hello_world">hello world!!!</string>
</resources>
// en.lproj/Localizable.strings
"hello_world" = "hello world!!!"
File Description
download_google_drive.py KO Drive의 xlsx 다운로드 · EN Download the xlsx from Drive
xlsx2string_res_for_AOS.py KO Android 리소스 생성 (yattag 사용) · EN Generate Android resources (uses yattag)
xlsx2string_res_for_IOS.py KO iOS 리소스 생성 · EN Generate iOS resources
android.sh / ios.sh KO 다운로드 + 변환을 한 번에 실행 · EN Run download + conversion in one go
templat/ KO 엑셀 템플릿 폴더 · EN Excel template folder

Requirements / 요구사항

  • Python 3
  • pip
pip install --upgrade google-api-python-client google-auth-httplib2 google-auth-oauthlib
pip install openpyxl
pip install yattag   # Android only / Android 전용

Setup & Run / 설정과 실행

  1. KO Google Cloud에서 프로젝트를 만들고 Drive API를 사용 설정합니다. · EN Create a Google Cloud project and enable the Drive API.
  2. KO 액세스 사용자 인증 정보(credentials)를 만들고 JSON 키 파일을 내려받습니다. · EN Create access credentials and download the JSON key file. KO 내려받은 파일 이름을 credentials.json으로 바꿔 레포 루트(스크립트를 실행하는 폴더)에 둡니다. 처음 실행하면 브라우저에서 로그인한 뒤 token.json이 만들어집니다. · EN Rename the file to credentials.json and put it in the repo root (where you run the scripts). On the first run you sign in through the browser and token.json is created.
  3. KO templat/string_generate_templat.xlsx를 Google Drive에 올리고 Google 스프레드시트로 저장합니다. (스크립트가 export_media로 내보내기 때문에 xlsx 파일 그대로는 받을 수 없습니다.) · EN Upload templat/string_generate_templat.xlsx to Google Drive and save it as a Google Sheet. (The script uses export_media, which only works on Google Sheets, not raw xlsx files.)
  4. KO 그 파일의 ID를 download_google_drive.py의 file_id 변수에 넣습니다. · EN Put that file's ID into the file_id variable in download_google_drive.py.
  5. KO 실행합니다. 결과물은 위 "동작 방식"의 경로에 만들어집니다. · EN Run. Output goes to the paths shown in "How it works" above:
./android.sh   # Android
./ios.sh       # iOS

Excel format / 엑셀 형식

KO 시트 이름은 stringsheet여야 합니다. 템플릿의 주황색 영역(1~5행, B·C열)은 구조이므로 수정하지 마세요. EN The sheet must be named stringsheet. Don't edit the orange area of the template (rows 1–5, columns B–C); it defines the layout.

Row / 행 B C D E F G
3 · iOS folder ko.lproj en.lproj ja.lproj zh-Hans.lproj
4 · Android folder string_id description values values-en values-ja values-zh
5 · label 한국어 영어 일본어 중국어
6~ · strings hello_world (memo) 헬로 월드!!! hello world!!! こんにちは世界 你好世界
  • KO 6행부터 B열에 문자열 ID, D열부터 언어별 값을 적습니다. B열이 빈 칸이 나오면 거기서 읽기를 멈춥니다. EN From row 6, put the string ID in column B and per-language values from column D. Reading stops at the first empty cell in column B.
  • KO 언어를 추가하려면 G열 오른쪽에 3·4행 폴더 이름과 값을 이어서 적으면 됩니다. EN To add a language, add a column after G with the folder names in rows 3–4 and the values below.

Security / 보안

KO credentials.json, token.json은 절대 커밋하지 마세요. 이 레포의 .gitignore에는 두 파일과 string_generate.xlsx가 이미 들어 있습니다. EN Never commit credentials.json or token.json. This repo's .gitignore already lists both files and string_generate.xlsx.


Known issues / 알려진 이슈

  • KO 폴더명 templat, 파일명 string_generate_templat.xlsx에 오타가 있습니다. 바꾸려면 스크립트 안의 경로도 함께 수정해야 합니다. EN The folder templat and file string_generate_templat.xlsx are misspelled. Update the paths inside the scripts if you rename them.
  • KO 기존 README의 단계 4("Download Json Key file and call api service accept")는 설명이 부족해 위 설정 2번으로 풀어 적었습니다. EN Step 4 of the old README was too terse; it's expanded into setup step 2 above.

License / 라이선스

MIT License © 2021 Hyun Dong Han. See LICENSE.


📚 More on the blog / 블로그에서 더 보기

About

This project automatically creates string resources for Android and ios by reading excel files in Google Drive.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages