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