|
1
|
1 /*
|
|
|
2 Simple DirectMedia Layer
|
|
|
3 Copyright (C) 1997-2025 Sam Lantinga <slouken@libsdl.org>
|
|
|
4
|
|
|
5 This software is provided 'as-is', without any express or implied
|
|
|
6 warranty. In no event will the authors be held liable for any damages
|
|
|
7 arising from the use of this software.
|
|
|
8
|
|
|
9 Permission is granted to anyone to use this software for any purpose,
|
|
|
10 including commercial applications, and to alter it and redistribute it
|
|
|
11 freely, subject to the following restrictions:
|
|
|
12
|
|
|
13 1. The origin of this software must not be misrepresented; you must not
|
|
|
14 claim that you wrote the original software. If you use this software
|
|
|
15 in a product, an acknowledgment in the product documentation would be
|
|
|
16 appreciated but is not required.
|
|
|
17 2. Altered source versions must be plainly marked as such, and must not be
|
|
|
18 misrepresented as being the original software.
|
|
|
19 3. This notice may not be removed or altered from any source distribution.
|
|
|
20 */
|
|
|
21
|
|
|
22 /**
|
|
|
23 * # CategoryLocale
|
|
|
24 *
|
|
|
25 * SDL locale services.
|
|
|
26 *
|
|
|
27 * This provides a way to get a list of preferred locales (language plus
|
|
|
28 * country) for the user. There is exactly one function:
|
|
|
29 * SDL_GetPreferredLocales(), which handles all the heavy lifting, and offers
|
|
|
30 * documentation on all the strange ways humans might have configured their
|
|
|
31 * language settings.
|
|
|
32 */
|
|
|
33
|
|
|
34 #ifndef SDL_locale_h
|
|
|
35 #define SDL_locale_h
|
|
|
36
|
|
|
37 #include <SDL3/SDL_stdinc.h>
|
|
|
38 #include <SDL3/SDL_error.h>
|
|
|
39
|
|
|
40 #include <SDL3/SDL_begin_code.h>
|
|
|
41 /* Set up for C function definitions, even when using C++ */
|
|
|
42 #ifdef __cplusplus
|
|
|
43 /* *INDENT-OFF* */
|
|
|
44 extern "C" {
|
|
|
45 /* *INDENT-ON* */
|
|
|
46 #endif
|
|
|
47
|
|
|
48 /**
|
|
|
49 * A struct to provide locale data.
|
|
|
50 *
|
|
|
51 * Locale data is split into a spoken language, like English, and an optional
|
|
|
52 * country, like Canada. The language will be in ISO-639 format (so English
|
|
|
53 * would be "en"), and the country, if not NULL, will be an ISO-3166 country
|
|
|
54 * code (so Canada would be "CA").
|
|
|
55 *
|
|
|
56 * \since This function is available since SDL 3.2.0.
|
|
|
57 *
|
|
|
58 * \sa SDL_GetPreferredLocales
|
|
|
59 */
|
|
|
60 typedef struct SDL_Locale
|
|
|
61 {
|
|
|
62 const char *language; /**< A language name, like "en" for English. */
|
|
|
63 const char *country; /**< A country, like "US" for America. Can be NULL. */
|
|
|
64 } SDL_Locale;
|
|
|
65
|
|
|
66 /**
|
|
|
67 * Report the user's preferred locale.
|
|
|
68 *
|
|
|
69 * Returned language strings are in the format xx, where 'xx' is an ISO-639
|
|
|
70 * language specifier (such as "en" for English, "de" for German, etc).
|
|
|
71 * Country strings are in the format YY, where "YY" is an ISO-3166 country
|
|
|
72 * code (such as "US" for the United States, "CA" for Canada, etc). Country
|
|
|
73 * might be NULL if there's no specific guidance on them (so you might get {
|
|
|
74 * "en", "US" } for American English, but { "en", NULL } means "English
|
|
|
75 * language, generically"). Language strings are never NULL, except to
|
|
|
76 * terminate the array.
|
|
|
77 *
|
|
|
78 * Please note that not all of these strings are 2 characters; some are three
|
|
|
79 * or more.
|
|
|
80 *
|
|
|
81 * The returned list of locales are in the order of the user's preference. For
|
|
|
82 * example, a German citizen that is fluent in US English and knows enough
|
|
|
83 * Japanese to navigate around Tokyo might have a list like: { "de", "en_US",
|
|
|
84 * "jp", NULL }. Someone from England might prefer British English (where
|
|
|
85 * "color" is spelled "colour", etc), but will settle for anything like it: {
|
|
|
86 * "en_GB", "en", NULL }.
|
|
|
87 *
|
|
|
88 * This function returns NULL on error, including when the platform does not
|
|
|
89 * supply this information at all.
|
|
|
90 *
|
|
|
91 * This might be a "slow" call that has to query the operating system. It's
|
|
|
92 * best to ask for this once and save the results. However, this list can
|
|
|
93 * change, usually because the user has changed a system preference outside of
|
|
|
94 * your program; SDL will send an SDL_EVENT_LOCALE_CHANGED event in this case,
|
|
|
95 * if possible, and you can call this function again to get an updated copy of
|
|
|
96 * preferred locales.
|
|
|
97 *
|
|
|
98 * \param count a pointer filled in with the number of locales returned, may
|
|
|
99 * be NULL.
|
|
|
100 * \returns a NULL terminated array of locale pointers, or NULL on failure;
|
|
|
101 * call SDL_GetError() for more information. This is a single
|
|
|
102 * allocation that should be freed with SDL_free() when it is no
|
|
|
103 * longer needed.
|
|
|
104 *
|
|
|
105 * \since This function is available since SDL 3.2.0.
|
|
|
106 */
|
|
|
107 extern SDL_DECLSPEC SDL_Locale ** SDLCALL SDL_GetPreferredLocales(int *count);
|
|
|
108
|
|
|
109 /* Ends C function definitions when using C++ */
|
|
|
110 #ifdef __cplusplus
|
|
|
111 /* *INDENT-OFF* */
|
|
|
112 }
|
|
|
113 /* *INDENT-ON* */
|
|
|
114 #endif
|
|
|
115 #include <SDL3/SDL_close_code.h>
|
|
|
116
|
|
|
117 #endif /* SDL_locale_h */
|