diff options
Diffstat (limited to 'core/os')
-rw-r--r-- | core/os/os.cpp | 6 | ||||
-rw-r--r-- | core/os/os.h | 1 |
2 files changed, 7 insertions, 0 deletions
diff --git a/core/os/os.cpp b/core/os/os.cpp index dc3fe29dca..7505f3ff34 100644 --- a/core/os/os.cpp +++ b/core/os/os.cpp @@ -231,6 +231,12 @@ String OS::get_locale() const { return "en"; } +// Non-virtual helper to extract the 2 or 3-letter language code from +// `get_locale()` in a way that's consistent for all platforms. +String OS::get_locale_language() const { + return get_locale().left(3).replace("_", ""); +} + // Helper function to ensure that a dir name/path will be valid on the OS String OS::get_safe_dir_name(const String &p_dir_name, bool p_allow_dir_separator) const { Vector<String> invalid_chars = String(": * ? \" < > |").split(" "); diff --git a/core/os/os.h b/core/os/os.h index f585483300..c027428477 100644 --- a/core/os/os.h +++ b/core/os/os.h @@ -243,6 +243,7 @@ public: RenderThreadMode get_render_thread_mode() const { return _render_thread_mode; } virtual String get_locale() const; + String get_locale_language() const; String get_safe_dir_name(const String &p_dir_name, bool p_allow_dir_separator = false) const; virtual String get_godot_dir_name() const; |