Working on translation context
This commit is contained in:
@@ -24,33 +24,24 @@ func _enter_tree() -> void:
|
||||
if !ITEM_MAP.has(itemType):
|
||||
assert(false, "Missing item type: " + Item.Type.find_key(itemType))
|
||||
|
||||
func getItem(type:Item.Type) -> Item:
|
||||
if !ITEM_MAP.has(type):
|
||||
assert(false, "Item type not found: " + Item.Type.find_key(type))
|
||||
return null
|
||||
|
||||
return ITEM_MAP[type]
|
||||
|
||||
func isStackable(itemType:Item.Type) -> bool:
|
||||
if not ITEM_MAP.has(itemType):
|
||||
return false
|
||||
|
||||
var item:Item = ITEM_MAP[itemType]
|
||||
return item.stackable
|
||||
return getItem(itemType).stackable
|
||||
|
||||
func getItemName(itemType:Item.Type, count:int = 1) -> String:
|
||||
if not ITEM_MAP.has(itemType):
|
||||
return ""
|
||||
|
||||
var item:Item = ITEM_MAP[itemType]
|
||||
var item = getItem(itemType)
|
||||
return tr_n(item.title, item.title + "_plural", count).format({
|
||||
"count": count
|
||||
})
|
||||
|
||||
func getItemDescription(itemType:Item.Type) -> String:
|
||||
if not ITEM_MAP.has(itemType):
|
||||
return ""
|
||||
|
||||
var item:Item = ITEM_MAP[itemType]
|
||||
return item.description_text
|
||||
return getItem(itemType).description_text
|
||||
|
||||
func getItemCategory(itemType:Item.Type) -> Item.Category:
|
||||
if not ITEM_MAP.has(itemType):
|
||||
return Item.Category.INGREDIENT
|
||||
|
||||
var item:Item = ITEM_MAP[itemType]
|
||||
return item.category
|
||||
return getItem(itemType).category
|
||||
|
@@ -39,6 +39,14 @@ func _init() -> void:
|
||||
var preferred = OS.get_locale()
|
||||
self.setLocaleFromLocaleString(preferred)
|
||||
|
||||
func _enter_tree() -> void:
|
||||
# Test
|
||||
print("Hello World!")
|
||||
|
||||
var ctx = TransContext.new()
|
||||
ctx.addContext("item", ITEM.getItem(Item.Type.POTION).getTranslationContext())
|
||||
print(ctx.translate("test"))
|
||||
|
||||
func setLocaleFromLocaleString(localeString:String) -> void:
|
||||
var parts:PackedStringArray = localeString.split("_")
|
||||
|
||||
|
@@ -25,3 +25,10 @@ func _enter_tree() -> void:
|
||||
|
||||
func _init() -> void:
|
||||
_updateRecipes()
|
||||
|
||||
func getRecipe(recipeType:Recipe.Type) -> Recipe:
|
||||
if RECIPE_MAP.has(recipeType):
|
||||
return RECIPE_MAP[recipeType]
|
||||
else:
|
||||
assert(false, "Recipe type not found: " + Recipe.Type.find_key(recipeType))
|
||||
return null
|
||||
|
Reference in New Issue
Block a user