peter-kish / gloot

A universal inventory system for the Godot game engine.
MIT License
625 stars 28 forks source link

Localization key not work when create an item #172

Open juliusspeak opened 8 months ago

juliusspeak commented 8 months ago

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
peter-kish commented 8 months ago

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.