chiark / gitweb /
775fe8bc728af79e9497547e618feaecf306d4c7
[elogind.git] / src / basic / locale-util.h
1 /* SPDX-License-Identifier: LGPL-2.1+ */
2 #pragma once
3
4 #include <libintl.h>
5 #include <stdbool.h>
6 #include <locale.h>
7
8 #include "macro.h"
9
10 typedef enum LocaleVariable {
11         /* We don't list LC_ALL here on purpose. People should be
12          * using LANG instead. */
13
14         VARIABLE_LANG,
15         VARIABLE_LANGUAGE,
16         VARIABLE_LC_CTYPE,
17         VARIABLE_LC_NUMERIC,
18         VARIABLE_LC_TIME,
19         VARIABLE_LC_COLLATE,
20         VARIABLE_LC_MONETARY,
21         VARIABLE_LC_MESSAGES,
22         VARIABLE_LC_PAPER,
23         VARIABLE_LC_NAME,
24         VARIABLE_LC_ADDRESS,
25         VARIABLE_LC_TELEPHONE,
26         VARIABLE_LC_MEASUREMENT,
27         VARIABLE_LC_IDENTIFICATION,
28         _VARIABLE_LC_MAX,
29         _VARIABLE_LC_INVALID = -1
30 } LocaleVariable;
31
32 int get_locales(char ***l);
33 bool locale_is_valid(const char *name);
34
35 #define _(String) gettext(String)
36 #define N_(String) String
37 void init_gettext(void);
38
39 bool is_locale_utf8(void);
40
41 typedef enum {
42         TREE_VERTICAL,
43         TREE_BRANCH,
44         TREE_RIGHT,
45         TREE_SPACE,
46         TRIANGULAR_BULLET,
47         BLACK_CIRCLE,
48         ARROW,
49         MDASH,
50         ELLIPSIS,
51         _SPECIAL_GLYPH_MAX
52 } SpecialGlyph;
53
54 const char *special_glyph(SpecialGlyph code) _const_;
55
56 const char* locale_variable_to_string(LocaleVariable i) _const_;
57 LocaleVariable locale_variable_from_string(const char *s) _pure_;
58
59 int get_keymaps(char ***l);
60 bool keymap_is_valid(const char *name);
61
62 static inline void freelocalep(locale_t *p) {
63         if (*p == (locale_t) 0)
64                 return;
65
66         freelocale(*p);
67 }