From 5fe7121ea968d42485bd4aca0a86ca553512d318 Mon Sep 17 00:00:00 2001 From: Misode Date: Thu, 20 Oct 2022 05:03:03 +0200 Subject: [PATCH] Fix #297 improve fake name translation and fix crash --- src/app/components/ItemTooltip.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/app/components/ItemTooltip.tsx b/src/app/components/ItemTooltip.tsx index cf9d06dd..a1350be0 100644 --- a/src/app/components/ItemTooltip.tsx +++ b/src/app/components/ItemTooltip.tsx @@ -53,6 +53,10 @@ export function ItemTooltip({ id, tag, advanced, offset = [0, 0], swap }: Props) } function fakeTranslation(str: string) { - const raw = str.replace(/minecraft:/, '').replaceAll('_', ' ') - return raw[0].toUpperCase() + raw.slice(1) + const colon = str.indexOf(':') + return str.slice(colon + 1) + .replace(/[_\/]/g, ' ') + .split(' ') + .map(word => word.charAt(0).toUpperCase() + word.slice(1)) + .join(' ') }