Skip to content

Commit

Permalink
Merge pull request #279 from VeriTas-arch
Browse files Browse the repository at this point in the history
simplified Chinese translations and minor
  • Loading branch information
Noaaan authored Feb 11, 2025
2 parents eac4403 + a5c7f3f commit aa23736
Show file tree
Hide file tree
Showing 6 changed files with 1,553 additions and 1,258 deletions.
8 changes: 8 additions & 0 deletions .github/tools/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Tools for Translators

This directory contains tools that can help translators to work more efficiently.

## Tools

- `check.py`: Check which keys are missing in the translation files.
- `sort.py`: Sort the keys in the translation files.
100 changes: 100 additions & 0 deletions .github/tools/check.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
import json
from pathlib import Path
import re

ROOT_DIR = Path(__file__).resolve().parent.parent.parent
JSON_DIR = ROOT_DIR / "src/main/resources/assets/mythicmetals/lang"
LANG_SOURCE = JSON_DIR / "en_us.json" # Original language file, set to English by default
LANG_TARGET = JSON_DIR / "zh_cn.json" # Target language file, set to your own language file
IGNORE_PATTERNS = [r"doge", r"froge", r".color"]


def load_json(file_path):
with open(file_path, "r", encoding="utf-8") as f:
return json.load(f)


def should_ignore_key(key, ignore_patterns):
"""
Judge whether the key should be ignored (supports regex matching).
Parameters
----------
key : str
The key to be checked (full path, e.g., "metadata.author").
ignore_patterns : list
List of regex patterns to ignore.
Returns
-------
bool
Whether to ignore (True / False).
"""
return any(re.search(pattern, key) for pattern in ignore_patterns)


def find_untranslated_keys(source, localized, untranslated_keys=None, parent_key="", ignore_patterns=None):
"""
Look for untranslated keys recursively, supporting the use of
regular expressions to exclude specific keys.
Parameters
----------
source
Original JSON data.
localized
Localized JSON data.
untranslated_keys : list, optional
Record untranslated keys.
parent_key : str, optional
Record nested key paths.
ignore_patterns : list, optional
List of regular expression patterns to exclude keys.
Returns
-------
untranslated_keys : list
Untranslated keys.
"""
if untranslated_keys is None:
untranslated_keys = []
if ignore_patterns is None:
ignore_patterns = []

if isinstance(source, dict):
for key, value in source.items():
new_key = f"{parent_key}.{key}" if parent_key else key

if should_ignore_key(new_key, ignore_patterns):
continue

if key in localized:
if isinstance(value, (dict, list)):
find_untranslated_keys(
value, localized[key], untranslated_keys, new_key, ignore_patterns
)
elif localized[key] == value:
untranslated_keys.append(new_key)
else:
untranslated_keys.append(new_key)

elif isinstance(source, list) and isinstance(localized, list):
for index, (s_item, l_item) in enumerate(zip(source, localized)):
find_untranslated_keys(
s_item, l_item, untranslated_keys, f"{parent_key}[{index}]", ignore_patterns
)

return untranslated_keys


source_json = load_json(LANG_SOURCE)
localized_json = load_json(LANG_TARGET)

untranslated_keys = find_untranslated_keys(source_json, localized_json, ignore_patterns=IGNORE_PATTERNS)

if untranslated_keys:
print(f"You have {len(untranslated_keys)} untranslated keys:")
for key in untranslated_keys:
print(key)
else:
print("All keys are translated!")
43 changes: 43 additions & 0 deletions .github/tools/sort.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import json
from pathlib import Path

ROOT_DIR = Path(__file__).resolve().parent.parent.parent
JSON_DIR = ROOT_DIR / "src/main/resources/assets/mythicmetals/lang"
INPUT = JSON_DIR / "zh_cn.json" # Original json file to be sorted
OUTPUT = JSON_DIR / "zh_cn.json" # Output json file, set to the same as INPUT for in-place sorting


def sort_json_keys(obj):
"""
Sort all dictionary keys in the JSON structure recursively.
Parameters
----------
obj : dict or list
JSON data to be sorted (dictionary or list).
Returns
-------
JSON data after reordering.
"""
if isinstance(obj, dict):
return {key: sort_json_keys(obj[key]) for key in sorted(obj.keys())}
elif isinstance(obj, list):
return [sort_json_keys(item) for item in obj]
else:
return obj


def reorder_json_file(input_file, output_file):
with open(input_file, "r", encoding="utf-8") as f:
data = json.load(f)

sorted_data = sort_json_keys(data)

with open(output_file, "w", encoding="utf-8") as f:
json.dump(sorted_data, f, ensure_ascii=False, indent=4)


reorder_json_file(INPUT, OUTPUT)

print("JSON sorting completed.")
78 changes: 40 additions & 38 deletions CREDITS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,37 @@

## The artists

* DH
* Temreno
* Tector
* Pois1x
* Henchman
* RGBeet
* Windy
* Shiftless
* Haunted Chest
* Dr. Zeal
* Azazelthedemonlord
* Paintedwithdrugs
* Taphrine
* thyreo
- DH
- Temreno
- Tector
- Pois1x
- Henchman
- RGBeet
- Windy
- Shiftless
- Haunted Chest
- Dr. Zeal
- Azazelthedemonlord
- Paintedwithdrugs
- Taphrine
- thyreo

Thank you all for making awesome new textures for the mod.
Thank you all for making awesome new textures for the mod.

A special thanks goes to Matpac, for providing multiple ingot textures to the mod.

## Translations
These people have helped translate the mod into different languages. Thank you to:

- Oscienet, for the russian translation.
- DH, for the macedonian translation.
- nageih and pluiedev, for the simplified chinese translations.
These people have helped translate the mod into different languages. Thank you to:

- Oscienet, for the russian translation.
- DH, for the macedonian translation.
- nageih and pluiedev, for the simplified chinese translations.
- gyular, for the korean translation.
- Kurty00 and SNL Neshorn, for the german translation.

Feel free to contribute a translation if you want to!
Feel free to contribute a translation if you want to!

I currently do not support Crowdin, so you will have to either put it up as a pull request or raise an issue with a translated lang file.

## Supporters
Expand All @@ -41,24 +43,24 @@ I currently do not support Crowdin, so you will have to either put it up as a pu

## Special Thanks

- Hugman76, for inspiring me to use Fabric.
- Shadowclaimer, for creating Metallurgy in the first place.
- Daveleo and matpac, for creating Metallurgy Reforged 4.
- Brandcraf06, for his Blockus code, helping creating blocks, chains, and anvils for the mod.
- supersaiyansubtlety and BoogieMonster1O1, for helping me with Mixin.
- LambdAurora, for her readme on how to use Gradle.
- misode, for his loot table generator.
- My friends SnifferProduct, revanitez, drakath9, and Spxtreofficial who have contributed and supported me with the mod.
- LordDeatHunter, for his helpful scripts and direct contributions to the mod.
- Flytre, for helping with the RecipeManager Mixin.
- glisco, for her many contributions and incredible toolchain.
- The incredible music talent from Galaxy Goats, provided by Jan_Boyega.
- williewillus, for the implementation of Fabric's ArmorRenderer.
- Dr. Zeal, for the wisp texture.
- BasiqueEvangelist, for multiple contributions to the project, helping with recipe serialization, and for mining copious amounts of Midas Gold.
- Draylar, for making a ton of cool mods that inspired multiple parts of the project.
- Starmute, for keeping the Terralith compat up-to-date.
- Hugman76, for inspiring me to use Fabric.
- Shadowclaimer, for creating Metallurgy in the first place.
- Daveleo and matpac, for creating Metallurgy Reforged 4.
- Brandcraf06, for his Blockus code, helping creating blocks, chains, and anvils for the mod.
- supersaiyansubtlety and BoogieMonster1O1, for helping me with Mixin.
- LambdAurora, for her readme on how to use Gradle.
- misode, for his loot table generator.
- My friends SnifferProduct, revanitez, drakath9, and Spxtreofficial who have contributed and supported me with the mod.
- LordDeatHunter, for his helpful scripts and direct contributions to the mod.
- Flytre, for helping with the RecipeManager Mixin.
- glisco, for her many contributions and incredible toolchain.
- The incredible music talent from Galaxy Goats, provided by Jan_Boyega.
- williewillus, for the implementation of Fabric's ArmorRenderer.
- Dr. Zeal, for the wisp texture.
- BasiqueEvangelist, for multiple contributions to the project, helping with recipe serialization, and for mining copious amounts of Midas Gold.
- Draylar, for making a ton of cool mods that inspired multiple parts of the project.
- Starmute, for keeping the Terralith compat up-to-date.
- DaFuqs, for the ItemRendererMixin implementation.
- 80020h, for a ton of great suggestions on improvements to the mod.
- Blodgharm, for always being willing to spend hours even just to find a typo in the code.
- The Fabric Project Discord, who have been supportive while developing this mod.
- The Fabric Project Discord, who have been supportive while developing this mod.
35 changes: 15 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,38 +1,33 @@
# Mythic Metals

Mythic Metals is a Fabric based Minecraft mod, that adds new ores, materials, tools and sets of armor.
The mod is heavily inspired by Shadowclaimers Metallurgy, and was originally intended as a port.
After being denied the privilege to do so this mod was created from the ground up as my first proper Minecraft mod.
Mythic Metals is a Fabric based Minecraft mod, that adds new ores, materials, tools and sets of armor. The mod is heavily inspired by Shadowclaimers Metallurgy, and was originally intended as a port. After being denied the privilege to do so this mod was created from the ground up as my first proper Minecraft mod.

You can find the patch notes in the [PATCHNOTES.md](PATCHNOTES.md) file.

## Download

You can download the mod from CurseForge, Modrinth, use CI builds, or build it yourself.
CurseForge link:
https://www.curseforge.com/minecraft/mc-mods/mythicmetals
You can download the mod from CurseForge, Modrinth, use CI builds, or build it yourself.

Modrinth link:
https://modrinth.com/mod/mythicmetals

GitHub Actions link:
https://github.com/Noaaan/MythicMetals/actions
- CurseForge link: <https://www.curseforge.com/minecraft/mc-mods/mythicmetals>
- Modrinth link: <https://modrinth.com/mod/mythicmetals>
- GitHub Actions link: <https://github.com/Noaaan/MythicMetals/actions>

## License

This mod is licensed under a custom MIT license. Please read it before re-using any code.
You can use this mod as an example/base for adding in blocks, ingots, armor, tools, and ore generation for Fabric mods.
Feel free to use this in any modpack you wish for.
Some modpacks that use Mythic Metals:
- Euphoric Curiosities: https://www.curseforge.com/minecraft/modpacks/euphoriccuriosity
- Medieval Minecraft (Fabric): https://www.curseforge.com/minecraft/modpacks/medieval-mc-fabric-mmc2
- BounceSMP: https://www.curseforge.com/minecraft/modpacks/bouncesmp-public
This mod is licensed under a custom MIT license. Please read it before re-using any code. You can use this mod as an example/base for adding in blocks, ingots, armor, tools, and ore generation for Fabric mods. Feel free to use this in any modpack you wish for.

Some modpacks that use Mythic Metals:

- Euphoric Curiosities: <https://www.curseforge.com/minecraft/modpacks/euphoriccuriosity>
- Medieval Minecraft (Fabric): <https://www.curseforge.com/minecraft/modpacks/medieval-mc-fabric-mmc2>
- BounceSMP: <https://www.curseforge.com/minecraft/modpacks/bouncesmp-public>

## Credits

See [the Credits file in the repo](CREDITS.md), as it contains a shoutout to everyone who has worked on the project!

## Translations
Feel free to contribute a translation if you want to!
I currently do not support Crowdin, so you will have to either put it up as a pull request or raise an issue with a translated lang file.

Feel free to contribute a translation if you want to! I currently do not support Crowdin, so you will have to either put it up as a pull request or raise an issue with a translated lang file.

Any translator is added to [the Credits.](CREDITS.md)
Loading

0 comments on commit aa23736

Please sign in to comment.