diff options
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); |
