Fix a lot of strings being hardcoded and untranslatable#35
Fix a lot of strings being hardcoded and untranslatable#35iglee42 merged 15 commits intoiglee42:1.21.1from
Conversation
|
@mpustovoi, fancy reviewing this abomination? :] |
mpustovoi
left a comment
There was a problem hiding this comment.
ru_ru.json is fine tho.
| (e,oE)->true | ||
| )); | ||
| }else if (getType() == ArmorItem.Type.LEGGINGS){ | ||
| list.add(Configuration.ofBool("Void Walking", |
There was a problem hiding this comment.
Could be Translated with CreateQOLLang.translateDirect("xxxx").getString()
There was a problem hiding this comment.
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"), |
| .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") |
There was a problem hiding this comment.
Why did you use Component.translatable() instead of CreateQOLLang.translateDirect("xxxx").getString()?
There was a problem hiding this comment.
Why did you use
Component.translatable()instead ofCreateQOLLang.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); |
There was a problem hiding this comment.
Could be generic with something like CreateQOLLang.translateDirect("function.state.disabled_by",CreateQOL.translateDirect("function.tool.smelting").getString(),CreateQOL.translateDirect("function.tool.digging").getString())
There was a problem hiding this comment.
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 : ", |
There was a problem hiding this comment.
Why did you put the : in the translation, it means we won't be able to use it elsewhere than the tooltip.
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
Theses messages can be more generic with %s
There was a problem hiding this comment.
Theses messages can be more generic with
%s
Got It!
|
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. |
…y are initially called in the config
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. |
Summary:
What was "dehardcoded":
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:
ru_ru.jsonas well, so future translation won't require doing that again.Phew.