diff options
| author | 2025-01-05 08:19:27 +0100 | |
|---|---|---|
| committer | 2025-01-05 08:19:27 +0100 | |
| commit | 79d8f5ff032e3d6cb5489f4b97be1987173b0e18 (patch) | |
| tree | 9f7263cba9b143427998fe23acef19133dd51225 /main.c | |
| parent | More /share tweaks. (diff) | |
| download | penes-snac2-79d8f5ff032e3d6cb5489f4b97be1987173b0e18.tar.gz penes-snac2-79d8f5ff032e3d6cb5489f4b97be1987173b0e18.tar.xz penes-snac2-79d8f5ff032e3d6cb5489f4b97be1987173b0e18.zip | |
The 'note' cmdline looks at the LANG env var to set the post's language.
Diffstat (limited to '')
| -rw-r--r-- | main.c | 15 |
1 files changed, 15 insertions, 0 deletions
| @@ -669,6 +669,21 @@ int main(int argc, char *argv[]) | |||
| 669 | 669 | ||
| 670 | msg = msg_note(&snac, content, NULL, NULL, attl, 0); | 670 | msg = msg_note(&snac, content, NULL, NULL, attl, 0); |
| 671 | 671 | ||
| 672 | /* set a post language according the LANG environment variable */ | ||
| 673 | const char *lang_env = getenv("LANG"); | ||
| 674 | if (xs_type(lang_env) == XSTYPE_STRING) { | ||
| 675 | /* split at the first _ */ | ||
| 676 | xs *l0 = xs_split(lang_env, "_"); | ||
| 677 | const char *lang = xs_list_get(l0, 0); | ||
| 678 | |||
| 679 | if (xs_type(lang) == XSTYPE_STRING && strlen(lang) == 2) { | ||
| 680 | /* a valid ISO language id */ | ||
| 681 | xs *cmap = xs_dict_new(); | ||
| 682 | cmap = xs_dict_set(cmap, lang, xs_dict_get(msg, "content")); | ||
| 683 | msg = xs_dict_set(msg, "contentMap", cmap); | ||
| 684 | } | ||
| 685 | } | ||
| 686 | |||
| 672 | c_msg = msg_create(&snac, msg); | 687 | c_msg = msg_create(&snac, msg); |
| 673 | 688 | ||
| 674 | if (dbglevel) { | 689 | if (dbglevel) { |