diff options
| -rw-r--r-- | beaker.h | 1 | ||||
| -rw-r--r-- | src/l10n.c | 17 |
2 files changed, 18 insertions, 0 deletions
@@ -119,6 +119,7 @@ int beaker_load_locales(void); void beaker_set_locale(TemplateContext *ctx, const char *locale_id); int beaker_get_all_locales(LocaleInfo *out, int max_count); const LocaleMeta *beaker_get_locale_meta(const char *locale_id); +const char *beaker_get_locale_value(const char *locale_id, const char *key); void beaker_free_locales(void); void send_response(const char *html); @@ -247,6 +247,23 @@ const LocaleMeta *beaker_get_locale_meta(const char *locale_id) { return NULL; } +const char *beaker_get_locale_value(const char *locale_id, const char *key) { + if (locale_id == NULL || key == NULL) { + return NULL; + } + for (int i = 0; i < locale_count; i++) { + if (strcmp(locales[i].meta.id, locale_id) == 0) { + for (int j = 0; j < locales[i].key_count; j++) { + if (strcmp(locales[i].keys[j].key, key) == 0) { + return locales[i].keys[j].value; + } + } + return NULL; + } + } + return NULL; +} + void beaker_free_locales(void) { for (int i = 0; i < locale_count; i++) { free(locales[i].keys); |
