Add Platform.GetUserLanguage for text localization, separate from locale used for numbers, currency and dates
This commit is contained in:
@@ -622,7 +622,7 @@ void EngineImpl::InitLog()
|
||||
|
||||
// Log product info
|
||||
LOG(Info, "Product: {0}, Company: {1}", Globals::ProductName, Globals::CompanyName);
|
||||
LOG(Info, "Current culture: {0}", Platform::GetUserLocaleName());
|
||||
LOG(Info, "Current language: {}, culture: {}", Platform::GetUserLanguage(), Platform::GetUserLocaleName());
|
||||
LOG(Info, "Command line: {0}", CommandLine);
|
||||
LOG(Info, "Base folder: {0}", Globals::StartupFolder);
|
||||
LOG(Info, "Binaries folder: {0}", Globals::BinariesFolder);
|
||||
|
||||
@@ -328,7 +328,8 @@ bool LocalizationService::Init()
|
||||
PROFILE_MEM(Localization);
|
||||
|
||||
// Use system language as default
|
||||
CurrentLanguage = CurrentCulture = CultureInfo(Platform::GetUserLocaleName());
|
||||
CurrentLanguage = CultureInfo(Platform::GetUserLanguage());
|
||||
CurrentCulture = CultureInfo(Platform::GetUserLocaleName());
|
||||
|
||||
// Setup localization
|
||||
Instance.OnLocalizationChanged();
|
||||
|
||||
@@ -595,6 +595,11 @@ ScreenOrientationType PlatformBase::GetScreenOrientationType()
|
||||
return ScreenOrientationType::Unknown;
|
||||
}
|
||||
|
||||
String PlatformBase::GetUserLanguage()
|
||||
{
|
||||
return Platform::GetUserLocaleName();
|
||||
}
|
||||
|
||||
String PlatformBase::GetUserName()
|
||||
{
|
||||
return Users.Count() != 0 ? Users[0]->GetName() : String::Empty;
|
||||
|
||||
@@ -613,7 +613,12 @@ public:
|
||||
API_PROPERTY() static ScreenOrientationType GetScreenOrientationType();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current locale culture (eg. "pl-PL" or "en-US").
|
||||
/// Gets the current user display language used to localize texts. Returns name of the culture (eg. "pl-PL" or "en-US"), use CultureInfo for display name of the language.
|
||||
/// </summary>
|
||||
API_PROPERTY() static String GetUserLanguage();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the current user locale culture used to localize numbers, currency and dates. Returns name of the culture (eg. "pl-PL" or "en-US"), use CultureInfo for display name of the language.
|
||||
/// </summary>
|
||||
API_PROPERTY() static String GetUserLocaleName() = delete;
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ void FlaxDbgHelpUnlock()
|
||||
|
||||
namespace
|
||||
{
|
||||
String UserLocale, ComputerName, WindowsName;
|
||||
String UserLanguage, UserLocale, ComputerName, WindowsName;
|
||||
HANDLE EngineMutex = nullptr;
|
||||
Rectangle VirtualScreenBounds(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
int32 VersionMajor = 0;
|
||||
@@ -766,12 +766,18 @@ bool WindowsPlatform::Init()
|
||||
|
||||
DWORD tmp;
|
||||
Char buffer[256];
|
||||
ULONG bufferSize = ARRAY_COUNT(buffer), languagesCount = 0;
|
||||
|
||||
// Get user locale string
|
||||
if (GetUserDefaultLocaleName(buffer, LOCALE_NAME_MAX_LENGTH))
|
||||
// Get user locale strings
|
||||
if (GetUserDefaultLocaleName(buffer, (int)bufferSize))
|
||||
{
|
||||
UserLocale = String(buffer);
|
||||
}
|
||||
if (GetUserPreferredUILanguages(MUI_LANGUAGE_NAME, &languagesCount, buffer, &bufferSize))
|
||||
{
|
||||
// Get the first language
|
||||
UserLanguage = String(buffer);
|
||||
}
|
||||
|
||||
// Get computer name string
|
||||
if (GetComputerNameW(buffer, &tmp))
|
||||
@@ -935,6 +941,11 @@ int32 WindowsPlatform::GetDpi()
|
||||
return SystemDpi;
|
||||
}
|
||||
|
||||
String WindowsPlatform::GetUserLanguage()
|
||||
{
|
||||
return UserLanguage.HasChars() ? UserLanguage : UserLocale;
|
||||
}
|
||||
|
||||
String WindowsPlatform::GetUserLocaleName()
|
||||
{
|
||||
return UserLocale;
|
||||
|
||||
@@ -71,6 +71,7 @@ public:
|
||||
static Version GetSystemVersion();
|
||||
static BatteryInfo GetBatteryInfo();
|
||||
static int32 GetDpi();
|
||||
static String GetUserLanguage();
|
||||
static String GetUserLocaleName();
|
||||
static String GetComputerName();
|
||||
static bool GetHasFocus();
|
||||
|
||||
Reference in New Issue
Block a user