Skip to content

Commit

Permalink
Validate file exists for add_translation_from_resource (#118)
Browse files Browse the repository at this point in the history
* `add_translation_from_resource` - Validate file exists

* `add_translation_from_resource` - fix log name in previous commit
  • Loading branch information
ithinkandicode authored Feb 15, 2023
1 parent a3ff6c4 commit a6c7ee8
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions addons/mod_loader/mod_loader.gd
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,10 @@ func register_global_classes_from_array(new_global_classes: Array) -> void:
# file should have been created in Godot already: When you improt a CSV, such
# a file will be created for you.
func add_translation_from_resource(resource_path: String) -> void:
if not File.new().file_exists(resource_path):
ModLoaderUtils.log_fatal("Tried to load a translation resource from a file that doesn't exist. The invalid path was: %s" % [resource_path], LOG_NAME)
return

var translation_object: Translation = load(resource_path)
TranslationServer.add_translation(translation_object)
ModLoaderUtils.log_info("Added Translation from Resource -> %s" % resource_path, LOG_NAME)
Expand Down

0 comments on commit a6c7ee8

Please sign in to comment.