Skip to content

Commit 1179a65

Browse files
Add SDL_locale.inc
1 parent 0b476b8 commit 1179a65

File tree

2 files changed

+85
-0
lines changed

2 files changed

+85
-0
lines changed

units/SDL3.pas

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ interface
7979
{$I SDL_log.inc} // 3.1.6-prev
8080
{$I SDL_version.inc} // 3.1.6-prev
8181
{$I SDL_revision.inc} // 3.1.6-prev
82+
{$I SDL_locale.inc} // 3.2.0
8283
{$I SDL_guid.inc} // 3.1.6-prev
8384
{$I SDL_hints.inc} // 3.2.0
8485
{$I SDL_stdinc.inc} // 3.1.6-prev (unfinished)

units/SDL_locale.inc

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
{
2+
This file is part of:
3+
4+
SDL3 for Pascal
5+
(https://github.com/PascalGameDevelopment/SDL3-for-Pascal)
6+
SPDX-License-Identifier: Zlib
7+
}
8+
9+
{*
10+
* # CategoryLocale
11+
*
12+
* SDL locale services.
13+
*
14+
* This provides a way to get a list of preferred locales (language plus
15+
* country) for the user. There is exactly one function:
16+
* SDL_GetPreferredLocales(), which handles all the heavy lifting, and offers
17+
* documentation on all the strange ways humans might have configured their
18+
* language settings.
19+
}
20+
21+
{*
22+
* A struct to provide locale data.
23+
*
24+
* Locale data is split into a spoken language, like English, and an optional
25+
* country, like Canada. The language will be in ISO-639 format (so English
26+
* would be "en"), and the country, if not nil, will be an ISO-3166 country
27+
* code (so Canada would be "CA").
28+
*
29+
* \since This function is available since SDL 3.2.0.
30+
*
31+
* \sa SDL_GetPreferredLocales
32+
}
33+
type
34+
PPSDL_Locale = ^PSDL_Locale;
35+
PSDL_Locale = ^TSDL_Locale;
36+
TSDL_Locale = record
37+
language: PAnsiChar; {*< A language name, like "en" for English. }
38+
country: PAnsiChar; {*< A country, like "US" for America. Can be nil. }
39+
end;
40+
41+
{*
42+
* Report the user's preferred locale.
43+
*
44+
* Returned language strings are in the format xx, where 'xx' is an ISO-639
45+
* language specifier (such as "en" for English, "de" for German, etc).
46+
* Country strings are in the format YY, where "YY" is an ISO-3166 country
47+
* code (such as "US" for the United States, "CA" for Canada, etc). Country
48+
* might be nil if there's no specific guidance on them (so you might get
49+
* "en", "US" for American English, but "en", nil means "English
50+
* language, generically"). Language strings are never nil, except to
51+
* terminate the array.
52+
*
53+
* Please note that not all of these strings are 2 characters; some are three
54+
* or more.
55+
*
56+
* The returned list of locales are in the order of the user's preference. For
57+
* example, a German citizen that is fluent in US English and knows enough
58+
* Japanese to navigate around Tokyo might have a list like: "de", "en_US",
59+
* "jp", nil . Someone from England might prefer British English (where
60+
* "color" is spelled "colour", etc), but will settle for anything like it:
61+
* "en_GB", "en", nil .
62+
*
63+
* This function returns nil on error, including when the platform does not
64+
* supply this information at all.
65+
*
66+
* This might be a "slow" call that has to query the operating system. It's
67+
* best to ask for this once and save the results. However, this list can
68+
* change, usually because the user has changed a system preference outside of
69+
* your program; SDL will send an SDL_EVENT_LOCALE_CHANGED event in this case,
70+
* if possible, and you can call this function again to get an updated copy of
71+
* preferred locales.
72+
*
73+
* \param count a Pointer filled in with the number of locales returned, may
74+
* be nil.
75+
* \returns a nil terminated array of locale pointers, or nil on failure;
76+
* call SDL_GetError() for more information. This is a single
77+
* allocation that should be freed with SDL_free() when it is no
78+
* longer needed.
79+
*
80+
* \since This function is available since SDL 3.2.0.
81+
}
82+
function SDL_GetPreferredLocales(count: pcint):PPSDL_Locale; cdecl;
83+
external SDL_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_GetPreferredLocales' {$ENDIF} {$ENDIF};
84+

0 commit comments

Comments
 (0)