aboutsummaryrefslogtreecommitdiff
path: root/extension/src/openvic-extension/singletons/LoadLocalisation.hpp
diff options
context:
space:
mode:
author Hop311 <Hop3114@gmail.com>2023-11-17 21:17:55 +0100
committer GitHub <noreply@github.com>2023-11-17 21:17:55 +0100
commit9165f5980c5cfe75b3bad4303a5822340f6adcfc (patch)
tree79a69cb7601bf1367e4ee4f10ebf61b698319bf3 /extension/src/openvic-extension/singletons/LoadLocalisation.hpp
parent72d893d55d26ae9dc6739a853d1773b3cb286123 (diff)
parentaefc61a1aff091e31436c60d004531b5905cecba (diff)
Merge pull request #166 from OpenVicProject/gui
GUI elements -> Godot UI nodes generator
Diffstat (limited to 'extension/src/openvic-extension/singletons/LoadLocalisation.hpp')
-rw-r--r--extension/src/openvic-extension/singletons/LoadLocalisation.hpp31
1 files changed, 31 insertions, 0 deletions
diff --git a/extension/src/openvic-extension/singletons/LoadLocalisation.hpp b/extension/src/openvic-extension/singletons/LoadLocalisation.hpp
new file mode 100644
index 0000000..b093fdf
--- /dev/null
+++ b/extension/src/openvic-extension/singletons/LoadLocalisation.hpp
@@ -0,0 +1,31 @@
+#pragma once
+
+#include <godot_cpp/classes/translation.hpp>
+
+#include <openvic-simulation/dataloader/Dataloader.hpp>
+
+namespace OpenVic {
+ class LoadLocalisation : public godot::Object {
+ GDCLASS(LoadLocalisation, godot::Object)
+
+ static inline LoadLocalisation* _singleton = nullptr;
+
+ godot::Error _load_file(godot::String const& file_path, godot::Ref<godot::Translation> translation) const;
+ godot::Ref<godot::Translation> _get_translation(godot::String const& locale) const;
+
+ protected:
+ static void _bind_methods();
+
+ public:
+ static LoadLocalisation* get_singleton();
+
+ LoadLocalisation();
+ ~LoadLocalisation();
+
+ godot::Error load_file(godot::String const& file_path, godot::String const& locale) const;
+ godot::Error load_locale_dir(godot::String const& dir_path, godot::String const& locale) const;
+ godot::Error load_localisation_dir(godot::String const& dir_path) const;
+
+ static bool add_message(std::string_view key, Dataloader::locale_t locale, std::string_view localisation);
+ };
+}