diff options
| author | frosty <gabriel@bwaaa.monster> | 2026-04-06 01:56:11 -0400 |
|---|---|---|
| committer | frosty <gabriel@bwaaa.monster> | 2026-04-06 01:56:11 -0400 |
| commit | f6c8242e7273b50a923ae0d5c59753505fa9df9b (patch) | |
| tree | b28979fd48a38dc3245babfadd2aef62c4099cb4 /src/Utility | |
| parent | e0c209c974b130a5e893c7d7b3d342f4ec325c8d (diff) | |
| download | omnisearch-f6c8242e7273b50a923ae0d5c59753505fa9df9b.tar.gz | |
feat: setting default locale for instanceindev
Diffstat (limited to 'src/Utility')
| -rw-r--r-- | src/Utility/Utility.c | 12 | ||||
| -rw-r--r-- | src/Utility/Utility.h | 1 |
2 files changed, 12 insertions, 1 deletions
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 <stdlib.h> #include <string.h> +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); |
