Skip to content

[1.20.1] Replace hardcoded untranslatable components with translatable #54

@kkylern

Description

@kkylern

Mod's version

1.20.1

Issue

A ton of strings in the mod are hardcoded. Please, replace untranslatable components (Component.literal) with translatable (Component.translatable).

Classes/Interfaces in question

SolarForgeBlockItem.java

list.add(Component.literal("ALL ENERGY IS LOST WHEN BROKEN!").withStyle(ChatFormatting.RED));

InfusingTableBlock.java

player.sendSystemMessage(Component.literal("You are not the owner!").withStyle(ChatFormatting.RED));

StructureScreen.java

RunicTablePacket.java

player.sendSystemMessage(Component.literal("Couldn't find any unlockable fragment. Tell that to dev if you haven't done anything suspicious.").withStyle(ChatFormatting.RED));

ElementWeaverContainerScreen.java You could shorten this code with loop and any offset structure, but whatever works, I guess

https://github.com/FINDERFEED/SolarCraftRepository/blob/9c635c353c7ddf6a067159e5edd61e1e3458272d/src/main/java/com/finderfeed/solarcraft/content/blocks/blockentities/containers/screens/ElementWeaverContainerScreen.java#L43-85

ClientPacketHandles.java

ClientHelpers.getClientPlayer().sendSystemMessage(Component.literal("You don't have structure fragment(s) for this structure!"));

RadiantPortalCreatorTile.java

entity.sendSystemMessage(Component.literal("Use wormhole on 1,Y(~120),1 coordinates to return back"));

InfuserBlock.java

user.sendSystemMessage(Component.literal("You are not the owner!").withStyle(ChatFormatting.RED));

DimensionCoreTile.java

entity.sendSystemMessage(Component.literal("Use wormhole on 1,Y(~120),1 coordinates to return back"));

RunicEnergyCoreTile.java

user.sendSystemMessage(Component.literal("Draining Energy: " + !isDrainingEnergy()));

SolarNetworkBinderWandAction.java

MemoryPuzzleBlockEntity.java

player.sendSystemMessage(Component.literal("No Solar Key was found in inventory."));

EnchanterBlock.java

player.sendSystemMessage(Component.literal("You are not the owner!").withStyle(ChatFormatting.RED));

SolarCraftCommands.java

I was thinking to add this class or not, but other modders tend to add translatable strings even for debugging stuff. There are 30+ matches, I'm not listing all of them.

stack.sendSuccess(()->Component.literal("Successfully unlocked ability."),true);

SolarOrbitalMissileLauncherScreen.java

IntegerEditBox radbox = new IntegerEditBox(font,relX + 8,relY + 26 + 18*2 + 40,209,18, Component.literal("Rad"));

IntegerEditBox depthbox = new IntegerEditBox(font,relX + 8,relY + 26 + 18*3 + 60,209,18, Component.literal("Depth"));

TeleportationStone.java

player.sendSystemMessage(Component.literal("Teleportation stone cannot be used here.").withStyle(ChatFormatting.RED));

player.sendSystemMessage(Component.literal("Could not find level " + this.dimension.location() + ", try again.").withStyle(ChatFormatting.RED));

SolarLexicon.java

.addComponent(new FDTextComponent(ContentAlignment.NO_ALIGNMENT,size,0).setText(Component.literal("Parent progressions:"),0xffffff).setInnerBorder(3))

builder.addComponent(new FDTextComponent(ContentAlignment.NO_ALIGNMENT,size,0).setText(Component.literal("SPOIILER: ")

InfusingRecipeEnergyScreen.java

graphics.renderTooltip(font,Component.literal("Next recipe"),mousex,mousey);

graphics.renderTooltip(font,Component.literal("Previous recipe"),mousex,mousey);

SolarForgeScreen.java

graphics.renderTooltip(font, List.of(Component.literal("Consume energy. Abilities were moved to separate screen"),

CraftingRecipeScreen.java

graphics.renderTooltip(font,Component.literal("Next recipe"),mousex,mousey);

graphics.renderTooltip(font,Component.literal("Previous recipe"),mousex,mousey);

InfusingCraftingRecipeScreen.java

graphics.renderTooltip(font,Component.literal("Next recipe"),mousex,mousey);

graphics.renderTooltip(font,Component.literal("Previous recipe"),mousex,mousey);

SolarNetworkBinder.java

ctx.getPlayer().displayClientMessage(Component.literal("Positions cleared"),true);

cmps.add(Component.literal("Pos 1: " + getPos1(item)).withStyle(ChatFormatting.GOLD));

cmps.add(Component.literal("Pos 2: " + getPos2(item)).withStyle(ChatFormatting.GOLD));

DungeonRayControllerStick.java

player.sendSystemMessage(Component.literal("Controller set"));

player.sendSystemMessage(Component.literal("Controller not found"));

player.sendSystemMessage(Component.literal("Created handler"));

player.sendSystemMessage(Component.literal("Added offset:" + clicked.subtract(epos)));

InfusingCraftingTableTile.java

pl.sendSystemMessage(Component.literal("Cant start craft, you don't have " + recipe.get().value().getFragment().getId().toUpperCase(Locale.ROOT) +

pl.sendSystemMessage(Component.literal("INCORRECT FRAGMENT IN RECIPE "+ recipe.get().value().getOutput().getDisplayName()+" TELL MOD AUTHOR TO FIX IT").withStyle(ChatFormatting.RED));

pl.sendSystemMessage(Component.literal("Recipe invalid.").withStyle(ChatFormatting.RED));

pl.sendSystemMessage(Component.literal("You are not the owner!").withStyle(ChatFormatting.RED));

StructureSelectionScreen.java

Minecraft.getInstance().player.sendSystemMessage(Component.literal("Structure is correct")

minecraft.player.sendSystemMessage(Component.literal("And more...").withStyle(ChatFormatting.RED));

String message1 = "Structure incorrect at: " + ChatFormatting.GOLD + incState.atPos();


InfuserTileEntity.java

playerEntity.sendSystemMessage(Component.literal("Can't access inventory").withStyle(ChatFormatting.RED));

playerEntity.sendSystemMessage(Component.literal("Clear the output slot").withStyle(ChatFormatting.RED));

playerEntity.sendSystemMessage(Component.literal("Unable to start ").withStyle(ChatFormatting.RED)

.append(Component.literal("melting").withStyle(ChatFormatting.GOLD)).append(" the item: Sun Shard")

playerEntity.sendSystemMessage(Component.literal("Catalysts don't match the recipe.").withStyle(ChatFormatting.RED));

playerEntity.sendSystemMessage(Component.literal("Structure invalid.").withStyle(ChatFormatting.RED));

playerEntity.sendSystemMessage(Component.literal("Recipe invalid").withStyle(ChatFormatting.RED));

playerEntity.sendSystemMessage(Component.literal("INCORRECT FRAGMENT IN RECIPE "+ opt.get().value().output.getDisplayName().getString()+" TELL MOD AUTHOR TO FIX IT").withStyle(ChatFormatting.RED));

In next classes/interfaces, Component.literal(type.id.toUpperCase(Locale.ROOT)

Can be changed with Component.translatable("solarcraft.rune_energy_type." + type.id).append(...)

InfusingRecipeCategory.java

components.add(Component.literal(type.id.toUpperCase(Locale.ROOT) + ": ").withStyle(ChatFormatting.GOLD)

AbilityHelper.java

.append(Component.literal(" " + type.id.toUpperCase(Locale.ROOT) + ", "))

ItemRunicEnergy.java

components.add(Component.literal(type.id.toUpperCase(Locale.ROOT) + ": %.2f".formatted(getRunicEnergyFromItem(stack,type)) + "/" + item.getMaxRunicEnergyCapacity()).withStyle(ChatFormatting.GOLD));

InfusingRecipeScreen.java

graphics.renderTooltip(font,Component.literal(type.id.toUpperCase(Locale.ROOT)).withStyle(ChatFormatting.GOLD),mousex,mousey);

RETypeSelectionScreen.java

graphics.renderTooltip(font, Component.literal(type.id.toUpperCase(Locale.ROOT)),(int)x,(int)y);

UnlockedEnergyTypeToast.java

graphics.drawCenteredString(cmp.getMinecraft().font,type.id.toUpperCase(Locale.ROOT),81,7,0xffffff);

RuneEnergyPylonBlockItem.java

.append(Component.literal(": " + type.id.toUpperCase(Locale.ROOT))));

EnchanterContainerScreen.java

components.add(Component.literal(type.id.toUpperCase(Locale.ROOT) + ": ").withStyle(ChatFormatting.GOLD)

RunicEnergyChargerScreen.java

components.add(Component.literal(type.id.toUpperCase(Locale.ROOT)).append(Component.literal(": "+ re + "/" + menu.tile.getRunicEnergyLimit()).withStyle(ChatFormatting.GOLD)));

InfusingRecipeScreen.java

graphics.renderTooltip(font,Component.literal("Next recipe"),mousex,mousey);

graphics.renderTooltip(font ,Component.literal("Previous recipe"),mousex,mousey);

IRunicEnergySaver.java

components.add(Component.literal(type.id.toUpperCase(Locale.ROOT)).withStyle(ChatFormatting.GOLD)

components.add(Component.literal(type.id.toUpperCase(Locale.ROOT)).withStyle(ChatFormatting.GOLD)

RENetworkConnectivityWandAction.java

player.sendSystemMessage(Component.literal(type.id.toUpperCase(Locale.ROOT) + ": CONNECTED")

player.sendSystemMessage(Component.literal(type.id.toUpperCase(Locale.ROOT) + ": NOT CONNECTED")

player.sendSystemMessage(Component.literal(type.id.toUpperCase(Locale.ROOT) + ": CONNECTED")

player.sendSystemMessage(Component.literal(type.id.toUpperCase(Locale.ROOT) + ": NOT CONNECTED")

Strings not associated with Component.literal, but which should be able to be translated

graphics.drawCenteredString(font,"Runic Energy Charger",relX + 89 + xOffset,relY + 13 + yOffset, SolarLexiconScreen.TEXT_COLOR);

graphics.drawCenteredString(mc.font,"Recipe Progress",width/2,height / 2 + 20,0xffffff);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions