1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
// This is an open source non-commercial project. Dear PVS-Studio, please check
// it. PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
#ifdef __APPLE__
# define Boolean CFBoolean // Avoid conflict with API's Boolean
# define FileInfo CSFileInfo // Avoid conflict with API's Fileinfo
# include <CoreServices/CoreServices.h>
# undef Boolean
# undef FileInfo
# include "auto/config.h"
# ifdef HAVE_LOCALE_H
# include <locale.h>
# endif
# include "nvim/os/os.h"
#endif
#include "nvim/os/lang.h"
void lang_init(void)
{
#ifdef __APPLE__
if (os_getenv("LANG") == NULL) {
char buf[50] = { 0 };
// $LANG is not set, either because it was unset or Nvim was started
// from the Dock. Query the system locale.
if (LocaleRefGetPartString(NULL,
kLocaleLanguageMask | kLocaleLanguageVariantMask |
kLocaleRegionMask | kLocaleRegionVariantMask,
sizeof(buf) - 10, buf) == noErr && *buf) {
if (strcasestr(buf, "utf-8") == NULL) {
xstrlcat(buf, ".UTF-8", sizeof(buf));
}
os_setenv("LANG", buf, true);
setlocale(LC_ALL, "");
// Make sure strtod() uses a decimal point, not a comma.
setlocale(LC_NUMERIC, "C");
} else {
ELOG("$LANG is empty and the macOS primary language cannot be inferred.");
}
}
#endif
}
|