Skip to content

Commit 5bca685

Browse files
Add Translation Support for Glossary (#1954)
- Makes Glossary translatable. - Adds empty-line separation too all csv's. - Fixes some character name translation bug that prevented all characters from being collected. - Adjust translation Settings a bit to be used for all resources not just timelines. --------- Co-authored-by: Jowan-Spooner <[email protected]>
1 parent 65a1633 commit 5bca685

File tree

10 files changed

+1370
-379
lines changed

10 files changed

+1370
-379
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
## This test suite tests the DialogicGlossary class.
2+
extends GdUnitTestSuite
3+
4+
5+
const NAME_ENTRY := "Example Name"
6+
const EXAMPLE_TITLE := "Example Title"
7+
const ALTERNATIVE_ENTRIES := ["A", "BE", "VERY LONG ENTRY"]
8+
9+
const SAMPLE_ENTRY := {
10+
DialogicGlossary.TITLE_PROPERTY: EXAMPLE_TITLE,
11+
DialogicGlossary.NAME_PROPERTY: NAME_ENTRY,
12+
DialogicGlossary.ALTERNATIVE_PROPERTY: ALTERNATIVE_ENTRIES
13+
}
14+
15+
16+
## We test to add a glossary entry and whether the resulting states of the
17+
## glossary indicate that the entry was added correctly.
18+
func test_add_entry() -> void:
19+
var glossary: DialogicGlossary = DialogicGlossary.new()
20+
21+
assert(glossary.try_add_entry(SAMPLE_ENTRY), "Unable to add entry.")
22+
23+
const NAME_COUNTER := 1
24+
var total_entry_count := ALTERNATIVE_ENTRIES.size() + NAME_COUNTER
25+
26+
assert(glossary.entries.size() == total_entry_count, "Glossary should have 1 entry")
27+
assert(not glossary.get_entry(NAME_ENTRY).is_empty(), "Entry index cannot be found via entry name.")
28+
29+
for alternative: String in ALTERNATIVE_ENTRIES:
30+
var assert_error_message := "Entry index cannot be found via alternative name: " + alternative
31+
assert(not glossary.get_entry(alternative).is_empty(), assert_error_message)
32+
33+
34+
## We test whether an entry's key can be replaced and if the resulting action
35+
## invalidates the old entry key when accessing the glossary.
36+
func test_replace_entries() -> void:
37+
var glossary: DialogicGlossary = DialogicGlossary.new()
38+
39+
assert(glossary.try_add_entry(SAMPLE_ENTRY), "Unable to add entry.")
40+
41+
const NEW_NAME := "NEW NAME"
42+
43+
glossary.replace_entry_key(NAME_ENTRY, NEW_NAME)
44+
45+
var entry := glossary.get_entry(NEW_NAME)
46+
var error := "Entry expected to be non-empty, was empty."
47+
assert(not entry.is_empty(), error)
48+
49+
var old_entry := glossary.get_entry(NAME_ENTRY)
50+
error = "Entry expected to be empty, was an instance."
51+
assert(old_entry.is_empty(), error)
52+
53+
54+
## We test whether adding and deleting entries work.
55+
func test_remove_entry() -> void:
56+
var glossary: DialogicGlossary = DialogicGlossary.new()
57+
58+
assert(glossary.try_add_entry(SAMPLE_ENTRY), "Unable to add entry.")
59+
60+
const NAME_COUNTER := 1
61+
var total_entry_count := ALTERNATIVE_ENTRIES.size() + NAME_COUNTER
62+
63+
assert(glossary.entries.size() == total_entry_count, "Glossary should have " + str(total_entry_count) + " entries.")
64+
65+
var remove_result: bool = glossary.remove_entry(NAME_ENTRY)
66+
67+
assert(remove_result, "Removal of entry failed.")
68+
assert(glossary.get_entry(NAME_ENTRY).is_empty(), "Entry should not exist.")
69+
assert(glossary.entries.size() == 0, "Glossary should have 0 entries but has " + str(glossary.entries.size()) + " entries.")
70+
71+
72+
func test_add_duplicates() -> void:
73+
var glossary: DialogicGlossary = DialogicGlossary.new()
74+
75+
assert(glossary.try_add_entry(SAMPLE_ENTRY), "Unable to add entry.")
76+
assert(not glossary.try_add_entry(SAMPLE_ENTRY), "Entry should not have been added.")

0 commit comments

Comments
 (0)