commit 79d8f5ff032e3d6cb5489f4b97be1987173b0e18
parent b7ab926c25c27285fd6eb6e31258dc57979b157d
Author: default <nobody@localhost>
Date: Sun, 5 Jan 2025 08:19:27 +0100
The 'note' cmdline looks at the LANG env var to set the post's language.
Diffstat:
1 file changed, 15 insertions(+), 0 deletions(-)
diff --git a/main.c b/main.c
@@ -669,6 +669,21 @@ int main(int argc, char *argv[])
msg = msg_note(&snac, content, NULL, NULL, attl, 0);
+ /* set a post language according the LANG environment variable */
+ const char *lang_env = getenv("LANG");
+ if (xs_type(lang_env) == XSTYPE_STRING) {
+ /* split at the first _ */
+ xs *l0 = xs_split(lang_env, "_");
+ const char *lang = xs_list_get(l0, 0);
+
+ if (xs_type(lang) == XSTYPE_STRING && strlen(lang) == 2) {
+ /* a valid ISO language id */
+ xs *cmap = xs_dict_new();
+ cmap = xs_dict_set(cmap, lang, xs_dict_get(msg, "content"));
+ msg = xs_dict_set(msg, "contentMap", cmap);
+ }
+ }
+
c_msg = msg_create(&snac, msg);
if (dbglevel) {