SDL_locale.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*
  2. Simple DirectMedia Layer
  3. Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
  4. This software is provided 'as-is', without any express or implied
  5. warranty. In no event will the authors be held liable for any damages
  6. arising from the use of this software.
  7. Permission is granted to anyone to use this software for any purpose,
  8. including commercial applications, and to alter it and redistribute it
  9. freely, subject to the following restrictions:
  10. 1. The origin of this software must not be misrepresented; you must not
  11. claim that you wrote the original software. If you use this software
  12. in a product, an acknowledgment in the product documentation would be
  13. appreciated but is not required.
  14. 2. Altered source versions must be plainly marked as such, and must not be
  15. misrepresented as being the original software.
  16. 3. This notice may not be removed or altered from any source distribution.
  17. */
  18. /**
  19. * \file SDL_locale.h
  20. *
  21. * Include file for SDL locale services
  22. */
  23. #ifndef _SDL_locale_h
  24. #define _SDL_locale_h
  25. #include "SDL_stdinc.h"
  26. #include "SDL_error.h"
  27. #include "begin_code.h"
  28. /* Set up for C function definitions, even when using C++ */
  29. #ifdef __cplusplus
  30. /* *INDENT-OFF* */
  31. extern "C" {
  32. /* *INDENT-ON* */
  33. #endif
  34. typedef struct SDL_Locale
  35. {
  36. const char *language; /**< A language name, like "en" for English. */
  37. const char *country; /**< A country, like "US" for America. Can be NULL. */
  38. } SDL_Locale;
  39. /**
  40. * \brief Report the user's preferred locale.
  41. *
  42. * This returns an array of SDL_Locale structs, the final item zeroed out.
  43. * When the caller is done with this array, it should call SDL_free() on
  44. * the returned value; all the memory involved is allocated in a single
  45. * block, so a single SDL_free() will suffice.
  46. *
  47. * Returned language strings are in the format xx, where 'xx' is an ISO-639
  48. * language specifier (such as "en" for English, "de" for German, etc).
  49. * Country strings are in the format YY, where "YY" is an ISO-3166 country
  50. * code (such as "US" for the United States, "CA" for Canada, etc). Country
  51. * might be NULL if there's no specific guidance on them (so you might get
  52. * { "en", "US" } for American English, but { "en", NULL } means "English
  53. * language, generically"). Language strings are never NULL, except to
  54. * terminate the array.
  55. *
  56. * Please note that not all of these strings are 2 characters; some are
  57. * three or more.
  58. *
  59. * The returned list of locales are in the order of the user's preference.
  60. * For example, a German citizen that is fluent in US English and knows
  61. * enough Japanese to navigate around Tokyo might have a list like:
  62. * { "de", "en_US", "jp", NULL }. Someone from England might prefer British
  63. * English (where "color" is spelled "colour", etc), but will settle for
  64. * anything like it: { "en_GB", "en", NULL }.
  65. *
  66. * This function returns NULL on error, including when the platform does not
  67. * supply this information at all.
  68. *
  69. * This might be a "slow" call that has to query the operating system. It's
  70. * best to ask for this once and save the results. However, this list can
  71. * change, usually because the user has changed a system preference outside
  72. * of your program; SDL will send an SDL_LOCALECHANGED event in this case,
  73. * if possible, and you can call this function again to get an updated copy
  74. * of preferred locales.
  75. *
  76. * \return array of locales, terminated with a locale with a NULL language
  77. * field. Will return NULL on error.
  78. */
  79. extern DECLSPEC SDL_Locale * SDLCALL SDL_GetPreferredLocales(void);
  80. /* Ends C function definitions when using C++ */
  81. #ifdef __cplusplus
  82. /* *INDENT-OFF* */
  83. }
  84. /* *INDENT-ON* */
  85. #endif
  86. #include "close_code.h"
  87. #endif /* _SDL_locale_h */
  88. /* vi: set ts=4 sw=4 expandtab: */