Fix #297 improve fake name translation and fix crash

This commit is contained in:
Misode
2022-10-20 05:03:03 +02:00
parent e78a317260
commit 5fe7121ea9

View File

@@ -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(' ')
}