Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BetterTooltips Languages Support #4993

Closed
wants to merge 0 commits into from

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.

@@ -282,12 +282,12 @@ private void appendTooltip(ItemStackTooltipEvent event) {
BlockStateComponent blockStateComponent = event.itemStack().get(DataComponentTypes.BLOCK_STATE);
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
Contributor

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
Contributor

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

@@ -327,7 +327,7 @@ private void getTooltipData(TooltipDataEvent event) {
else if (event.itemStack.getItem() == Items.ENDER_CHEST && previewEChest()) {
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
Contributor

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

@@ -408,7 +408,7 @@ private void appendPreviewTooltipText(ItemStackTooltipEvent event, boolean space
)) {
// 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
Contributor

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
Contributor

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