Skip to content

Commit

Permalink
Add format string and material separator translation keys (#4753)
Browse files Browse the repository at this point in the history
Not super happy with a separator instead of a format string for materials, but since its a loop I don't have much other choice. Order does not really matter in any case so a format string does not really add much I suppose
  • Loading branch information
KnightMiner committed Dec 27, 2022
1 parent 6ffc057 commit 1d7acee
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@

/** Helper functions for adding tooltips to tools */
public class TooltipUtil {
/** Translation key for the tool name format string */
private static final String KEY_FORMAT = TConstruct.makeTranslationKey("item", "tool.format");
/** Translation key for the tool name format string */
private static final Component MATERIAL_SEPARATOR = TConstruct.makeTranslation("item", "tool.material_separator");
/** Tool tag to set that makes a tool a display tool */
public static final String KEY_DISPLAY = "tic_display";
/** Function to show all attributes in the tooltip */
Expand Down Expand Up @@ -102,9 +106,9 @@ private static Component nameFor(String itemKey, Component itemName, MaterialVar
if (Util.canTranslate(formatKey)) {
return new TranslatableComponent(formatKey, itemName);
}
// base name
// base name with generic format
if (Util.canTranslate(materialKey)) {
return new TranslatableComponent(materialKey).append(" ").append(itemName);
return new TranslatableComponent(KEY_FORMAT, new TranslatableComponent(materialKey), itemName);
}
return null;
}
Expand Down Expand Up @@ -147,11 +151,9 @@ private static Component getCombinedItemName(Component itemName, Collection<Comp
Iterator<Component> iter = materials.iterator();
name.append(iter.next());
while (iter.hasNext()) {
name.append("-").append(iter.next());
name.append(MATERIAL_SEPARATOR).append(iter.next());
}
name.append(" ").append(itemName);

return name;
return new TranslatableComponent(KEY_FORMAT, name, itemName);
}

/**
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/assets/tconstruct/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -845,6 +845,10 @@

"_comment": "Tinkers Tools",

"_comment_on_format_": "These format allows you to have more control over separators in material names. By default we separate with space. You can use %1$s and %2$s if you wish to change the order.",
"item.tconstruct.tool.format": "%s %s",
"item.tconstruct.tool.material_separator": "-",

"item.tconstruct.pickaxe": "Pickaxe",
"item.tconstruct.sledge_hammer": "Sledge Hammer",
"item.tconstruct.vein_hammer": "Vein Hammer",
Expand Down

0 comments on commit 1d7acee

Please sign in to comment.