From f6c8242e7273b50a923ae0d5c59753505fa9df9b Mon Sep 17 00:00:00 2001 From: frosty Date: Mon, 6 Apr 2026 01:56:11 -0400 Subject: feat: setting default locale for instance --- src/Utility/Utility.c | 12 +++++++++++- src/Utility/Utility.h | 1 + 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'src/Utility') diff --git a/src/Utility/Utility.c b/src/Utility/Utility.c index e6a4549..8bcb748 100644 --- a/src/Utility/Utility.c +++ b/src/Utility/Utility.c @@ -5,6 +5,15 @@ #include #include +static char global_default_locale[32] = "en_gb"; + +void set_default_locale(const char *locale) { + if (locale && strlen(locale) > 0) { + strncpy(global_default_locale, locale, sizeof(global_default_locale) - 1); + global_default_locale[sizeof(global_default_locale) - 1] = '\0'; + } +} + int hex_to_int(char c) { if (c >= '0' && c <= '9') return c - '0'; @@ -32,7 +41,8 @@ char *get_locale(const char *default_locale) { return cookie; } free(cookie); - return strdup(default_locale); + const char *fallback = default_locale ? default_locale : global_default_locale; + return strdup(fallback); } static int engine_id_casecmp(const char *a, const char *b) { diff --git a/src/Utility/Utility.h b/src/Utility/Utility.h index e00e50c..bd48295 100644 --- a/src/Utility/Utility.h +++ b/src/Utility/Utility.h @@ -15,6 +15,7 @@ int hex_to_int(char c); char *get_theme(const char *default_theme); +void set_default_locale(const char *locale); char *get_locale(const char *default_locale); int is_engine_id_enabled(const char *engine_id); -- cgit v1.2.3