mods-string-extractor 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,33 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ push:
5
+ tags:
6
+ - "v*"
7
+
8
+ permissions:
9
+ id-token: write
10
+
11
+ jobs:
12
+ publish:
13
+ name: Build and publish to PyPI
14
+ runs-on: ubuntu-latest
15
+ environment:
16
+ name: pypi
17
+ url: https://pypi.org/p/mods-string-extractor
18
+ steps:
19
+ - uses: actions/checkout@v4
20
+
21
+ - name: Install uv
22
+ uses: astral-sh/setup-uv@v5
23
+
24
+ - name: Set up Python
25
+ uses: actions/setup-python@v5
26
+ with:
27
+ python-version-file: "pyproject.toml"
28
+
29
+ - name: Build package
30
+ run: uv build
31
+
32
+ - name: Publish to PyPI
33
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,211 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[codz]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py.cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ #uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ #poetry.lock
109
+ #poetry.toml
110
+
111
+ # pdm
112
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
113
+ # pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
114
+ # https://pdm-project.org/en/latest/usage/project/#working-with-version-control
115
+ #pdm.lock
116
+ #pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # pixi
121
+ # Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
122
+ #pixi.lock
123
+ # Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
124
+ # in the .venv directory. It is recommended not to include this directory in version control.
125
+ .pixi
126
+
127
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
128
+ __pypackages__/
129
+
130
+ # Celery stuff
131
+ celerybeat-schedule
132
+ celerybeat.pid
133
+
134
+ # SageMath parsed files
135
+ *.sage.py
136
+
137
+ # Environments
138
+ .env
139
+ .envrc
140
+ .venv
141
+ env/
142
+ venv/
143
+ ENV/
144
+ env.bak/
145
+ venv.bak/
146
+
147
+ # Spyder project settings
148
+ .spyderproject
149
+ .spyproject
150
+
151
+ # Rope project settings
152
+ .ropeproject
153
+
154
+ # mkdocs documentation
155
+ /site
156
+
157
+ # mypy
158
+ .mypy_cache/
159
+ .dmypy.json
160
+ dmypy.json
161
+
162
+ # Pyre type checker
163
+ .pyre/
164
+
165
+ # pytype static type analyzer
166
+ .pytype/
167
+
168
+ # Cython debug symbols
169
+ cython_debug/
170
+
171
+ # PyCharm
172
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
173
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
174
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
175
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
176
+ #.idea/
177
+
178
+ # Abstra
179
+ # Abstra is an AI-powered process automation framework.
180
+ # Ignore directories containing user credentials, local state, and settings.
181
+ # Learn more at https://abstra.io/docs
182
+ .abstra/
183
+
184
+ # Visual Studio Code
185
+ # Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
186
+ # that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
187
+ # and can be added to the global gitignore or merged into this file. However, if you prefer,
188
+ # you could uncomment the following to ignore the entire vscode folder
189
+ # .vscode/
190
+
191
+ # Ruff stuff:
192
+ .ruff_cache/
193
+
194
+ # PyPI configuration file
195
+ .pypirc
196
+
197
+ # Cursor
198
+ # Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
199
+ # exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
200
+ # refer to https://docs.cursor.com/context/ignore-files
201
+ .cursorignore
202
+ .cursorindexingignore
203
+
204
+ # Marimo
205
+ marimo/_static/
206
+ marimo/_lsp/
207
+ __marimo__/
208
+
209
+ output/
210
+ extracted/
211
+ *.zip
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ziqi Zhu
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,111 @@
1
+ Metadata-Version: 2.4
2
+ Name: mods-string-extractor
3
+ Version: 1.0.0
4
+ Summary: Extract translatable strings from Minecraft modpack mods and pack translations into resource packs
5
+ Project-URL: Homepage, https://github.com/zack-zzq/mods-string-extractor
6
+ Project-URL: Repository, https://github.com/zack-zzq/mods-string-extractor
7
+ Project-URL: Issues, https://github.com/zack-zzq/mods-string-extractor/issues
8
+ Author: zack-zzq
9
+ License: MIT
10
+ License-File: LICENSE
11
+ Keywords: i18n,minecraft,modpack,resource-pack,translation
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Topic :: Games/Entertainment
21
+ Requires-Python: >=3.10
22
+ Description-Content-Type: text/markdown
23
+
24
+ # Mods String Extractor
25
+
26
+ [![PyPI version](https://badge.fury.io/py/mods-string-extractor.svg)](https://pypi.org/project/mods-string-extractor/)
27
+
28
+ 从 Minecraft modpack 的 mods 中提取待翻译字符串,并在翻译完成后一键打包成资源包。
29
+
30
+ ## 功能
31
+
32
+ - 🔍 **自动扫描** mods 目录下所有 `.jar` 文件
33
+ - 🌐 **智能提取** 待翻译字符串:
34
+ - 如果 mod 已有 `zh_cn.json`,只提取 `en_us.json` 与 `zh_cn.json` 的差集
35
+ - 如果 mod 没有 `zh_cn.json`,全量提取 `en_us.json`
36
+ - 📦 **一键打包** 翻译好的字符串为 Minecraft 资源包
37
+
38
+ ## 安装
39
+
40
+ ```bash
41
+ pip install mods-string-extractor
42
+ ```
43
+
44
+ 或使用 uv:
45
+
46
+ ```bash
47
+ uv tool install mods-string-extractor
48
+ ```
49
+
50
+ ## 使用方法
51
+
52
+ ### 1. 提取待翻译字符串
53
+
54
+ ```bash
55
+ mods-string-extractor extract --mods /path/to/mods --output ./extracted
56
+ ```
57
+
58
+ 提取后的文件结构:
59
+
60
+ ```
61
+ extracted/
62
+ ├── ae2/
63
+ │ └── en_us.json
64
+ ├── create/
65
+ │ └── en_us.json
66
+ ├── mekanism/
67
+ │ └── en_us.json
68
+ └── ...
69
+ ```
70
+
71
+ ### 2. 翻译
72
+
73
+ 编辑 `extracted/` 中的 `en_us.json` 文件,将英文值替换为中文翻译。
74
+
75
+ ### 3. 打包资源包
76
+
77
+ ```bash
78
+ mods-string-extractor pack --input ./extracted --output translation_pack.zip
79
+ ```
80
+
81
+ 可选参数:
82
+
83
+ ```bash
84
+ mods-string-extractor pack \
85
+ --input ./extracted \
86
+ --output translation_pack.zip \
87
+ --pack-format 34 \
88
+ --description "My Translation Pack"
89
+ ```
90
+
91
+ ### 4. 使用资源包
92
+
93
+ 将生成的 `.zip` 文件放入 Minecraft 的 `resourcepacks` 目录即可。
94
+
95
+ ## 开发
96
+
97
+ ```bash
98
+ # 克隆项目
99
+ git clone https://github.com/zack-zzq/mods-string-extractor.git
100
+ cd mods-string-extractor
101
+
102
+ # 安装开发依赖
103
+ uv sync
104
+
105
+ # 运行测试
106
+ uv run pytest tests/ -v
107
+ ```
108
+
109
+ ## License
110
+
111
+ MIT
@@ -0,0 +1,88 @@
1
+ # Mods String Extractor
2
+
3
+ [![PyPI version](https://badge.fury.io/py/mods-string-extractor.svg)](https://pypi.org/project/mods-string-extractor/)
4
+
5
+ 从 Minecraft modpack 的 mods 中提取待翻译字符串,并在翻译完成后一键打包成资源包。
6
+
7
+ ## 功能
8
+
9
+ - 🔍 **自动扫描** mods 目录下所有 `.jar` 文件
10
+ - 🌐 **智能提取** 待翻译字符串:
11
+ - 如果 mod 已有 `zh_cn.json`,只提取 `en_us.json` 与 `zh_cn.json` 的差集
12
+ - 如果 mod 没有 `zh_cn.json`,全量提取 `en_us.json`
13
+ - 📦 **一键打包** 翻译好的字符串为 Minecraft 资源包
14
+
15
+ ## 安装
16
+
17
+ ```bash
18
+ pip install mods-string-extractor
19
+ ```
20
+
21
+ 或使用 uv:
22
+
23
+ ```bash
24
+ uv tool install mods-string-extractor
25
+ ```
26
+
27
+ ## 使用方法
28
+
29
+ ### 1. 提取待翻译字符串
30
+
31
+ ```bash
32
+ mods-string-extractor extract --mods /path/to/mods --output ./extracted
33
+ ```
34
+
35
+ 提取后的文件结构:
36
+
37
+ ```
38
+ extracted/
39
+ ├── ae2/
40
+ │ └── en_us.json
41
+ ├── create/
42
+ │ └── en_us.json
43
+ ├── mekanism/
44
+ │ └── en_us.json
45
+ └── ...
46
+ ```
47
+
48
+ ### 2. 翻译
49
+
50
+ 编辑 `extracted/` 中的 `en_us.json` 文件,将英文值替换为中文翻译。
51
+
52
+ ### 3. 打包资源包
53
+
54
+ ```bash
55
+ mods-string-extractor pack --input ./extracted --output translation_pack.zip
56
+ ```
57
+
58
+ 可选参数:
59
+
60
+ ```bash
61
+ mods-string-extractor pack \
62
+ --input ./extracted \
63
+ --output translation_pack.zip \
64
+ --pack-format 34 \
65
+ --description "My Translation Pack"
66
+ ```
67
+
68
+ ### 4. 使用资源包
69
+
70
+ 将生成的 `.zip` 文件放入 Minecraft 的 `resourcepacks` 目录即可。
71
+
72
+ ## 开发
73
+
74
+ ```bash
75
+ # 克隆项目
76
+ git clone https://github.com/zack-zzq/mods-string-extractor.git
77
+ cd mods-string-extractor
78
+
79
+ # 安装开发依赖
80
+ uv sync
81
+
82
+ # 运行测试
83
+ uv run pytest tests/ -v
84
+ ```
85
+
86
+ ## License
87
+
88
+ MIT
@@ -0,0 +1,42 @@
1
+ [project]
2
+ name = "mods-string-extractor"
3
+ version = "1.0.0"
4
+ description = "Extract translatable strings from Minecraft modpack mods and pack translations into resource packs"
5
+ readme = "README.md"
6
+ license = { text = "MIT" }
7
+ requires-python = ">=3.10"
8
+ authors = [
9
+ { name = "zack-zzq" },
10
+ ]
11
+ keywords = ["minecraft", "modpack", "translation", "i18n", "resource-pack"]
12
+ classifiers = [
13
+ "Development Status :: 4 - Beta",
14
+ "Intended Audience :: Developers",
15
+ "License :: OSI Approved :: MIT License",
16
+ "Programming Language :: Python :: 3",
17
+ "Programming Language :: Python :: 3.10",
18
+ "Programming Language :: Python :: 3.11",
19
+ "Programming Language :: Python :: 3.12",
20
+ "Programming Language :: Python :: 3.13",
21
+ "Topic :: Games/Entertainment",
22
+ ]
23
+
24
+ [project.scripts]
25
+ mods-string-extractor = "mods_string_extractor.cli:main"
26
+
27
+ [project.urls]
28
+ Homepage = "https://github.com/zack-zzq/mods-string-extractor"
29
+ Repository = "https://github.com/zack-zzq/mods-string-extractor"
30
+ Issues = "https://github.com/zack-zzq/mods-string-extractor/issues"
31
+
32
+ [build-system]
33
+ requires = ["hatchling"]
34
+ build-backend = "hatchling.build"
35
+
36
+ [tool.hatch.build.targets.wheel]
37
+ packages = ["src/mods_string_extractor"]
38
+
39
+ [dependency-groups]
40
+ dev = [
41
+ "pytest>=8.0",
42
+ ]
@@ -0,0 +1,3 @@
1
+ """Extract translatable strings from Minecraft modpack mods and pack translations into resource packs."""
2
+
3
+ __version__ = "0.1.0"
@@ -0,0 +1,137 @@
1
+ """Command-line interface for mods-string-extractor."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import argparse
6
+ import logging
7
+ import sys
8
+ from pathlib import Path
9
+
10
+ from . import __version__
11
+ from .extractor import extract_mods
12
+ from .packer import DEFAULT_DESCRIPTION, DEFAULT_PACK_FORMAT, pack_resourcepack
13
+
14
+
15
+ def _setup_logging(verbose: bool = False) -> None:
16
+ level = logging.DEBUG if verbose else logging.INFO
17
+ logging.basicConfig(
18
+ level=level,
19
+ format="%(levelname)s: %(message)s",
20
+ )
21
+
22
+
23
+ def cmd_extract(args: argparse.Namespace) -> int:
24
+ """Handle the 'extract' subcommand."""
25
+ mods_dir = Path(args.mods)
26
+ output_dir = Path(args.output)
27
+
28
+ try:
29
+ results = extract_mods(mods_dir, output_dir)
30
+ except FileNotFoundError as e:
31
+ logging.error(str(e))
32
+ return 1
33
+
34
+ total_namespaces = sum(len(r.namespaces) for r in results)
35
+ total_keys = sum(r.total_keys for r in results)
36
+
37
+ print(f"\n✅ Extraction complete!")
38
+ print(f" Mods scanned: {len(results)}")
39
+ print(f" Namespaces: {total_namespaces}")
40
+ print(f" Keys extracted: {total_keys}")
41
+ print(f" Output: {output_dir.resolve()}")
42
+ return 0
43
+
44
+
45
+ def cmd_pack(args: argparse.Namespace) -> int:
46
+ """Handle the 'pack' subcommand."""
47
+ input_dir = Path(args.input)
48
+ output_file = Path(args.output)
49
+
50
+ try:
51
+ file_count = pack_resourcepack(
52
+ input_dir,
53
+ output_file,
54
+ pack_format=args.pack_format,
55
+ description=args.description,
56
+ )
57
+ except FileNotFoundError as e:
58
+ logging.error(str(e))
59
+ return 1
60
+
61
+ print(f"\n✅ Resource pack created!")
62
+ print(f" Language files: {file_count}")
63
+ print(f" Output: {output_file.resolve()}")
64
+ return 0
65
+
66
+
67
+ def main(argv: list[str] | None = None) -> int:
68
+ parser = argparse.ArgumentParser(
69
+ prog="mods-string-extractor",
70
+ description="Extract translatable strings from Minecraft modpack mods and pack translations into resource packs.",
71
+ )
72
+ parser.add_argument(
73
+ "--version", action="version", version=f"%(prog)s {__version__}"
74
+ )
75
+ parser.add_argument(
76
+ "-v", "--verbose", action="store_true", help="Enable verbose output"
77
+ )
78
+
79
+ subparsers = parser.add_subparsers(dest="command", required=True)
80
+
81
+ # extract subcommand
82
+ extract_parser = subparsers.add_parser(
83
+ "extract",
84
+ help="Extract translatable strings from mod jars",
85
+ )
86
+ extract_parser.add_argument(
87
+ "--mods",
88
+ required=True,
89
+ help="Path to the mods directory containing .jar files",
90
+ )
91
+ extract_parser.add_argument(
92
+ "--output",
93
+ required=True,
94
+ help="Path to the output directory for extracted strings",
95
+ )
96
+
97
+ # pack subcommand
98
+ pack_parser = subparsers.add_parser(
99
+ "pack",
100
+ help="Pack translated strings into a resource pack",
101
+ )
102
+ pack_parser.add_argument(
103
+ "--input",
104
+ required=True,
105
+ help="Path to the directory containing translated JSON files",
106
+ )
107
+ pack_parser.add_argument(
108
+ "--output",
109
+ required=True,
110
+ help="Path for the output resource pack zip file",
111
+ )
112
+ pack_parser.add_argument(
113
+ "--pack-format",
114
+ type=int,
115
+ default=DEFAULT_PACK_FORMAT,
116
+ help=f"Minecraft resource pack format version (default: {DEFAULT_PACK_FORMAT})",
117
+ )
118
+ pack_parser.add_argument(
119
+ "--description",
120
+ default=DEFAULT_DESCRIPTION,
121
+ help=f'Resource pack description (default: "{DEFAULT_DESCRIPTION}")',
122
+ )
123
+
124
+ args = parser.parse_args(argv)
125
+ _setup_logging(args.verbose)
126
+
127
+ if args.command == "extract":
128
+ return cmd_extract(args)
129
+ elif args.command == "pack":
130
+ return cmd_pack(args)
131
+ else:
132
+ parser.print_help()
133
+ return 1
134
+
135
+
136
+ if __name__ == "__main__":
137
+ sys.exit(main())