Skip to content

Commit 464a57b

Browse files
committed
Locale: simply
1 parent d31d157 commit 464a57b

File tree

1 file changed

+6
-21
lines changed

1 file changed

+6
-21
lines changed

src/modules/locale.c

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "common/parsing.h"
77

88
#include <stdlib.h>
9+
#include <locale.h>
910

1011
#define FF_LOCALE_MODULE_NAME "Locale"
1112
#define FF_LOCALE_NUM_FORMAT_ARGS 1
@@ -25,27 +26,11 @@ static void getLocaleFromEnv(FFstrbuf* locale)
2526

2627
static void getLocaleFromCmd(FFstrbuf* locale)
2728
{
28-
FFstrbuf buffer;
29-
ffStrbufInitA(&buffer, 0);
30-
char* args[] = { "locale", NULL };
31-
if(ffProcessAppendStdOut(&buffer, args) == NULL)
32-
{
33-
ffParsePropLines(buffer.chars, "LANG=\"", locale);
34-
ffStrbufTrimRight(locale, '"');
35-
36-
if(locale->length == 0)
37-
{
38-
ffParsePropLines(buffer.chars, "LC_ALL=\"", locale);
39-
ffStrbufTrimRight(locale, '"');
40-
41-
if(locale->length == 0)
42-
{
43-
ffParsePropLines(buffer.chars, "LC_MESSAGES=\"", locale);
44-
ffStrbufTrimRight(locale, '"');
45-
}
46-
}
47-
}
48-
ffStrbufDestroy(&buffer);
29+
ffStrbufAppendS(locale, setlocale(LC_ALL, NULL));
30+
if(locale->length > 0)
31+
return;
32+
33+
ffStrbufAppendS(locale, setlocale(LC_MESSAGES, NULL));
4934
}
5035

5136
void ffPrintLocale(FFinstance* instance)

0 commit comments

Comments
 (0)