Skip to content

Commit 49cc9c9

Browse files
Make Text Input event translatable (#2667)
* Make text input strings translatable
1 parent 0c22d94 commit 49cc9c9

File tree

2 files changed

+27
-13
lines changed

2 files changed

+27
-13
lines changed

addons/dialogic/Modules/Text/event_text.gd

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,7 @@ func _init() -> void:
285285

286286

287287

288-
################################################################################
289-
## SAVING/LOADING
288+
#region SAVING/LOADING
290289
################################################################################
291290

292291
func to_text() -> String:

addons/dialogic/Modules/TextInput/event_text_input.gd

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,21 @@ var default := ""
1919
var allow_empty := false
2020

2121

22-
################################################################################
23-
## EXECUTION
22+
#region EXECUTION
2423
################################################################################
2524

2625
func _execute() -> void:
2726
dialogic.Inputs.auto_skip.enabled = false
2827
dialogic.current_state = DialogicGameHandler.States.WAITING
29-
dialogic.TextInput.show_text_input(text, default, placeholder, allow_empty)
28+
dialogic.TextInput.show_text_input(
29+
get_property_translated("text"),
30+
get_property_translated("default"),
31+
get_property_translated("placeholder"), allow_empty)
3032
dialogic.TextInput.input_confirmed.connect(_on_DialogicTextInput_input_confirmed, CONNECT_ONE_SHOT)
3133

3234

3335
func _on_DialogicTextInput_input_confirmed(input:String) -> void:
34-
if !dialogic.has_subsystem('VAR'):
36+
if not dialogic.has_subsystem('VAR'):
3537
printerr('[Dialogic] The TextInput event needs the variable subsystem to be present.')
3638
finish()
3739
return
@@ -41,8 +43,7 @@ func _on_DialogicTextInput_input_confirmed(input:String) -> void:
4143
finish()
4244

4345

44-
################################################################################
45-
## SAVING/LOADING
46+
#region SETUP
4647
################################################################################
4748

4849
func _init() -> void:
@@ -52,8 +53,7 @@ func _init() -> void:
5253
event_sorting_index = 6
5354

5455

55-
################################################################################
56-
## SAVING/LOADING
56+
#region SAVING/LOADING
5757
################################################################################
5858

5959
func get_shortcode() -> String:
@@ -70,8 +70,23 @@ func get_shortcode_parameters() -> Dictionary:
7070
"allow_empty" : {"property": "allow_empty", "default": false},
7171
}
7272

73-
################################################################################
74-
## EDITOR
73+
74+
func _get_translatable_properties() -> Array:
75+
return ["text", "placeholder", "default"]
76+
77+
78+
func _get_property_original_translation(property_name:String) -> String:
79+
match property_name:
80+
"text":
81+
return text
82+
"placeholder":
83+
return placeholder
84+
"default":
85+
return default
86+
return ""
87+
88+
89+
#region EDITOR
7590
################################################################################
7691

7792
func build_event_editor() -> void:
@@ -86,7 +101,7 @@ func build_event_editor() -> void:
86101
add_body_edit('allow_empty', ValueType.BOOL, {'left_text':'Allow empty:'})
87102

88103

89-
func get_var_suggestions(filter:String="") -> Dictionary:
104+
func get_var_suggestions(filter: String = "") -> Dictionary:
90105
var suggestions := {}
91106
if filter:
92107
suggestions[filter] = {

0 commit comments

Comments
 (0)