master ohmu/fastfetch-openbsd / src / detection / locale / locale_linux.c
ohmu  ·  2026-10-15
 1#include "detection/locale/locale.h"
 2#include "common/debug.h"
 3
 4#include <locale.h>
 5
 6const char* ffDetectLocale(FFstrbuf* result) {
 7    ffStrbufAppendS(result, getenv("LC_ALL"));
 8    if (result->length > 0) {
 9        return nullptr;
10    }
11
12    ffStrbufAppendS(result, getenv("LANG"));
13    if (result->length > 0) {
14        return nullptr;
15    }
16
17    ffStrbufAppendS(result, setlocale(LC_TIME, nullptr));
18    if (result->length > 0) {
19        return nullptr;
20    }
21
22    FF_DEBUG("LC_ALL, LANG and setlocale(LC_TIME, nullptr) are all empty");
23    return "Failed to detect locale";
24}