Skip to content

Conversation

@Nekiplay
Copy link
Contributor

Type of change

  • Bug fix
  • New feature

Description

Support for different languages for BetterTooltips

Related issues

None

How Has This Been Tested?

image

Checklist:

  • My code follows the style guidelines of this project.
  • I have added comments to my code in more complex areas.
  • I have tested the code in both development and production environments.

if (blockStateComponent != null) {
String level = blockStateComponent.properties().get("honey_level");
event.appendStart(Text.literal(String.format("%sHoney level: %s%s%s.", Formatting.GRAY, Formatting.YELLOW, level, Formatting.GRAY)));
event.appendStart(Text.literal(String.format(Text.translatable("modules.better-tooltip.honey-level").getString(), Formatting.GRAY, Formatting.YELLOW, level, Formatting.GRAY)));
Copy link
Collaborator

Choose a reason for hiding this comment

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

use a single Text.translatable() with arguments

List<BeehiveBlockEntity.BeeData> bees = event.itemStack().get(DataComponentTypes.BEES);
if (bees != null) {
event.appendStart(Text.literal(String.format("%sBees: %s%d%s.", Formatting.GRAY, Formatting.YELLOW, bees.size(), Formatting.GRAY)));
event.appendStart(Text.literal(String.format(Text.translatable("modules.better-tooltip.bees").getString(), Formatting.GRAY, Formatting.YELLOW, bees.size(), Formatting.GRAY)));
Copy link
Collaborator

Choose a reason for hiding this comment

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

use a single Text.translatable() with arguments

event.tooltipData = EChestMemory.isKnown()
? new ContainerTooltipComponent(EChestMemory.ITEMS.toArray(new ItemStack[27]), ECHEST_COLOR)
: new TextTooltipComponent(Text.literal("Unknown ender chest inventory.").formatted(Formatting.DARK_RED));
: new TextTooltipComponent(Text.literal(Text.translatable("modules.better-tooltip.unknown-ender-chest-inventory").getString()).formatted(Formatting.DARK_RED));
Copy link
Collaborator

Choose a reason for hiding this comment

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

use a single Text.translatable() with arguments

// we don't want to add the spacer if the tooltip is hidden
if (spacer) event.appendEnd(Text.literal(""));
event.appendEnd(Text.literal("Hold " + Formatting.YELLOW + keybind + Formatting.RESET + " to preview"));
event.appendEnd(Text.literal(String.format(Text.translatable("modules.better-tooltip.hold-for-preview").getString(), Formatting.YELLOW, keybind, Formatting.RESET)));
Copy link
Collaborator

Choose a reason for hiding this comment

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

use a single Text.translatable() with arguments

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
It doesn't work with colours for some reason
image

Copy link
Collaborator

Choose a reason for hiding this comment

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

yes, you use styled Text objects as arguments

@Nekiplay Nekiplay marked this pull request as draft October 29, 2024 13:48
@Nekiplay Nekiplay marked this pull request as ready for review October 29, 2024 14:11
@Wide-Cat
Copy link
Collaborator

This is something interesting to think about. If we're going to add translations to meteor like this, it would probably make more sense to do it as a whole across the project, rather than module by module. We also need to finish work on the font renderer, as while it does now support many more languages, it's not perfect. Something to discuss after the 1.21.3 update.

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