File tree Expand file tree Collapse file tree 2 files changed +10
-5
lines changed
Expand file tree Collapse file tree 2 files changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -11,8 +11,10 @@ var _glossary := {}
1111# and wrap glossary entries in rich text labels.
1212var _glossary_regex := RegEx .new ()
1313
14-
1514func _init () -> void :
15+ setup ()
16+
17+ func setup () -> void :
1618 _glossary = _parse_glossary_file (glossary_file )
1719 var patterns := PoolStringArray ()
1820 for key in _glossary :
@@ -36,7 +38,7 @@ func get_match(keyword: String) -> Entry:
3638
3739# Parses the input CSV file and returns a dictionary mapping keywords to
3840# glossary entries.
39- static func _parse_glossary_file (path : String ) -> Dictionary :
41+ func _parse_glossary_file (path : String ) -> Dictionary :
4042 var glossary := {}
4143 var file := File .new ()
4244 file .open (path , file .READ )
@@ -47,8 +49,8 @@ static func _parse_glossary_file(path: String) -> Dictionary:
4749 if not csv_line [0 ]:
4850 break
4951
50- var plural_form = csv_line [1 ]
51- var keyword = csv_line [0 ]
52+ var plural_form = tr ( csv_line [1 ])
53+ var keyword = tr ( csv_line [0 ])
5254 assert (not keyword in glossary , "Duplicate key %s in glossary." % keyword )
5355 assert (not plural_form in glossary , "Duplicate key %s in glossary." % keyword )
5456 var entry := Entry .new (csv_line )
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ export var test_lesson: Resource
1818
1919var _lesson : Lesson
2020# Resource used to highlight glossary entries in the lesson text.
21- var _glossary : Glossary = preload ( "res://course/glossary.tres" )
21+ var _glossary : Glossary
2222var _visible_index := - 1
2323var _quizzes_done := - 1 # Start with -1 because we will always autoincrement at least once.
2424var _quizz_count := 0
@@ -49,6 +49,8 @@ func _ready() -> void:
4949 _scroll_container .get_v_scrollbar ().connect ("value_changed" , self , "_on_content_scrolled" )
5050 _debounce_timer .connect ("timeout" , self , "_emit_read_content" )
5151 TranslationManager .connect ("translation_changed" , self , "_on_translation_changed" )
52+
53+ _glossary = load ("res://course/glossary.tres" )
5254
5355 if test_lesson and get_parent () == get_tree ().root :
5456 setup (test_lesson , null )
@@ -184,6 +186,7 @@ func setup(lesson: Lesson, course: Course) -> void:
184186 _emit_read_content ()
185187
186188func _underline_glossary_entries () -> void :
189+ _glossary .setup ()
187190 # Underline glossary entries
188191 for rtl in get_tree ().get_nodes_in_group ("rich_text_label" ):
189192 rtl .bbcode_text = _glossary .replace_matching_terms (rtl .bbcode_text )
You can’t perform that action at this time.
0 commit comments