From 3df26d1e240bb940462ac63b7715d778482d51e7 Mon Sep 17 00:00:00 2001 From: Ansariel Date: Sun, 15 Nov 2020 10:58:06 +0100 Subject: [PATCH] After discussion with Nicky: Use user's locale from OS if using system default language, otherwise use locale configured in particular language_settings.xml file --- indra/llcommon/llstring.cpp | 8 ++------ indra/llui/llresmgr.cpp | 24 ++++++++++++++++++++---- indra/llui/llresmgr.h | 5 ++++- indra/newview/llavatarrendernotifier.cpp | 2 +- indra/newview/llfloaterinspect.cpp | 2 +- indra/newview/llfloaterpreference.cpp | 2 +- indra/newview/llfloatersnapshot.cpp | 5 +---- indra/newview/llinventorybridge.cpp | 2 +- indra/newview/lloutfitslist.cpp | 4 ++-- indra/newview/llpanelmaininventory.cpp | 5 +---- indra/newview/llpaneloutfitedit.cpp | 2 +- indra/newview/llpanelwearing.cpp | 4 ++-- indra/newview/llstartup.cpp | 8 +++++++- indra/newview/llvoavatar.cpp | 2 +- indra/newview/llwearableitemslist.cpp | 2 +- 15 files changed, 46 insertions(+), 31 deletions(-) diff --git a/indra/llcommon/llstring.cpp b/indra/llcommon/llstring.cpp index 3835d6649e..1c4d9e3509 100644 --- a/indra/llcommon/llstring.cpp +++ b/indra/llcommon/llstring.cpp @@ -1298,9 +1298,7 @@ void LLStringUtil::formatNumber(std::string& numStr, std::string decimals) // std::locale() throws if the locale is unknown! (EXT-7926) try { - // Use user's system locale setting for number formatting - //strStream.imbue(std::locale(sLocale.c_str())); - strStream.imbue(std::locale("")); + strStream.imbue(std::locale(sLocale.c_str())); } catch (const std::exception &) { LL_WARNS_ONCE("Locale") << "Cannot set locale to " << sLocale << LL_ENDL; @@ -1337,9 +1335,7 @@ void LLStringUtil::formatNumber(std::string& numStr, std::string decimals) // std::locale() throws if the locale is unknown! (EXT-7926) try { - // Use user's system locale setting for number formatting - //strStream.imbue(std::locale(sLocale.c_str())); - strStream.imbue(std::locale("")); + strStream.imbue(std::locale(sLocale.c_str())); } catch (const std::exception &) { LL_WARNS_ONCE("Locale") << "Cannot set locale to " << sLocale << LL_ENDL; diff --git a/indra/llui/llresmgr.cpp b/indra/llui/llresmgr.cpp index 5d3cbe6c78..09580dec24 100644 --- a/indra/llui/llresmgr.cpp +++ b/indra/llui/llresmgr.cpp @@ -291,16 +291,24 @@ void LLResMgr::getIntegerString( std::string& output, S32 input ) const } #if LL_WINDOWS -const std::string LLLocale::USER_LOCALE("English_United States.1252");// = LLStringUtil::null; +// Make user locale work properly +//const std::string LLLocale::USER_LOCALE("English_United States.1252");// = LLStringUtil::null; +std::string LLLocale::USER_LOCALE("");// = LLStringUtil::null; const std::string LLLocale::SYSTEM_LOCALE("English_United States.1252"); #elif LL_DARWIN -const std::string LLLocale::USER_LOCALE("en_US.iso8859-1");// = LLStringUtil::null; +// Make user locale work properly +//const std::string LLLocale::USER_LOCALE("en_US.iso8859-1");// = LLStringUtil::null; +std::string LLLocale::USER_LOCALE("");// = LLStringUtil::null; const std::string LLLocale::SYSTEM_LOCALE("en_US.iso8859-1"); #elif LL_SOLARIS -const std::string LLLocale::USER_LOCALE("en_US.ISO8859-1"); +// Make user locale work properly +//const std::string LLLocale::USER_LOCALE("en_US.ISO8859-1"); +std::string LLLocale::USER_LOCALE(""); const std::string LLLocale::SYSTEM_LOCALE("C"); #else // LL_LINUX likes this -const std::string LLLocale::USER_LOCALE("en_US.utf8"); +// Make user locale work properly +//const std::string LLLocale::USER_LOCALE("en_US.utf8"); +std::string LLLocale::USER_LOCALE(""); const std::string LLLocale::SYSTEM_LOCALE("C"); #endif @@ -327,3 +335,11 @@ LLLocale::~LLLocale() { setlocale( LC_ALL, mPrevLocaleString.c_str() ); } + +// Make user locale work properly +//static +void LLLocale::setUserLocale(const std::string& locale) +{ + USER_LOCALE = locale; +} +// diff --git a/indra/llui/llresmgr.h b/indra/llui/llresmgr.h index b19d8d40b8..8e8278649b 100644 --- a/indra/llui/llresmgr.h +++ b/indra/llui/llresmgr.h @@ -67,7 +67,10 @@ public: LLLocale(const std::string& locale_string); virtual ~LLLocale(); - static const std::string USER_LOCALE; + // Make user locale work properly + //static const std::string USER_LOCALE; + static void setUserLocale(const std::string& locale); + static std::string USER_LOCALE; static const std::string SYSTEM_LOCALE; private: diff --git a/indra/newview/llavatarrendernotifier.cpp b/indra/newview/llavatarrendernotifier.cpp index f006fa1d8f..514eddec9d 100644 --- a/indra/newview/llavatarrendernotifier.cpp +++ b/indra/newview/llavatarrendernotifier.cpp @@ -121,7 +121,7 @@ void LLAvatarRenderNotifier::displayNotification(bool show_over_limit) // FIRE-19958: Add digit group separators to avatar complexity notification //args["AGENT_COMPLEXITY"] = LLSD::Integer(mLatestAgentComplexity); { - LLLocale locale(""); + LLLocale locale(LLLocale::USER_LOCALE); std::string complexity_string; LLResMgr::getInstance()->getIntegerString(complexity_string, mLatestAgentComplexity); args["AGENT_COMPLEXITY"] = complexity_string; diff --git a/indra/newview/llfloaterinspect.cpp b/indra/newview/llfloaterinspect.cpp index 701b057383..6415d5f78d 100644 --- a/indra/newview/llfloaterinspect.cpp +++ b/indra/newview/llfloaterinspect.cpp @@ -344,7 +344,7 @@ void LLFloaterInspect::refresh() std::string creator_name; S32 pos = mObjectList->getScrollPos(); // PoundLife - Improved Object Inspect - LLLocale locale(""); + LLLocale locale(LLLocale::USER_LOCALE); LLResMgr& res_mgr = LLResMgr::instance(); LLSelectMgr& sel_mgr = LLSelectMgr::instance(); S32 fcount = 0; diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index aeddc0b7ec..94d9c19f88 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -3343,7 +3343,7 @@ void LLAvatarComplexityControls::setText(U32 value, LLTextBox* text_box) // Proper number formatting with delimiter //text_box->setText(llformat("%d", value)); std::string output_string; - LLLocale locale(""); + LLLocale locale(LLLocale::USER_LOCALE); LLResMgr::getInstance()->getIntegerString(output_string, value); text_box->setText(output_string); } diff --git a/indra/newview/llfloatersnapshot.cpp b/indra/newview/llfloatersnapshot.cpp index 3abdecf955..3ee97d3fc6 100644 --- a/indra/newview/llfloatersnapshot.cpp +++ b/indra/newview/llfloatersnapshot.cpp @@ -397,10 +397,7 @@ void LLFloaterSnapshot::Impl::updateControls(LLFloaterSnapshotBase* floater) // *TODO: Separate maximum size for Web images from postcards LL_DEBUGS() << "Is snapshot up-to-date? " << got_snap << LL_ENDL; - // Use user-default locale from operating system - //LLLocale locale(LLLocale::USER_LOCALE); - LLLocale locale(""); - // + LLLocale locale(LLLocale::USER_LOCALE); std::string bytes_string; if (got_snap) { diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index 6a920eabda..5377b67f0e 100644 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -2496,7 +2496,7 @@ std::string LLFolderBridge::getLabelSuffix() const //} if (cat_array.size() > 0 || item_array.size() > 0) { - LLLocale locale(""); + LLLocale locale(LLLocale::USER_LOCALE); LLStringUtil::format_map_t args; std::string count_str; LLResMgr::getInstance()->getIntegerString(count_str, item_array.size()); diff --git a/indra/newview/lloutfitslist.cpp b/indra/newview/lloutfitslist.cpp index c0662cddda..74d42a1d1c 100644 --- a/indra/newview/lloutfitslist.cpp +++ b/indra/newview/lloutfitslist.cpp @@ -976,7 +976,7 @@ void LLOutfitListBase::refreshList(const LLUUID& category_id) // FIRE-12939: Add outfit count to outfits list { std::string count_string; - LLLocale locale(""); + LLLocale locale(LLLocale::USER_LOCALE); LLResMgr::getInstance()->getIntegerString(count_string, (S32)cat_array.size()); getChild("OutfitcountText")->setTextArg("COUNT", count_string); } @@ -1154,7 +1154,7 @@ void LLOutfitListBase::deselectOutfit(const LLUUID& category_id) void LLOutfitListBase::updateAvatarComplexity(U32 complexity) { std::string complexity_string; - LLLocale locale(""); + LLLocale locale(LLLocale::USER_LOCALE); LLResMgr::getInstance()->getIntegerString(complexity_string, complexity); mAvatarComplexityLabel->setTextArg("[WEIGHT]", complexity_string); diff --git a/indra/newview/llpanelmaininventory.cpp b/indra/newview/llpanelmaininventory.cpp index 3621570aa2..91c6608929 100644 --- a/indra/newview/llpanelmaininventory.cpp +++ b/indra/newview/llpanelmaininventory.cpp @@ -1055,10 +1055,7 @@ void LLPanelMainInventory::updateItemcountText() mItemCount = new_count; // mItemCountString = ""; - // Use user-default locale from operating system - //LLLocale locale(LLLocale::USER_LOCALE); - LLLocale locale(""); - // + LLLocale locale(LLLocale::USER_LOCALE); LLResMgr::getInstance()->getIntegerString(mItemCountString, mItemCount); // Include folders in inventory count diff --git a/indra/newview/llpaneloutfitedit.cpp b/indra/newview/llpaneloutfitedit.cpp index a3aadf5cc6..f3838b9c6d 100644 --- a/indra/newview/llpaneloutfitedit.cpp +++ b/indra/newview/llpaneloutfitedit.cpp @@ -1441,7 +1441,7 @@ void LLPanelOutfitEdit::saveListSelection() void LLPanelOutfitEdit::updateAvatarComplexity(U32 complexity) { std::string complexity_string; - LLLocale locale(""); + LLLocale locale(LLLocale::USER_LOCALE); LLResMgr::getInstance()->getIntegerString(complexity_string, complexity); mAvatarComplexityLabel->setTextArg("[WEIGHT]", complexity_string); diff --git a/indra/newview/llpanelwearing.cpp b/indra/newview/llpanelwearing.cpp index 76cb8fcf99..ca75a1c1d2 100644 --- a/indra/newview/llpanelwearing.cpp +++ b/indra/newview/llpanelwearing.cpp @@ -489,7 +489,7 @@ bool LLPanelWearing::populateAttachmentsList(bool update) } // Show avatar complexity in appearance floater std::string complexity_string; - LLLocale locale(""); + LLLocale locale(LLLocale::USER_LOCALE); LLResMgr::getInstance()->getIntegerString(complexity_string, mTempItemComplexityMap[attachment->getID()]); row["columns"][2]["column"] = "weight"; row["columns"][2]["value"] = complexity_string; @@ -664,7 +664,7 @@ void LLPanelWearing::copyToClipboard() void LLPanelWearing::updateAvatarComplexity(U32 complexity, const std::map& item_complexity, const std::map& temp_item_complexity, U32 body_parts_complexity) { std::string complexity_string; - LLLocale locale(""); + LLLocale locale(LLLocale::USER_LOCALE); LLResMgr::getInstance()->getIntegerString(complexity_string, complexity); mAvatarComplexityLabel->setTextArg("[WEIGHT]", complexity_string); diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp index 7a839d7b1b..05b3730a76 100644 --- a/indra/newview/llstartup.cpp +++ b/indra/newview/llstartup.cpp @@ -244,6 +244,7 @@ #include "llnotificationmanager.h" #include "llpresetsmanager.h" #include "llprogressview.h" +#include "llresmgr.h" #include "lltoolbarview.h" #include "NACLantispam.h" #include "streamtitledisplay.h" @@ -618,7 +619,12 @@ bool idle_startup() system = osString.substr (begIdx, endIdx - begIdx); system += "Locale"; - LLStringUtil::setLocale (LLTrans::getString(system)); + // Make user locale work properly + //LLStringUtil::setLocale (LLTrans::getString(system)); + std::string user_locale = gSavedSettings.getString("Language") == "default" ? "" : LLTrans::getString(system); + LLStringUtil::setLocale(user_locale); + LLLocale::setUserLocale(user_locale); + // //note: Removing this line will cause incorrect button size in the login screen. -- bao. gTextureList.updateImages(0.01f) ; diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index 8fe1ecbb57..29bc5129ef 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -3795,7 +3795,7 @@ void LLVOAvatar::idleUpdateNameTagText(BOOL new_name) (!isSelf() && (!show_too_complex_only_arw_tag || isTooComplex())))) { std::string complexity_string; - LLLocale locale(""); + LLLocale locale(LLLocale::USER_LOCALE); // always show complexity, even if the reason for a jelly baby is the texture area // this is technically not 100% correct but the decision logic with all of the diff --git a/indra/newview/llwearableitemslist.cpp b/indra/newview/llwearableitemslist.cpp index 18dccaea3a..f101d0a49b 100644 --- a/indra/newview/llwearableitemslist.cpp +++ b/indra/newview/llwearableitemslist.cpp @@ -477,7 +477,7 @@ void FSPanelCOFWearableOutfitListItem::updateItemWeight(U32 item_weight) std::string complexity_string; if (item_weight > 0) { - LLLocale locale(""); + LLLocale locale(LLLocale::USER_LOCALE); LLResMgr::getInstance()->getIntegerString(complexity_string, item_weight); } mWeightCtrl->setText(complexity_string);