Skip to content

Fix a lot of strings being hardcoded and untranslatable#35

Merged
iglee42 merged 15 commits intoiglee42:1.21.1from
VladisCrafter:string_dehardcoding
Aug 29, 2025
Merged

Fix a lot of strings being hardcoded and untranslatable#35
iglee42 merged 15 commits intoiglee42:1.21.1from
VladisCrafter:string_dehardcoding

Conversation

@VladisCrafter
Copy link
Copy Markdown
Contributor

Summary:

What was "dehardcoded":

  1. All Statue-related strings (main tab labels, scale scroll, statue/player/animation names);
  2. Armor & Tools strings (function displays in the inventory, function activation messages);
  3. (Partially) Inventory/Item/Tooltip config screens (the UI itself, not the tooltips);
  4. Display board edit screen strings (Glowing button AND color names);
  5. The Stock Manager warning chat message (also split it in two for easier editing).

Important:

Some of strings have identical values in en_us.json, but are technically different for a reason. For example, "createqol.function.tools.vein_mine" is used in the inventory, and
"createqol.tool.vein_mine_toggle" - is shown in the client's screen when it's enabled.
Thus, messages can be customized separately.


Corrections:

If you dislike the localization key values or their placements in the lang files, you can request changes or change them yourself BUT mind the following:

  • If former: mass replace, not by hand (as some keys are used in a lot of places);
  • If latter: please move them in ru_ru.json as well, so future translation won't require doing that again.

Phew.

@VladisCrafter
Copy link
Copy Markdown
Contributor Author

@mpustovoi, fancy reviewing this abomination? :]
Only the ru_ru ofc 😅

@iglee42 iglee42 self-assigned this Aug 28, 2025
Copy link
Copy Markdown
Contributor

@mpustovoi mpustovoi left a comment

Choose a reason for hiding this comment

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

ru_ru.json is fine tho.

(e,oE)->true
));
}else if (getType() == ArmorItem.Type.LEGGINGS){
list.add(Configuration.ofBool("Void Walking",
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Could be Translated with CreateQOLLang.translateDirect("xxxx").getString()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Could be Translated with CreateQOLLang.translateDirect("xxxx").getString()

I decided to not touch strings of the config itself, since Create mod's config is surprisingly hardcoded as well. Maybe that will change in the future but I think it's better to leave it like that for the sake of consistency.

list.add(Configuration.ofBool("Void Walking",
stack.getOrDefault(QOLDataComponents.VOID_WALK,true),
QOLDataComponents.VOID_WALK,
List.of("Enable walking on void"),
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Same

.withStyle(ChatFormatting.GOLD)
.append(QOLConfigurableItem.chooseState(CreateQOLConfigs.server().equipments.armors.voidWalking.get(),
true, stack.getOrDefault(QOLDataComponents.VOID_WALK, true), false, true)));
components.add(Component.translatable("createqol.function.armor.step_height")
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Why did you use Component.translatable() instead of CreateQOLLang.translateDirect("xxxx").getString()?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Why did you use Component.translatable() instead of CreateQOLLang.translateDirect("xxxx").getString()?

I tried replicating your style of translating by using CreateQOLLang.translateDirect("xxxx") mainly in client messages and some other stuff. I also remember seeing that:

/**

  • legacy-ish. Use CreateQOLLang.translate and other builder methods where possible

*/

...so I'm not sure if it was good to use at all 🤷‍♂️

if (player.isCrouching()){
if (player.getItemInHand(hand).getOrDefault(QOLDataComponents.HARVESTING,false)){
player.displayClientMessage(Component.literal("Ploughing can't be enabled if harvesting is enabled").withStyle(ChatFormatting.RED),true);
player.displayClientMessage(Component.translatable("createqol.tool.ploughing_unavailable").withStyle(ChatFormatting.RED),true);
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Could be generic with something like CreateQOLLang.translateDirect("function.state.disabled_by",CreateQOL.translateDirect("function.tool.smelting").getString(),CreateQOL.translateDirect("function.tool.digging").getString())

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Could be generic with something like CreateQOLLang.translateDirect("function.state.disabled_by",CreateQOL.translateDirect("function.tool.smelting").getString(),CreateQOL.translateDirect("function.tool.digging").getString())

Yeah, I can try that.

"createqol.tool.vein_mine_disabled": "Vein Mine is disabled by the config",
"createqol.tool.vein_mine_unavailable": "Vein Mine can't be enabled if digging is enabled",

"createqol.tool.casingifier_toggle": "Casingifier : ",
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Why did you put the : in the translation, it means we won't be able to use it elsewhere than the tooltip.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Why did you put the : in the translation, it means we won't be able to use it elsewhere than the tooltip.

Well, actually you did. I copied the string one-to-one :]
But yeah, I can remove the : from this type of strings.

And, if by "elsewhere" you have a specific thought, I'd like to know.

"createqol.chestplate.dash_disabled": "Dashing is disabled on this server !",
"createqol.chestplate.dash_reloading": "Dashing is reloading, please wait!",

"createqol.tool.casingifier_disabled": "Casingifier is disabled by the config",
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Theses messages can be more generic with %s

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Theses messages can be more generic with %s

Got It!

@iglee42
Copy link
Copy Markdown
Owner

iglee42 commented Aug 28, 2025

Also I think you can merge duplicate keys because if they have to be edited I will forgot one for sure and in english it doesn't cause issues if they are the same.
I don't know in russian

@VladisCrafter
Copy link
Copy Markdown
Contributor Author

Also I think you can merge duplicate keys because if they have to be edited I will forgot one for sure and in english it doesn't cause issues if they are the same. I don't know in russian

That's the issue. I'd suggest keeping them as different strings: short type to be displayed in the inventory and long type for client messages.

@VladisCrafter VladisCrafter marked this pull request as ready for review August 29, 2025 13:06
Copy link
Copy Markdown
Owner

@iglee42 iglee42 left a comment

Choose a reason for hiding this comment

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

Seems all good

@iglee42 iglee42 merged commit 5d551c8 into iglee42:1.21.1 Aug 29, 2025
0 of 3 checks passed
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.

3 participants