Skip to content

Add full language extraction and integrate with CI workflow#51

Open
Q2297045667 wants to merge 13 commits into
Pumpkin-MC:masterfrom
Q2297045667:master
Open

Add full language extraction and integrate with CI workflow#51
Q2297045667 wants to merge 13 commits into
Pumpkin-MC:masterfrom
Q2297045667:master

Conversation

@Q2297045667

@Q2297045667 Q2297045667 commented Jun 27, 2026

Copy link
Copy Markdown

Summary

This PR adds full multi-language translation extraction, Fabric i18n support, CI/CD, code quality improvements,


Changes

1. Extract all languages (Translations.kt)

Before After
Only en_us.json via classpath All available languages via client LanguageManager + ResourceManager
  • Reflectively accesses Minecraft.getInstance().getLanguageManager().getLanguages() to discover every available language
  • Loads each language via the client ResourceManager.getResourceStack() (has full assets — the dev-mapped jar only ships en_us)
  • Each language written as pumpkin_extractor_output/lang/<code>_java.json
  • translations.json records a summary array of all extracted language codes
  • Dedicated-server fallback: extracts en_us only (the sole lang file on the data-only classpath)

2. Fabric i18n (Lang.kt + language files)

  • Lang.kt — loads the mod's own en_us.json at runtime, exposes Lang.fmt(key, args...) with String.format semantics. All log strings are defined in the lang file as the single source of truth.
  • en_us.json / zh_cn.json — 16 translation keys each, covering mod metadata and every log message
  • fabric.mod.jsonname and description now reference translation keys; Fabric Loader resolves them per the player's locale

3. CI/CD (.github/workflows/build.yml)

  • Triggers on push and pull_request to master
  • JDK 25 + Gradle caching
  • Built artifacts uploaded as extractor-build

4. Code quality (Extractor.kt)

  • Removed unused modID field and Logger import
  • FileWriter switched to Kotlin .use {} for auto-close
  • Output directory extracted to companion object OUTPUT_DIR
  • Subdirectory support via Files.createDirectories(out.parent)
  • Outer try/catch(Throwable) prevents silent fatal failures
  • Output-directory failure logged as error instead of info
  • Dead-code comment block indentation verified identical to UP branch

File overview

File Status Description
.github/workflows/build.yml Added CI build & artifact upload
Lang.kt Added i18n string loader + formatter
assets/extractor/lang/en_us.json Added English translations (16 keys)
assets/extractor/lang/zh_cn.json Added Chinese translations (16 keys)
Extractor.kt Modified Log i18n, .use {}, defensive error handling
Translations.kt Modified Multi-language extraction with client reflection
fabric.mod.json Modified Translation-key names
README.md Modified Updated extractor list

Output structure

pumpkin_extractor_output/
├── translations.json
├── lang/
│   ├── en_us_java.json
│   ├── zh_cn_java.json
│   ├── ja_jp_java.json
│   └── ...
├── blocks.json
├── items.json
└── ...

.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant