Commit Graph

7 Commits

Author SHA1 Message Date
Vadim Zeitlin
45f9908e05 Allow creating wxUILocale objects for any locale
Creating such objects (without using them for the UI) is supported under
all platforms, so allow doing it.

Note that this is only supported under Unix systems when locale_t and
related functionality is available, but this should be the case just
about everywhere by now.

Add a test (or, rather, replace an existing test which was disabled by
default) checking that we can now get locale information about any
locale, not necessarily the currently used one.
2021-09-01 18:11:40 +02:00
Vadim Zeitlin
608718dd9c Separate creating wxUILocaleImpl from using it
Add Use() virtual function which can be used if the newly created
wxUILocaleImpl object should be used as the default UI locale.

Currently Use() is always called after creating a new wxUILocaleImpl, so
adding a separate function just seems to complicate matters needlessly,
but this won't be the case any more soon, when wxUILocaleImpl could be
created for using them for other purposes than making them the default.

No real changes yet.
2021-09-01 18:11:40 +02:00
Vadim Zeitlin
45ffc40fc2 Use nl_langinfo() in wxUILocaleImplUnix::GetInfo()
This function can be used for all GetInfo() items, so using it is
simpler than the code in the Unix version of wxLocale::GetInfo() which
uses either it or localeconv(), and there should be no real drawbacks to
using it nowadays as it should be available everywhere.

No real changes yet.
2021-09-01 18:11:40 +02:00
Vadim Zeitlin
592e1678ce Add charset support to wxLocaleIdent and accessors
Charset is important for Unix systems as some locales may not be
available without it, e.g. "xx_XX" may not be supported, but
"xx_XX.utf8" could be.
2021-09-01 18:11:40 +02:00
Alexander Koshelev
c8269210a2 Add wxUILocale::CompareStrings() function
This function allows comparing strings using the sort order of the
specified locale, represented by the new wxLocaleIdent class.

It is implemented using CompareStringEx()[1] under MSW and
NSString::compare:options:range:locale:[2] under macOS, generic
implementation for the other platforms is upcoming.

[1]: https://docs.microsoft.com/en-us/windows/win32/api/stringapiset/nf-stringapiset-comparestringex
[2]: https://developer.apple.com/documentation/foundation/nsstring/1414561-compare?language=objc
2021-09-01 18:11:33 +02:00
Vadim Zeitlin
37a23e1ab1 Move platform-specific parts of wxLocale::Init() to wxUILocale
This is tidier than using #ifdefs in the same common file and also
ensures that initializing wxLocale affects wxUILocale too, which will be
important for compatibility when the code elsewhere is modified to use
wxUILocale::GetInfo() instead of wxLocale::GetInfo() in the upcoming
commits.

This commit is best viewed with --color-moved git option.
2021-08-20 23:37:28 +02:00
Vadim Zeitlin
b9cbe6770f Add wxUILocale with minimal functionality
Use it in the sample to show what (little) it can do right now.
2021-08-20 22:02:46 +02:00