diff options
author | Vadim Savchuk <vsavchuk@productengine.com> | 2010-04-19 17:56:09 +0300 |
---|---|---|
committer | Vadim Savchuk <vsavchuk@productengine.com> | 2010-04-19 17:56:09 +0300 |
commit | d88a465a46a3e8cb988e0122cf748882cae367b8 (patch) | |
tree | 18bc0c81eaa604f4a2fc780b3ed3de2c4de5ac0f /indra/newview | |
parent | 2e062a8ecbdd02d85a99d9a0e60ec488a25f7dce (diff) |
Fixed bug EXT-6842 ([I18N] Date format in Profile - mm/dd/yyyy needs to be: yyyy/mm/dd for Japanese).
- Made avatar registration date localizeable.
- Specified localization templates for English, Japanese and German.
Reviewed by Mike: https://jira.secondlife.com/browse/EXT-6842
--HG--
branch : product-engine
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/llavatarpropertiesprocessor.cpp | 5 | ||||
-rw-r--r-- | indra/newview/llavatarpropertiesprocessor.h | 2 | ||||
-rw-r--r-- | indra/newview/lldateutil.cpp | 35 | ||||
-rw-r--r-- | indra/newview/lldateutil.h | 23 | ||||
-rw-r--r-- | indra/newview/llinspectavatar.cpp | 7 | ||||
-rw-r--r-- | indra/newview/llpanelavatar.cpp | 7 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/de/strings.xml | 3 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/strings.xml | 4 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/ja/strings.xml | 3 |
9 files changed, 74 insertions, 15 deletions
diff --git a/indra/newview/llavatarpropertiesprocessor.cpp b/indra/newview/llavatarpropertiesprocessor.cpp index 33e5046f50..c7e788f345 100644 --- a/indra/newview/llavatarpropertiesprocessor.cpp +++ b/indra/newview/llavatarpropertiesprocessor.cpp @@ -37,6 +37,7 @@ // Viewer includes #include "llagent.h" #include "llagentpicksinfo.h" +#include "lldateutil.h" #include "llviewergenericmessage.h" // Linden library includes @@ -246,6 +247,7 @@ std::string LLAvatarPropertiesProcessor::paymentInfo(const LLAvatarData* avatar_ void LLAvatarPropertiesProcessor::processAvatarPropertiesReply(LLMessageSystem* msg, void**) { LLAvatarData avatar_data; + std::string birth_date; msg->getUUIDFast( _PREHASH_AgentData, _PREHASH_AgentID, avatar_data.agent_id); msg->getUUIDFast( _PREHASH_AgentData, _PREHASH_AvatarID, avatar_data.avatar_id); @@ -254,11 +256,12 @@ void LLAvatarPropertiesProcessor::processAvatarPropertiesReply(LLMessageSystem* msg->getUUIDFast( _PREHASH_PropertiesData, _PREHASH_PartnerID, avatar_data.partner_id); msg->getStringFast( _PREHASH_PropertiesData, _PREHASH_AboutText, avatar_data.about_text); msg->getStringFast( _PREHASH_PropertiesData, _PREHASH_FLAboutText, avatar_data.fl_about_text); - msg->getStringFast( _PREHASH_PropertiesData, _PREHASH_BornOn, avatar_data.born_on); + msg->getStringFast( _PREHASH_PropertiesData, _PREHASH_BornOn, birth_date); msg->getString( _PREHASH_PropertiesData, _PREHASH_ProfileURL, avatar_data.profile_url); msg->getU32Fast( _PREHASH_PropertiesData, _PREHASH_Flags, avatar_data.flags); + LLDateUtil::dateFromPDTString(avatar_data.born_on, birth_date); avatar_data.caption_index = 0; S32 charter_member_size = 0; diff --git a/indra/newview/llavatarpropertiesprocessor.h b/indra/newview/llavatarpropertiesprocessor.h index 716c1b8065..b9e8bfd0ab 100644 --- a/indra/newview/llavatarpropertiesprocessor.h +++ b/indra/newview/llavatarpropertiesprocessor.h @@ -67,7 +67,7 @@ struct LLAvatarData LLUUID partner_id; std::string about_text; std::string fl_about_text; - std::string born_on; + LLDate born_on; std::string profile_url; U8 caption_index; std::string caption_text; diff --git a/indra/newview/lldateutil.cpp b/indra/newview/lldateutil.cpp index abb2fdeb9a..3e71ecdfba 100644 --- a/indra/newview/lldateutil.cpp +++ b/indra/newview/lldateutil.cpp @@ -59,19 +59,22 @@ static S32 days_from_month(S32 year, S32 month) } } -std::string LLDateUtil::ageFromDate(const std::string& date_string, - const LLDate& now) +bool LLDateUtil::dateFromPDTString(LLDate& date, const std::string& str) +{ + S32 month, day, year; + S32 matched = sscanf(str.c_str(), "%d/%d/%d", &month, &day, &year); + if (matched != 3) return false; + date.fromYMDHMS(year, month, day); + F64 secs_since_epoch = date.secondsSinceEpoch(); + // Correct for the fact that specified date is in Pacific time, == UTC - 8 + secs_since_epoch += 8.0 * 60.0 * 60.0; + date.secondsSinceEpoch(secs_since_epoch); + return true; +} + +std::string LLDateUtil::ageFromDate(const LLDate& born_date, const LLDate& now) { S32 born_month, born_day, born_year; - S32 matched = sscanf(date_string.c_str(), "%d/%d/%d", &born_month, &born_day, &born_year); - if (matched != 3) return "???"; - LLDate born_date; - born_date.fromYMDHMS(born_year, born_month, born_day); - F64 born_date_secs_since_epoch = born_date.secondsSinceEpoch(); - // Correct for the fact that account creation dates are in Pacific time, - // == UTC - 8 - born_date_secs_since_epoch += 8.0 * 60.0 * 60.0; - born_date.secondsSinceEpoch(born_date_secs_since_epoch); // explode out to month/day/year again born_date.split(&born_year, &born_month, &born_day); @@ -155,6 +158,16 @@ std::string LLDateUtil::ageFromDate(const std::string& date_string, return LLTrans::getString("TodayOld"); } +std::string LLDateUtil::ageFromDate(const std::string& date_string, const LLDate& now) +{ + LLDate born_date; + + if (!dateFromPDTString(born_date, date_string)) + return "???"; + + return ageFromDate(born_date, now); +} + std::string LLDateUtil::ageFromDate(const std::string& date_string) { return ageFromDate(date_string, LLDate::now()); diff --git a/indra/newview/lldateutil.h b/indra/newview/lldateutil.h index 041be07f12..a0df21022e 100644 --- a/indra/newview/lldateutil.h +++ b/indra/newview/lldateutil.h @@ -36,6 +36,29 @@ class LLDate; namespace LLDateUtil { + /** + * Convert a date provided by the server into seconds since the Epoch. + * + * @param[out] date Number of seconds since 01/01/1970 UTC. + * @param[in] str Date string (MM/DD/YYYY) in PDT time zone. + * + * @return true on success, false on parse error + */ + bool dateFromPDTString(LLDate& date, const std::string& str); + + /** + * Get human-readable avatar age. + * + * Used for avatar inspectors and profiles. + * + * @param born_date Date an avatar was born on. + * @param now Current date. + * + * @return human-readable localized string like "1 year, 2 months", + * or "???" on error. + */ + std::string ageFromDate(const LLDate& born_date, const LLDate& now); + // Convert a date provided by the server (MM/DD/YYYY) into a localized, // human-readable age (1 year, 2 months) using translation strings. // Pass LLDate::now() for now. diff --git a/indra/newview/llinspectavatar.cpp b/indra/newview/llinspectavatar.cpp index 94ea236757..e48bb77bda 100644 --- a/indra/newview/llinspectavatar.cpp +++ b/indra/newview/llinspectavatar.cpp @@ -58,6 +58,7 @@ #include "llfloaterreg.h" #include "llmenubutton.h" #include "lltooltip.h" // positionViewNearMouse() +#include "lltrans.h" #include "lluictrl.h" #include "llavatariconctrl.h" @@ -380,7 +381,11 @@ void LLInspectAvatar::requestUpdate() void LLInspectAvatar::processAvatarData(LLAvatarData* data) { LLStringUtil::format_map_t args; - args["[BORN_ON]"] = data->born_on; + { + std::string birth_date = LLTrans::getString("AvatarBirthDateFormat"); + LLStringUtil::format(birth_date, LLSD().with("datetime", (S32) data->born_on.secondsSinceEpoch())); + args["[BORN_ON]"] = birth_date; + } args["[AGE]"] = LLDateUtil::ageFromDate(data->born_on, LLDate::now()); args["[SL_PROFILE]"] = data->about_text; args["[RW_PROFILE"] = data->fl_about_text; diff --git a/indra/newview/llpanelavatar.cpp b/indra/newview/llpanelavatar.cpp index a0ba2f739b..dd632ccefe 100644 --- a/indra/newview/llpanelavatar.cpp +++ b/indra/newview/llpanelavatar.cpp @@ -51,6 +51,7 @@ #include "llnotificationsutil.h" #include "llvoiceclient.h" #include "llnamebox.h" +#include "lltrans.h" //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Class LLDropTarget @@ -645,7 +646,11 @@ void LLPanelAvatarProfile::fillCommonData(const LLAvatarData* avatar_data) LLAvatarIconIDCache::getInstance()->remove(avatar_data->avatar_id); LLStringUtil::format_map_t args; - args["[REG_DATE]"] = avatar_data->born_on; + { + std::string birth_date = LLTrans::getString("AvatarBirthDateFormat"); + LLStringUtil::format(birth_date, LLSD().with("datetime", (S32) avatar_data->born_on.secondsSinceEpoch())); + args["[REG_DATE]"] = birth_date; + } args["[AGE]"] = LLDateUtil::ageFromDate( avatar_data->born_on, LLDate::now()); std::string register_date = getString("RegisterDateFormat", args); childSetValue("register_date", register_date ); diff --git a/indra/newview/skins/default/xui/de/strings.xml b/indra/newview/skins/default/xui/de/strings.xml index fd05f02ceb..b3aeb8cd68 100644 --- a/indra/newview/skins/default/xui/de/strings.xml +++ b/indra/newview/skins/default/xui/de/strings.xml @@ -3577,4 +3577,7 @@ Missbrauchsbericht <string name="Contents"> Inhalt </string> + <string name="AvatarBirthDateFormat"> + [day,datetime,slt]/[mthnum,datetime,slt]/[year,datetime,slt] + </string> </strings> diff --git a/indra/newview/skins/default/xui/en/strings.xml b/indra/newview/skins/default/xui/en/strings.xml index 813f59ff89..df4e4153f4 100644 --- a/indra/newview/skins/default/xui/en/strings.xml +++ b/indra/newview/skins/default/xui/en/strings.xml @@ -3103,4 +3103,8 @@ Abuse Report</string> <string name="New Script">New Script</string> <string name="New Folder">New Folder</string> <string name="Contents">Contents</string> + + <!-- birth date format shared by avatar inspector and profile panels --> + <string name="AvatarBirthDateFormat">[mthnum,datetime,slt]/[day,datetime,slt]/[year,datetime,slt]</string> + </strings> diff --git a/indra/newview/skins/default/xui/ja/strings.xml b/indra/newview/skins/default/xui/ja/strings.xml index b9df82adcd..a54d96061f 100644 --- a/indra/newview/skins/default/xui/ja/strings.xml +++ b/indra/newview/skins/default/xui/ja/strings.xml @@ -3577,4 +3577,7 @@ www.secondlife.com から最新バージョンをダウンロードしてくだ <string name="Contents"> コンテンツ </string> + <string name="AvatarBirthDateFormat"> + [year,datetime,slt]/[mthnum,datetime,slt]/[day,datetime,slt] + </string> </strings> |