aboutsummaryrefslogtreecommitdiff
path: root/beaker.h
diff options
context:
space:
mode:
authorfrosty <gabriel@bwaaa.monster>2026-04-03 15:28:10 -0400
committerfrosty <gabriel@bwaaa.monster>2026-04-03 15:28:10 -0400
commit3fab89ecf8f4c664477a82add660d28db87357b4 (patch)
tree07ae926139ede338f92600682418b94fbd697cf7 /beaker.h
parentea9b44e2b88949d0ac6efc0b06118f6d9ccbe980 (diff)
parent3f1ab2576c31da36e7fc3f69694d4d76c8243842 (diff)
downloadbeaker-3fab89ecf8f4c664477a82add660d28db87357b4.tar.gz
Merge branch 'indev'
Diffstat (limited to 'beaker.h')
-rw-r--r--beaker.h37
1 files changed, 37 insertions, 0 deletions
diff --git a/beaker.h b/beaker.h
index 96125d3..cc87634 100644
--- a/beaker.h
+++ b/beaker.h
@@ -20,6 +20,14 @@
#define TEMPLATES_DIR "templates/"
#define STATIC_DIR "static/"
+#define LOCALES_DIR "locales/"
+
+#define INITIAL_LOCALES_CAPACITY 8
+#define INITIAL_LOCALE_KEYS_CAPACITY 16
+#define MAX_LOCALES_HARD 1024
+#define MAX_LOCALE_KEYS_HARD 65536
+#define MAX_LOCALE_ID_LEN 64
+#define MAX_LOCALE_VALUE_LEN 512
typedef enum {
CONTEXT_TYPE_STRING,
@@ -68,6 +76,28 @@ typedef struct {
bool secure;
} Cookie;
+typedef struct {
+ char id[MAX_LOCALE_ID_LEN];
+ char name[MAX_VALUE_LEN];
+ char direction[16];
+} LocaleMeta;
+
+typedef struct {
+ char key[MAX_KEY_LEN];
+ char value[MAX_LOCALE_VALUE_LEN];
+} LocaleKV;
+
+typedef struct {
+ LocaleMeta meta;
+ LocaleKV *keys;
+ int key_count;
+ int key_capacity;
+} Locale;
+
+typedef struct {
+ LocaleMeta meta;
+} LocaleInfo;
+
typedef int (*RequestHandler)(UrlParams *params);
typedef struct {
@@ -85,6 +115,13 @@ void context_set_array_of_arrays(TemplateContext *ctx, const char *key,
void free_context(TemplateContext *ctx);
char *render_template(const char *template_file, TemplateContext *ctx);
+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);
void send_redirect(const char *location);
void set_cookie(const char *name, const char *value, const char *expires,