From 48f3e57a449ea32ac543bed6b4c565fbd7d02325 Mon Sep 17 00:00:00 2001 From: Dominic Masters Date: Sun, 25 May 2025 14:25:07 -0500 Subject: [PATCH] Added a few translation helpers --- locale/en_AU.mo | Bin 2157 -> 0 bytes locale/en_AU.po | 7 +++++-- project.godot | 2 +- scenes/Singletons/Quest.tscn | 6 +++++- scenes/UI/QuestMenu.tscn | 1 + scripts/Quest/Quest.gd | 8 ++++++-- scripts/Quest/QuestObjective.gd | 9 ++++++++- scripts/Singleton/Locale.gd | 3 +++ scripts/UI/QuestMenu.gd | 15 ++++++--------- 9 files changed, 35 insertions(+), 16 deletions(-) delete mode 100644 locale/en_AU.mo diff --git a/locale/en_AU.mo b/locale/en_AU.mo deleted file mode 100644 index 92e73160cbff92f34e46721728177e3bf74a37d8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2157 zcmaKsO>Z1E7{?8?6t=vSLP3HeJ%E5BWu|G#p(Kh#+H6V?RkzKyAXU-g-FcG-2T8hT~4_`fw;=6vkrj1i-u>#*KZ?3K?dT~mUY{c!9^1(kf_%#>h8 z!SV6U%ubXY67Q?brP8gOb&+PW&6#*mu=Ar9oF-UWt2YeIa< zW;eOZ*5PQDX?Ec2=HGO=#0 z-KpK!yiuR%y_7E2t{Ls&e$pHdq0;lNzc|cr1}oGVNbA_I-f3Bfpq;ErIJWTgT4+^Pqoa2WF6Suj;xB-)u6T#udYZNaVl@&;SAUzGFqc*dqSfb<& z4cYd>y+SR~rYGfSByCO-?sQDvGu9*4h5cm&0ZF7tW!adza-52*q1b6F6gxFyu^%B~ zC)PB@i@SjR&dXuOWO|fK4L!;Y*hTvt3E!9s2c1g8g?LE`RvBln$;weGZidn?zt9^3 z#JCL5qF@X@G+>$e!L-hf(XPm$7g1a8 bool: return questStarted func objectiveUpdated(objective:QuestObjective) -> void: - QUEST.questUpdated.emit(self) \ No newline at end of file + QUEST.questUpdated.emit(self) + +func getLocaleData() -> Dictionary[String, String]: + var dict: Dictionary[String, String] = {} + return dict diff --git a/scripts/Quest/QuestObjective.gd b/scripts/Quest/QuestObjective.gd index bb6a50e..d708d07 100644 --- a/scripts/Quest/QuestObjective.gd +++ b/scripts/Quest/QuestObjective.gd @@ -4,7 +4,8 @@ enum Type { Item, } -@export var title:String = "" +@export_multiline var title:String = "" +@export_multiline var description:String = "" @export var objectiveType:Type = Type.Item @export var itemType:Item.Type = Item.Type.POTION @@ -38,3 +39,9 @@ func _onPlayerInventoryUpdated() -> void: func isCompleted() -> bool: return completed + +func getLocaleData() -> Dictionary[String, String]: + var dict:Dictionary[String, String] = {} + dict.item = ITEM.getItemName(itemType, quantity) + dict.quantity = LOCALE.formatInteger(quantity) + return dict diff --git a/scripts/Singleton/Locale.gd b/scripts/Singleton/Locale.gd index 5c6bda8..3629b57 100644 --- a/scripts/Singleton/Locale.gd +++ b/scripts/Singleton/Locale.gd @@ -104,3 +104,6 @@ func setLocale(language:Language, region:Region) -> void: TranslationServer.set_locale(l) localeChanged.emit(l) print("Locale set to: " + l) + +func formatInteger(integer:int) -> String: + return TextServerManager.get_primary_interface().format_number(str(integer)) diff --git a/scripts/UI/QuestMenu.gd b/scripts/UI/QuestMenu.gd index b5dfd0b..90de31c 100644 --- a/scripts/UI/QuestMenu.gd +++ b/scripts/UI/QuestMenu.gd @@ -61,8 +61,11 @@ func setQuestObjective(objective = null): var quest = QUEST.quests[currentQuestKey]; var questObjective = quest.objectives[objective] questObjectiveList.select(objective) - - questObjectiveInfo.text = questObjective.title + "\n" + + # Setup Description + var data = quest.getLocaleData() + data.merge(questObjective.getLocaleData()) + questObjectiveInfo.text = tr(questObjective.description).format(data) func open(questKey = null) -> void: @@ -77,19 +80,13 @@ func close() -> void: func isOpen() -> bool: return self.visible - # Private methods func _updateQuestList(): questList.clear() questList.deselect_all() for questKey in QUEST.quests: var q = QUEST.quests[questKey] - var n = q.title; - if q.isCompleted(): - n += " (Complete)" - elif q.isStarted(): - n += " (Started)" - questList.add_item(n) + questList.add_item(q.title) # Event handlers