2021-02-18 22:25:36 +01:00
|
|
|
#include "fastfetch.h"
|
2022-12-16 11:21:14 +08:00
|
|
|
#include "common/printing.h"
|
|
|
|
|
#include "detection/locale/locale.h"
|
2022-06-18 14:25:31 +02:00
|
|
|
|
2021-04-15 18:59:26 +02:00
|
|
|
#define FF_LOCALE_MODULE_NAME "Locale"
|
|
|
|
|
#define FF_LOCALE_NUM_FORMAT_ARGS 1
|
|
|
|
|
|
2021-02-27 18:30:05 +01:00
|
|
|
void ffPrintLocale(FFinstance* instance)
|
2021-02-18 22:25:36 +01:00
|
|
|
{
|
2022-12-16 11:21:14 +08:00
|
|
|
FFstrbuf locale;
|
2021-05-13 12:27:44 +02:00
|
|
|
ffStrbufInit(&locale);
|
|
|
|
|
|
2022-12-16 11:21:14 +08:00
|
|
|
ffDetectLocale(&locale);
|
2021-05-13 12:27:44 +02:00
|
|
|
if(locale.length == 0)
|
2021-04-15 18:59:26 +02:00
|
|
|
{
|
2022-06-17 18:15:36 +02:00
|
|
|
ffPrintError(instance, FF_LOCALE_MODULE_NAME, 0, &instance->config.locale, "No locale found");
|
2021-04-15 18:59:26 +02:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-17 11:39:10 +08:00
|
|
|
if(instance->config.locale.outputFormat.length == 0)
|
|
|
|
|
{
|
|
|
|
|
ffPrintLogoAndKey(instance, FF_LOCALE_MODULE_NAME, 0, &instance->config.locale.key);
|
|
|
|
|
ffStrbufPutTo(&locale, stdout);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ffPrintFormat(instance, FF_LOCALE_MODULE_NAME, 0, &instance->config.locale, FF_LOCALE_NUM_FORMAT_ARGS, (FFformatarg[]){
|
|
|
|
|
{FF_FORMAT_ARG_TYPE_STRBUF, &locale}
|
|
|
|
|
});
|
|
|
|
|
}
|
2021-03-19 20:57:07 +01:00
|
|
|
|
2022-12-16 11:21:14 +08:00
|
|
|
ffStrbufDestroy(&locale);
|
2021-03-20 10:39:05 +01:00
|
|
|
}
|