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
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 |
- 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 전용- KO Google Cloud에서 프로젝트를 만들고 Drive API를 사용 설정합니다. · EN Create a Google Cloud project and enable the Drive API.
- KO 액세스 사용자 인증 정보(credentials)를 만들고 JSON 키 파일을 내려받습니다. · EN Create access credentials and download the JSON key file.
KO 내려받은 파일 이름을
credentials.json으로 바꿔 레포 루트(스크립트를 실행하는 폴더)에 둡니다. 처음 실행하면 브라우저에서 로그인한 뒤token.json이 만들어집니다. · EN Rename the file tocredentials.jsonand put it in the repo root (where you run the scripts). On the first run you sign in through the browser andtoken.jsonis created. - KO
templat/string_generate_templat.xlsx를 Google Drive에 올리고 Google 스프레드시트로 저장합니다. (스크립트가export_media로 내보내기 때문에 xlsx 파일 그대로는 받을 수 없습니다.) · EN Uploadtemplat/string_generate_templat.xlsxto Google Drive and save it as a Google Sheet. (The script usesexport_media, which only works on Google Sheets, not raw xlsx files.) - KO 그 파일의 ID를
download_google_drive.py의file_id변수에 넣습니다. · EN Put that file's ID into thefile_idvariable indownload_google_drive.py. - KO 실행합니다. 결과물은 위 "동작 방식"의 경로에 만들어집니다. · EN Run. Output goes to the paths shown in "How it works" above:
./android.sh # Android
./ios.sh # iOSKO 시트 이름은 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.
KO
credentials.json,token.json은 절대 커밋하지 마세요. 이 레포의.gitignore에는 두 파일과string_generate.xlsx가 이미 들어 있습니다. EN Never commitcredentials.jsonortoken.json. This repo's.gitignorealready lists both files andstring_generate.xlsx.
- KO 폴더명
templat, 파일명string_generate_templat.xlsx에 오타가 있습니다. 바꾸려면 스크립트 안의 경로도 함께 수정해야 합니다. EN The foldertemplatand filestring_generate_templat.xlsxare 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.
MIT License © 2021 Hyun Dong Han. See LICENSE.
- KO 개발 관련 글을 DN_Developer에 올리고 있습니다. → Python · Android · Tools
- EN I write about development on DN_Developer. → Python · Android · Tools