Support creating Unix wxUILocale for languages without region

Unlike MSW and macOS, creating wxUILocale for e.g. "en" doesn't
necessarily succeed under Linux even if "en_US" is available, so try to
find a working language+region combination if just language doesn't
work.

This requires access to the languages database, so add a private
wxGetLanguageInfos() to avoid having to depend on wxLocale just for
this.
This commit is contained in:
Vadim Zeitlin
2021-09-01 01:02:00 +02:00
parent e92da29272
commit 3f8fd90c31
3 changed files with 57 additions and 17 deletions

View File

@@ -51,7 +51,8 @@
#include "wx/stdpaths.h"
#include "wx/hashset.h"
#include "wx/uilocale.h"
#include "wx/vector.h"
#include "wx/private/uilocale.h"
#ifdef __WIN32__
#include "wx/msw/private/uilocale.h"
@@ -193,9 +194,16 @@ wxString wxLanguageInfo::GetLocaleName() const
// wxLocale
// ----------------------------------------------------------------------------
static wxVector<wxLanguageInfo> gs_languagesDB;
static wxLanguageInfos gs_languagesDB;
static bool gs_languagesDBInitialized = false;
const wxLanguageInfos& wxGetLanguageInfos()
{
wxLocale::CreateLanguagesDB();
return gs_languagesDB;
}
/*static*/ void wxLocale::CreateLanguagesDB()
{
if (!gs_languagesDBInitialized)