Refactor code structure for improved readability and maintainability
This commit is contained in:
@@ -23,17 +23,34 @@ var Locales: Dictionary = {}
|
||||
var Locale = "en"
|
||||
|
||||
var Entities: Dictionary = {}
|
||||
var Templates: Dictionary = {}
|
||||
|
||||
|
||||
func get_localized_item_description(entity_id: String, item: String) -> String:
|
||||
if Locales[Locale].has(entity_id):
|
||||
return Locales[Locale][entity_id][item]
|
||||
return ""
|
||||
|
||||
|
||||
func get_description(item_id: String, values: Array = []) -> String:
|
||||
if !Templates[Locale].has(item_id):
|
||||
return ""
|
||||
#print(Templates[Locale])
|
||||
var description: String = Templates[Locale][item_id]["text"]
|
||||
var value = 0
|
||||
for item in values:
|
||||
description.replace("value"+str(value), str(item))
|
||||
return description
|
||||
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
Entities = _read_from_csv("res://Autoload/entities.csv")
|
||||
|
||||
Locales["en"] = _read_from_csv("res://Autoload/locale.en.csv")
|
||||
Locales["ru"] = _read_from_csv("res://Autoload/locale.ru.csv")
|
||||
|
||||
Templates["en"] = _read_from_csv("res://Autoload/templates.en.csv")
|
||||
|
||||
func _read_from_csv(file_path: String) -> Dictionary:
|
||||
if not FileAccess.file_exists(file_path):
|
||||
|
||||
Reference in New Issue
Block a user