gloot icon indicating copy to clipboard operation
gloot copied to clipboard

Localization key not work when create an item

Open juliusspeak opened this issue 1 year ago • 1 comments

Not exactly an error, but I had to add this to the code so that the translation works correctly and does not show the key instead translation.

func add_item(item: InventoryItem) -> bool:
	if !can_add_item(item):
		return false

	if item.get_parent():
		item.get_parent().remove_child(item)

	add_child(item)
##############################
	item.set_property("name", tr(item.get_property("name")))
##############################
	if Engine.is_editor_hint():
		item.owner = get_tree().edited_scene_root
	return true
func create_and_add_item(prototype_id: String) -> InventoryItem:
	var item: InventoryItem = InventoryItem.new()
	item.protoset = item_protoset
	item.prototype_id = prototype_id
##############################
	item.set_property("name", tr(item.get_property("name")))
##############################
	if add_item(item):
		return item
	else:
		item.free()
		return null

juliusspeak avatar Feb 28 '24 17:02 juliusspeak

Yeah, would be nice to have support for localization, though I haven't really done any work on that yet.

I'm also not sure if I will be able to include it in the following releases... My plans are to get version 2.x into a stable state (without adding any ambitious new features), and then focus on version 3 which should include all the features I was postponing in favor of stability.

peter-kish avatar Mar 01 '24 21:03 peter-kish