aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--beaker.h1
-rw-r--r--src/l10n.c17
2 files changed, 18 insertions, 0 deletions
diff --git a/beaker.h b/beaker.h
index a5f374e..cc87634 100644
--- a/beaker.h
+++ b/beaker.h
@@ -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);
diff --git a/src/l10n.c b/src/l10n.c
index f6e748f..4d8ac30 100644
--- a/src/l10n.c
+++ b/src/l10n.c
@@ -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);