Skip to content

Reduce the size of the GregTech.lang, and standardize the Line Break, etc.#5261

Open
iouter wants to merge 109 commits intomasterfrom
tooltip
Open

Reduce the size of the GregTech.lang, and standardize the Line Break, etc.#5261
iouter wants to merge 109 commits intomasterfrom
tooltip

Conversation

@iouter
Copy link
Contributor

@iouter iouter commented Nov 6, 2025

Line Breaks

Material

  • The methods for returning names in GregTech, Bartworks and GT++ have been standardized:
    • getDefaultLocalName() returns the original text of the localized name.
    • getLocalizedNameKey() returns the localized key of the material.
    • getLocalizedName() returns the translated localized name.
  • Removed the mLocalizedName variable in GT materials, use getLocalizedName() instead. The mChemicalFormula has been set to private, use getChemicalFormula() to get it.
  • Those materials in GT++ that come from GT but have a different name. All use GT names now.
  • In GregTech.lang, the translation keys for GT++ materials now follow the same format "Material.xxx".
  • Most chemical formulas use the original text, while those requiring translation automatically generate translation keys, including English sentences and non-auto-generated formulas from bartworks.
  • The lore texts can be localized now.
  • Refactor the tooltip of material, each form should be able to display the chemical formula and lore text, and retain a translation key that can be used to add a tooltip for a single material item.
  • image
  • Move some translation keys from CustomToolTips.xml to en_US.lang, but not include the Orundum Ore.
  • image
  • image

Oreprefixes

  • No longer generates keys for each form of every material, this includes %material xxx and it's Chemical Formula.
  • Each form use only one key to display.

Fluids

  • Use the addLocalizedName() to generate translation keys for fluids.
  • Fluid names will no longer be automatically generated for materials that either have the same name or match specific forms (such as Molten %material, %material plasma) when use the addLocalizedName(Materials) or addLocalizedName(Werkstoff).
  • Must use the addLocalizedName() to automatically generate a fluid translation key when registering GT fluids.
  • GT++ fluids follow similar logic.
  • The chemical formula displayed in white instead of yellow now, as other items use white.
  • image

Machines

  • No longer generates translation keys for MetaPipeEntity. Most now use the oreprefix key to get name, while others use keys from en_US.lang.
  • Machine tooltips are now merged into a single line during generation, connected with \n. The key has been changed to gt.blockmachines.{name}.tooltip(_secondary).
  • Added the addFormattedString(String) method, which can be used in getDescription() (when isSkipGenerateDescription() is false). It will automatically replaces parameters with %s during generation and displays parameters in the game. This functions similarly to the previous %%% markers but is more intuitive.
  • Added the @SkipGenerateDescription annotation. If a class is annotated with it, the automatic generation of machine tooltip keys is skipped. In this case, getDescription() should directly return text processed by the mc lang system.
  • Each class that needs to skip generating tooltips must be annotated with this annotation.
  • Moved tooltips for some machines to en_US.lang.
  • The pipe/wire can be displayed the chemical formula and lore text.
  • image

Authors

  • Removed the "Author: " from all author constants.
  • When there are multiple authors, it will be displayed as: author1, author2 & author3.

GTLanguagerManger (GregTech.lang)

  • The addStringLocalization(key, value) no longer returns a value. Generate key and get translation must be handled separately. (translation should not be stored in variables.)
  • Moved some translation keys to the en_US.lang of their mods.
  • The key and english is registered in fallbackTranslator now.
  • When loading language entries, results from already loaded language entries are prioritized, meaning translations corresponding to keys in en_US.lang are used first.
  • Switching languages now reloads GregTech.lang.
  • Fixed some hardcoded issues.
  • The significant reduction in the size of GregTech.lang paves the way for transitioning its generation from in-game to an external process.

Migration

  • I tried to write a script to automate the migration of some keys.
  • the script link: https://gist.github.com/iouter/4f64244a4cf68a018abb9a94f99a63fa
  • Usage: modify the LANGUAGE_CODE, INPUT_ZIP_FILE_PAST, INPUT_ZIP_FILE_NOW, OUTPUT_PATH. LANGUAGE_CODE is the language code like zh_CN, INPUT_ZIP_FILE_PAST is the zip downloaded from paratranz before the PR, INPUT_ZIP_FILE_NOW is the zip after the PR, OUTPUT_PATH is the output path.
  • Notice: a Paratranz ZIP needs to be saved before the PR is merged.
  • Output: in the OUTPUT_PATH folder.
  • Import process in Paratranz: Settings & Management -> Files -> Find these Files -> Import translations -> Add Files and Click “Force Import”.

Language Files Result

Sub-PR

# Conflicts:
#	src/main/java/bartworks/common/tileentities/tiered/MTECompressedFluidHatch.java
#	src/main/java/bartworks/common/tileentities/tiered/MTEHumongousInputHatch.java
#	src/main/java/bartworks/system/material/BWMetaGeneratedBlocks.java
#	src/main/java/bartworks/system/material/BWMetaGeneratedItems.java
#	src/main/java/bartworks/system/material/BWMetaGeneratedOres.java
#	src/main/java/bartworks/system/material/BWMetaGeneratedSmallOres.java
#	src/main/java/bartworks/system/material/BWMetaGeneratedWerkstoffBlocks.java
#	src/main/java/detrav/items/behaviours/BehaviourDetravToolProspector.java
#	src/main/java/detrav/net/ProspectingPacket.java
#	src/main/java/goodgenerator/blocks/tileEntity/AntimatterOutputHatch.java
#	src/main/java/gregtech/api/enums/Materials.java
#	src/main/java/gregtech/api/enums/MaterialsBotania.java
#	src/main/java/gregtech/api/items/MetaGeneratedItemX32.java
#	src/main/java/gregtech/api/metatileentity/CommonMetaTileEntity.java
#	src/main/java/gregtech/api/metatileentity/implementations/MTEHatchInput.java
#	src/main/java/gregtech/api/metatileentity/implementations/MTEHatchInputBus.java
#	src/main/java/gregtech/api/metatileentity/implementations/MTEHatchOutputBus.java
#	src/main/java/gregtech/api/metatileentity/implementations/MTEHatchVoidBus.java
#	src/main/java/gregtech/api/util/GTUtility.java
#	src/main/java/gregtech/common/OreMixBuilder.java
#	src/main/java/gregtech/common/blocks/BlockConcretes.java
#	src/main/java/gregtech/common/blocks/BlockFrameBox.java
#	src/main/java/gregtech/common/blocks/BlockMetal.java
#	src/main/java/gregtech/common/blocks/BlockOresAbstract.java
#	src/main/java/gregtech/common/blocks/BlockReinforced.java
#	src/main/java/gregtech/common/blocks/ItemOres.java
#	src/main/java/gregtech/common/items/MetaGeneratedItem03.java
#	src/main/java/gregtech/common/items/MetaGeneratedItem99.java
#	src/main/java/gregtech/common/items/behaviors/BehaviourProspecting.java
#	src/main/java/gregtech/common/tileentities/machines/MTEHatchInputBusME.java
#	src/main/java/gregtech/common/tileentities/machines/MTEHatchInputME.java
#	src/main/java/gregtech/loaders/preload/LoaderGTBlockFluid.java
#	src/main/java/gtPlusPlus/core/item/circuit/GTPPIntegratedCircuitItem.java
#	src/main/java/gtPlusPlus/core/material/Material.java
#	src/main/java/gtPlusPlus/core/util/minecraft/FluidUtils.java
#	src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/GTPPMTEFluidPipe.java
#	src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/MTEHatchChiselBus.java
#	src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/MTEHatchDynamoBuffer.java
#	src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/MTEHatchSolidifier.java
#	src/main/java/gtPlusPlus/xmod/gregtech/api/metatileentity/implementations/MTEHatchSteamBusOutput.java
#	src/main/java/gtneioreplugin/plugin/gregtech5/PluginGT5Base.java
#	src/main/java/gtneioreplugin/plugin/gregtech5/PluginGT5VeinStat.java
#	src/main/java/gtneioreplugin/util/GT5OreLayerHelper.java
#	src/main/resources/assets/gregtech/lang/en_US.lang
# Conflicts:
#	src/main/java/gregtech/api/util/GTUtility.java
# Conflicts:
#	src/main/resources/assets/gregtech/lang/en_US.lang
@iouter iouter added the Refactor For PRs rewriting a part of the code to have a nicer code overall. label Nov 6, 2025
@Dream-Master Dream-Master added the 🚧 Testing on Zeta Do not merge yet, testing this PR on Zeta label Nov 7, 2025
@Dream-Master Dream-Master requested a review from a team November 7, 2025 09:35
@Dream-Master Dream-Master removed the 🚧 Testing on Zeta Do not merge yet, testing this PR on Zeta label Nov 7, 2025
@Nikolay-Sitnikov Nikolay-Sitnikov self-assigned this Nov 7, 2025
Comment on lines +124 to +136
public String getLocalizedName() {
if (materialKeys.size() == 1) return StatCollector.translateToLocal(materialKeys.get(0));
String localizedName = String.join(
", ",
materialKeys.stream()
.map(StatCollector::translateToLocal)
.toArray(String[]::new));
int index = localizedName.lastIndexOf(", ");
if (index != -1) {
localizedName = localizedName.substring(0, index) + " & " + localizedName.substring(index + 2);
}
return localizedName;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is generally a bad idea, since different languages have different rules for making a list of items. (There's no ampersand in Russian, for instance.)

Also, don't all the ore mixes already have their own translation strings added with .name()? What's this text used for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

And any suggestion for these "different rules"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solutions:

  1. Hardcoded.
  2. Add 2 translation keys
  3. Use the ListFormatter from ICU4J, but the icu4j-core-mojang-51.2.jar from vanilla can't use it, needs updating and shadow jar.
  4. Only supports Java 22+, use the ListFormat.

@Nikolay-Sitnikov
Copy link
Contributor

Once #5210 is merged, I think we can change all the chemical formulas that contain text in them to be lore text instead. That way, there's no need to localize chemical formulas and we have logical separation between text & chemistry.

@iouter
Copy link
Contributor Author

iouter commented Nov 8, 2025

Once #5210 is merged, I think we can change all the chemical formulas that contain text in them to be lore text instead. That way, there's no need to localize chemical formulas and we have logical separation between text & chemistry.

these lore texts seem hardcoded.

@VortexSo4
Copy link
Contributor

VortexSo4 commented Nov 8, 2025

these lore texts seem hardcoded.

the lore text is hardcoded, feel free to add localization, i thought that translating them would change the vibe of the quotes, so i left them in english only

@iouter
Copy link
Contributor Author

iouter commented Nov 8, 2025

these lore texts seem hardcoded.

the lore text is hardcoded, feel free to add localization, i thought that translating them would change the vibe of the quotes, so i left them in english only

Translating anything inevitably change the vibe, it may be more appropriate for the translator, rather than yourself, to make the decision on whether to keep the original text, especially for a sentence like this.

# Conflicts:
#	src/main/java/gregtech/api/enums/MaterialBuilder.java
#	src/main/java/gregtech/api/enums/Materials.java
#	src/main/java/gregtech/api/items/MetaGeneratedItemX32.java
#	src/main/java/gregtech/common/blocks/BlockFrameBox.java
#	src/main/java/gregtech/common/items/MetaGeneratedItem99.java
#	src/main/java/gregtech/loaders/materials/MaterialsInit.java
Copy link
Contributor

@Discreater Discreater left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Tested in sp & mp. However, I feel that my review alone might not be sufficient. Since GTUtility.trans no longer automatically adds keys, any entries that haven't been localized via addStringLocalization will only display their raw keys. We might need manual testing to identify these cases.

@Nikolay-Sitnikov Nikolay-Sitnikov removed their assignment Feb 20, 2026
Dream-Master and others added 8 commits February 20, 2026 15:55
# Conflicts:
#	src/main/java/gregtech/api/enums/GTValues.java
#	src/main/java/gregtech/common/tileentities/machines/MTEHatchInputBusME.java
#	src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/machines/multi/processing/steam/MTESteamMixer.java
@Dream-Master
Copy link
Member

@iouter

iouter and others added 7 commits February 25, 2026 05:51
# Conflicts:
#	src/main/java/gregtech/api/items/BlockLongDistancePipe.java
#	src/main/java/gregtech/api/util/GTLanguageManager.java
#	src/main/java/gregtech/api/util/tooltip/TooltipHelper.java
#	src/main/resources/assets/gregtech/lang/en_US.lang
@Dream-Master
Copy link
Member

@iouter can you resolve the merge conflicts? Btw what is the status of this pr?

iouter added 2 commits March 3, 2026 22:59
# Conflicts:
#	src/main/java/gtPlusPlus/xmod/gregtech/common/tileentities/storage/MTETieredTank.java
#	src/main/resources/assets/gregtech/lang/en_US.lang
#	src/main/resources/assets/miscutils/lang/en_US.lang
@iouter
Copy link
Contributor Author

iouter commented Mar 3, 2026

@iouter can you resolve the merge conflicts? Btw what is the status of this pr?

done. waiting for more review i guess.

@Dream-Master Dream-Master removed the 🚧 Testing on Zeta Do not merge yet, testing this PR on Zeta label Mar 4, 2026
iouter and others added 4 commits March 7, 2026 06:54
# Conflicts:
#	src/main/java/bartworks/common/tileentities/tiered/MTEDiode.java
#	src/main/java/gregtech/api/enums/GTValues.java
#	src/main/resources/assets/gregtech/lang/en_US.lang
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Refactor For PRs rewriting a part of the code to have a nicer code overall.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants