Path: blob/master/thirdparty/sdl/include/SDL3/SDL_locale.h
9912 views
/*1Simple DirectMedia Layer2Copyright (C) 1997-2025 Sam Lantinga <[email protected]>34This software is provided 'as-is', without any express or implied5warranty. In no event will the authors be held liable for any damages6arising from the use of this software.78Permission is granted to anyone to use this software for any purpose,9including commercial applications, and to alter it and redistribute it10freely, subject to the following restrictions:11121. The origin of this software must not be misrepresented; you must not13claim that you wrote the original software. If you use this software14in a product, an acknowledgment in the product documentation would be15appreciated but is not required.162. Altered source versions must be plainly marked as such, and must not be17misrepresented as being the original software.183. This notice may not be removed or altered from any source distribution.19*/2021/**22* # CategoryLocale23*24* SDL locale services.25*26* This provides a way to get a list of preferred locales (language plus27* country) for the user. There is exactly one function:28* SDL_GetPreferredLocales(), which handles all the heavy lifting, and offers29* documentation on all the strange ways humans might have configured their30* language settings.31*/3233#ifndef SDL_locale_h34#define SDL_locale_h3536#include <SDL3/SDL_stdinc.h>37#include <SDL3/SDL_error.h>3839#include <SDL3/SDL_begin_code.h>40/* Set up for C function definitions, even when using C++ */41#ifdef __cplusplus42/* *INDENT-OFF* */43extern "C" {44/* *INDENT-ON* */45#endif4647/**48* A struct to provide locale data.49*50* Locale data is split into a spoken language, like English, and an optional51* country, like Canada. The language will be in ISO-639 format (so English52* would be "en"), and the country, if not NULL, will be an ISO-3166 country53* code (so Canada would be "CA").54*55* \since This function is available since SDL 3.2.0.56*57* \sa SDL_GetPreferredLocales58*/59typedef struct SDL_Locale60{61const char *language; /**< A language name, like "en" for English. */62const char *country; /**< A country, like "US" for America. Can be NULL. */63} SDL_Locale;6465/**66* Report the user's preferred locale.67*68* Returned language strings are in the format xx, where 'xx' is an ISO-63969* language specifier (such as "en" for English, "de" for German, etc).70* Country strings are in the format YY, where "YY" is an ISO-3166 country71* code (such as "US" for the United States, "CA" for Canada, etc). Country72* might be NULL if there's no specific guidance on them (so you might get {73* "en", "US" } for American English, but { "en", NULL } means "English74* language, generically"). Language strings are never NULL, except to75* terminate the array.76*77* Please note that not all of these strings are 2 characters; some are three78* or more.79*80* The returned list of locales are in the order of the user's preference. For81* example, a German citizen that is fluent in US English and knows enough82* Japanese to navigate around Tokyo might have a list like: { "de", "en_US",83* "jp", NULL }. Someone from England might prefer British English (where84* "color" is spelled "colour", etc), but will settle for anything like it: {85* "en_GB", "en", NULL }.86*87* This function returns NULL on error, including when the platform does not88* supply this information at all.89*90* This might be a "slow" call that has to query the operating system. It's91* best to ask for this once and save the results. However, this list can92* change, usually because the user has changed a system preference outside of93* your program; SDL will send an SDL_EVENT_LOCALE_CHANGED event in this case,94* if possible, and you can call this function again to get an updated copy of95* preferred locales.96*97* \param count a pointer filled in with the number of locales returned, may98* be NULL.99* \returns a NULL terminated array of locale pointers, or NULL on failure;100* call SDL_GetError() for more information. This is a single101* allocation that should be freed with SDL_free() when it is no102* longer needed.103*104* \since This function is available since SDL 3.2.0.105*/106extern SDL_DECLSPEC SDL_Locale ** SDLCALL SDL_GetPreferredLocales(int *count);107108/* Ends C function definitions when using C++ */109#ifdef __cplusplus110/* *INDENT-OFF* */111}112/* *INDENT-ON* */113#endif114#include <SDL3/SDL_close_code.h>115116#endif /* SDL_locale_h */117118119