More string fixes
Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>
This commit is contained in:
@@ -20,7 +20,6 @@
|
||||
#include "System.h" // to access InitLocalization()
|
||||
#include <CryPath.h>
|
||||
#include <IConsole.h>
|
||||
#include <StringUtils.h>
|
||||
#include <locale.h>
|
||||
#include <time.h>
|
||||
|
||||
@@ -146,9 +145,9 @@ static void ReloadDialogData([[maybe_unused]] IConsoleCmdArgs* pArgs)
|
||||
#if !defined(_RELEASE)
|
||||
static void TestFormatMessage ([[maybe_unused]] IConsoleCmdArgs* pArgs)
|
||||
{
|
||||
string fmt1 ("abc %1 def % gh%2i %");
|
||||
string fmt2 ("abc %[action:abc] %2 def % gh%1i %1");
|
||||
string out1, out2;
|
||||
AZStd::string fmt1 ("abc %1 def % gh%2i %");
|
||||
AZStd::string fmt2 ("abc %[action:abc] %2 def % gh%1i %1");
|
||||
AZStd::string out1, out2;
|
||||
LocalizationManagerRequestBus::Broadcast(&LocalizationManagerRequestBus::Events::FormatStringMessage, out1, fmt1, "first", "second", "third", nullptr);
|
||||
CryLogAlways("%s", out1.c_str());
|
||||
LocalizationManagerRequestBus::Broadcast(&LocalizationManagerRequestBus::Events::FormatStringMessage, out2, fmt2, "second", nullptr, nullptr, nullptr);
|
||||
@@ -206,18 +205,18 @@ CLocalizedStringsManager::CLocalizedStringsManager(ISystem* pSystem)
|
||||
|
||||
// Populate available languages by scanning the localization directory for paks
|
||||
// Default to US English if language is not supported
|
||||
string sPath;
|
||||
const string sLocalizationFolder(PathUtil::GetLocalizationFolder());
|
||||
AZStd::string sPath;
|
||||
const AZStd::string sLocalizationFolder(PathUtil::GetLocalizationFolder());
|
||||
ILocalizationManager::TLocalizationBitfield availableLanguages = 0;
|
||||
|
||||
AZ::IO::FileIOBase* fileIO = AZ::IO::FileIOBase::GetInstance();
|
||||
// test language name against supported languages
|
||||
for (int i = 0; i < ILocalizationManager::ePILID_MAX_OR_INVALID; i++)
|
||||
{
|
||||
string sCurrentLanguage = LangNameFromPILID((ILocalizationManager::EPlatformIndependentLanguageID)i);
|
||||
AZStd::string sCurrentLanguage = LangNameFromPILID((ILocalizationManager::EPlatformIndependentLanguageID)i);
|
||||
sPath = sLocalizationFolder.c_str() + sCurrentLanguage;
|
||||
sPath.MakeLower();
|
||||
if (fileIO && fileIO->IsDirectory(sPath))
|
||||
AZStd::to_lower(sPath.begin(), sPath.end());
|
||||
if (fileIO && fileIO->IsDirectory(sPath.c_str()))
|
||||
{
|
||||
availableLanguages |= ILocalizationManager::LocalizationBitfieldFromPILID((ILocalizationManager::EPlatformIndependentLanguageID)i);
|
||||
if (m_cvarLocalizationDebug >= 2)
|
||||
@@ -366,7 +365,7 @@ bool CLocalizedStringsManager::SetLanguage(const char* sLanguage)
|
||||
// Check if already language loaded.
|
||||
for (uint32 i = 0; i < m_languages.size(); i++)
|
||||
{
|
||||
if (_stricmp(sLanguage, m_languages[i]->sLanguage) == 0)
|
||||
if (_stricmp(sLanguage, m_languages[i]->sLanguage.c_str()) == 0)
|
||||
{
|
||||
InternalSetCurrentLanguage(m_languages[i]);
|
||||
return true;
|
||||
@@ -441,9 +440,9 @@ void CLocalizedStringsManager::AddControl([[maybe_unused]] int nKey)
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CLocalizedStringsManager::ParseFirstLine(IXmlTableReader* pXmlTableReader, char* nCellIndexToType, std::map<int, string>& SoundMoodIndex, std::map<int, string>& EventParameterIndex)
|
||||
void CLocalizedStringsManager::ParseFirstLine(IXmlTableReader* pXmlTableReader, char* nCellIndexToType, std::map<int, AZStd::string>& SoundMoodIndex, std::map<int, AZStd::string>& EventParameterIndex)
|
||||
{
|
||||
string sCellContent;
|
||||
AZStd::string sCellContent;
|
||||
|
||||
for (;; )
|
||||
{
|
||||
@@ -466,7 +465,7 @@ void CLocalizedStringsManager::ParseFirstLine(IXmlTableReader* pXmlTableReader,
|
||||
}
|
||||
|
||||
sCellContent.assign(pContent, contentSize);
|
||||
sCellContent.MakeLower();
|
||||
AZStd::to_lower(sCellContent.begin(), sCellContent.end());
|
||||
|
||||
for (int i = 0; i < sizeof(sLocalizedColumnNames) / sizeof(sLocalizedColumnNames[0]); ++i)
|
||||
{
|
||||
@@ -530,8 +529,8 @@ static void CopyLowercase(char* dst, size_t dstSize, const char* src, size_t src
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
static void ReplaceEndOfLine(AZStd::fixed_string<CLocalizedStringsManager::LOADING_FIXED_STRING_LENGTH>& s)
|
||||
{
|
||||
const string oldSubstr("\\n");
|
||||
const string newSubstr(" \n");
|
||||
const AZStd::string oldSubstr("\\n");
|
||||
const AZStd::string newSubstr(" \n");
|
||||
size_t pos = 0;
|
||||
for (;; )
|
||||
{
|
||||
@@ -565,7 +564,7 @@ void CLocalizedStringsManager::OnSystemEvent(
|
||||
|
||||
for (TStringVec::iterator it = m_tagLoadRequests.begin(); it != m_tagLoadRequests.end(); ++it)
|
||||
{
|
||||
LoadLocalizationDataByTag(*it);
|
||||
LoadLocalizationDataByTag(it->c_str());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -577,7 +576,7 @@ void CLocalizedStringsManager::OnSystemEvent(
|
||||
// Load all tags after the Editor has finished initialization.
|
||||
for (TTagFileNames::iterator it = m_tagFileNames.begin(); it != m_tagFileNames.end(); ++it)
|
||||
{
|
||||
LoadLocalizationDataByTag(it->first);
|
||||
LoadLocalizationDataByTag(it->first.c_str());
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -600,7 +599,7 @@ bool CLocalizedStringsManager::InitLocalizationData(
|
||||
for (int i = 0; i < root->getChildCount(); i++)
|
||||
{
|
||||
XmlNodeRef typeNode = root->getChild(i);
|
||||
string sType = typeNode->getTag();
|
||||
AZStd::string sType = typeNode->getTag();
|
||||
|
||||
// tags should be unique
|
||||
if (m_tagFileNames.find(sType) != m_tagFileNames.end())
|
||||
@@ -678,9 +677,9 @@ bool CLocalizedStringsManager::LoadLocalizationDataByTag(
|
||||
for (TStringVec::iterator it2 = vEntries.begin(); it2 != vEntries.end(); ++it2)
|
||||
{
|
||||
//Only load files of the correct type for the configured format
|
||||
if ((m_cvarLocalizationFormat == 0 && strstr(*it2, ".xml")) || (m_cvarLocalizationFormat == 1 && strstr(*it2, ".agsxml")))
|
||||
if ((m_cvarLocalizationFormat == 0 && strstr(it2->c_str(), ".xml")) || (m_cvarLocalizationFormat == 1 && strstr(it2->c_str(), ".agsxml")))
|
||||
{
|
||||
bResult &= (this->*loadFunction)(*it2, it->second.id, bReload);
|
||||
bResult &= (this->*loadFunction)(it2->c_str(), it->second.id, bReload);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -824,7 +823,7 @@ bool CLocalizedStringsManager::LoadAllLocalizationData(bool bReload)
|
||||
{
|
||||
for (TTagFileNames::iterator it = m_tagFileNames.begin(); it != m_tagFileNames.end(); ++it)
|
||||
{
|
||||
if(!LoadLocalizationDataByTag(it->first, bReload))
|
||||
if(!LoadLocalizationDataByTag(it->first.c_str(), bReload))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -837,6 +836,37 @@ bool CLocalizedStringsManager::LoadExcelXmlSpreadsheet(const char* sFileName, bo
|
||||
return (this->*loadFunction)(sFileName, 0, bReload);
|
||||
}
|
||||
|
||||
enum class YesNoType
|
||||
{
|
||||
Yes,
|
||||
No,
|
||||
Invalid
|
||||
};
|
||||
|
||||
// parse the yes/no string
|
||||
/*!
|
||||
\param szString any of the following strings: yes, enable, true, 1, no, disable, false, 0
|
||||
\return YesNoType::Yes if szString is yes/enable/true/1, YesNoType::No if szString is no, disable, false, 0 and YesNoType::Invalid if the string is not one of the expected values.
|
||||
*/
|
||||
inline YesNoType ToYesNoType(const char* szString)
|
||||
{
|
||||
if (!_stricmp(szString, "yes")
|
||||
|| !_stricmp(szString, "enable")
|
||||
|| !_stricmp(szString, "true")
|
||||
|| !_stricmp(szString, "1"))
|
||||
{
|
||||
return YesNoType::Yes;
|
||||
}
|
||||
if (!_stricmp(szString, "no")
|
||||
|| !_stricmp(szString, "disable")
|
||||
|| !_stricmp(szString, "false")
|
||||
|| !_stricmp(szString, "0"))
|
||||
{
|
||||
return YesNoType::No;
|
||||
}
|
||||
return YesNoType::Invalid;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Loads a string-table from a Excel XML Spreadsheet file.
|
||||
bool CLocalizedStringsManager::DoLoadExcelXmlSpreadsheet(const char* sFileName, uint8 nTagID, bool bReload)
|
||||
@@ -850,7 +880,7 @@ bool CLocalizedStringsManager::DoLoadExcelXmlSpreadsheet(const char* sFileName,
|
||||
//check if this table has already been loaded
|
||||
if (!bReload)
|
||||
{
|
||||
if (m_loadedTables.find(CONST_TEMP_STRING(sFileName)) != m_loadedTables.end())
|
||||
if (m_loadedTables.find(AZStd::string(sFileName)) != m_loadedTables.end())
|
||||
{
|
||||
return (true);
|
||||
}
|
||||
@@ -866,12 +896,12 @@ bool CLocalizedStringsManager::DoLoadExcelXmlSpreadsheet(const char* sFileName,
|
||||
}
|
||||
|
||||
XmlNodeRef root;
|
||||
string sPath;
|
||||
AZStd::string sPath;
|
||||
{
|
||||
const string sLocalizationFolder(PathUtil::GetLocalizationRoot());
|
||||
const string& languageFolder = m_pLanguage->sLanguage;
|
||||
const AZStd::string sLocalizationFolder(PathUtil::GetLocalizationRoot());
|
||||
const AZStd::string& languageFolder = m_pLanguage->sLanguage;
|
||||
sPath = sLocalizationFolder.c_str() + languageFolder + PathUtil::GetSlash() + sFileName;
|
||||
root = m_pSystem->LoadXmlFromFile(sPath);
|
||||
root = m_pSystem->LoadXmlFromFile(sPath.c_str());
|
||||
if (!root)
|
||||
{
|
||||
CryLog("Loading Localization File %s failed!", sPath.c_str());
|
||||
@@ -948,10 +978,10 @@ bool CLocalizedStringsManager::DoLoadExcelXmlSpreadsheet(const char* sFileName,
|
||||
memset(nCellIndexToType, 0, sizeof(nCellIndexToType));
|
||||
|
||||
// SoundMood Index
|
||||
std::map<int, string> SoundMoodIndex;
|
||||
std::map<int, AZStd::string> SoundMoodIndex;
|
||||
|
||||
// EventParameter Index
|
||||
std::map<int, string> EventParameterIndex;
|
||||
std::map<int, AZStd::string> EventParameterIndex;
|
||||
|
||||
bool bFirstRow = true;
|
||||
|
||||
@@ -1083,7 +1113,7 @@ bool CLocalizedStringsManager::DoLoadExcelXmlSpreadsheet(const char* sFileName,
|
||||
break;
|
||||
case ELOCALIZED_COLUMN_USE_SUBTITLE:
|
||||
sTmp.assign(cell.ptr, cell.count);
|
||||
bUseSubtitle = CryStringUtils::ToYesNoType(sTmp.c_str()) == CryStringUtils::YesNoType::No ? false : true; // favor yes (yes and invalid -> yes)
|
||||
bUseSubtitle = ToYesNoType(sTmp.c_str()) == YesNoType::No ? false : true; // favor yes (yes and invalid -> yes)
|
||||
break;
|
||||
case ELOCALIZED_COLUMN_VOLUME:
|
||||
sTmp.assign(cell.ptr, cell.count);
|
||||
@@ -1121,7 +1151,7 @@ bool CLocalizedStringsManager::DoLoadExcelXmlSpreadsheet(const char* sFileName,
|
||||
{
|
||||
bIsIntercepted = true;
|
||||
}
|
||||
bIsDirectRadio = bIsIntercepted || (CryStringUtils::ToYesNoType(sTmp.c_str()) == CryStringUtils::YesNoType::Yes ? true : false); // favor no (no and invalid -> no)
|
||||
bIsDirectRadio = bIsIntercepted || (ToYesNoType(sTmp.c_str()) == YesNoType::Yes ? true : false); // favor no (no and invalid -> no)
|
||||
++nItems;
|
||||
break;
|
||||
// legacy names
|
||||
@@ -1358,7 +1388,7 @@ bool CLocalizedStringsManager::DoLoadExcelXmlSpreadsheet(const char* sFileName,
|
||||
}
|
||||
else
|
||||
{
|
||||
pEntry->TranslatedText.psUtf8Uncompressed = new string(sTmp.c_str(), sTmp.c_str() + sTmp.length());
|
||||
pEntry->TranslatedText.psUtf8Uncompressed = new AZStd::string(sTmp.c_str(), sTmp.c_str() + sTmp.length());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1367,7 +1397,7 @@ bool CLocalizedStringsManager::DoLoadExcelXmlSpreadsheet(const char* sFileName,
|
||||
// the CryString makes sure, that only the ref-count is increment on assignment
|
||||
if (*szLowerCaseEvent)
|
||||
{
|
||||
PrototypeSoundEvents::iterator it = m_prototypeEvents.find(CONST_TEMP_STRING(szLowerCaseEvent));
|
||||
PrototypeSoundEvents::iterator it = m_prototypeEvents.find(AZStd::string(szLowerCaseEvent));
|
||||
if (it != m_prototypeEvents.end())
|
||||
{
|
||||
pEntry->sPrototypeSoundEvent = *it;
|
||||
@@ -1384,8 +1414,8 @@ bool CLocalizedStringsManager::DoLoadExcelXmlSpreadsheet(const char* sFileName,
|
||||
{
|
||||
sTmp.assign(sWho.ptr, sWho.count);
|
||||
ReplaceEndOfLine(sTmp);
|
||||
sTmp.replace(" ", "_");
|
||||
string tmp;
|
||||
AZStd::replace(sTmp.begin(), sTmp.end(), ' ', '_');
|
||||
AZStd::string tmp;
|
||||
{
|
||||
tmp = sTmp.c_str();
|
||||
}
|
||||
@@ -1531,19 +1561,19 @@ bool CLocalizedStringsManager::DoLoadAGSXmlDocument(const char* sFileName, uint8
|
||||
}
|
||||
if (!bReload)
|
||||
{
|
||||
if (m_loadedTables.find(CONST_TEMP_STRING(sFileName)) != m_loadedTables.end())
|
||||
if (m_loadedTables.find(AZStd::string(sFileName)) != m_loadedTables.end())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
ListAndClearProblemLabels();
|
||||
XmlNodeRef root;
|
||||
string sPath;
|
||||
AZStd::string sPath;
|
||||
{
|
||||
const string sLocalizationFolder(PathUtil::GetLocalizationRoot());
|
||||
const string& languageFolder = m_pLanguage->sLanguage;
|
||||
const AZStd::string sLocalizationFolder(PathUtil::GetLocalizationRoot());
|
||||
const AZStd::string& languageFolder = m_pLanguage->sLanguage;
|
||||
sPath = sLocalizationFolder.c_str() + languageFolder + PathUtil::GetSlash() + sFileName;
|
||||
root = m_pSystem->LoadXmlFromFile(sPath);
|
||||
root = m_pSystem->LoadXmlFromFile(sPath.c_str());
|
||||
if (!root)
|
||||
{
|
||||
AZ_TracePrintf(LOC_WINDOW, "Loading Localization File %s failed!", sPath.c_str());
|
||||
@@ -1654,7 +1684,7 @@ bool CLocalizedStringsManager::DoLoadAGSXmlDocument(const char* sFileName, uint8
|
||||
}
|
||||
else
|
||||
{
|
||||
pEntry->TranslatedText.psUtf8Uncompressed = new string(textString, textString + textLength);
|
||||
pEntry->TranslatedText.psUtf8Uncompressed = new AZStd::string(textString, textString + textLength);
|
||||
}
|
||||
}
|
||||
{
|
||||
@@ -1714,7 +1744,7 @@ void CLocalizedStringsManager::ReloadData()
|
||||
FreeLocalizationData();
|
||||
for (tmapFilenames::iterator it = temp.begin(); it != temp.end(); it++)
|
||||
{
|
||||
(this->*loadFunction)((*it).first, (*it).second.nTagID, true);
|
||||
(this->*loadFunction)((*it).first.c_str(), (*it).second.nTagID, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1732,19 +1762,19 @@ void CLocalizedStringsManager::AddLocalizedString(SLanguage* pLanguage, SLocaliz
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CLocalizedStringsManager::LocalizeString_ch(const char* sString, string& outLocalizedString, bool bEnglish)
|
||||
bool CLocalizedStringsManager::LocalizeString_ch(const char* sString, AZStd::string& outLocalizedString, bool bEnglish)
|
||||
{
|
||||
return LocalizeStringInternal(sString, strlen(sString), outLocalizedString, bEnglish);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CLocalizedStringsManager::LocalizeString_s(const string& sString, string& outLocalizedString, bool bEnglish)
|
||||
bool CLocalizedStringsManager::LocalizeString_s(const AZStd::string& sString, AZStd::string& outLocalizedString, bool bEnglish)
|
||||
{
|
||||
return LocalizeStringInternal(sString.c_str(), sString.length(), outLocalizedString, bEnglish);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CLocalizedStringsManager::LocalizeStringInternal(const char* pStr, size_t len, string& outLocalizedString, bool bEnglish)
|
||||
bool CLocalizedStringsManager::LocalizeStringInternal(const char* pStr, size_t len, AZStd::string& outLocalizedString, bool bEnglish)
|
||||
{
|
||||
assert (m_pLanguage);
|
||||
if (m_pLanguage == 0)
|
||||
@@ -1755,7 +1785,7 @@ bool CLocalizedStringsManager::LocalizeStringInternal(const char* pStr, size_t l
|
||||
}
|
||||
|
||||
// note: we don't write directly to outLocalizedString, in case it aliases pStr
|
||||
string out;
|
||||
AZStd::string out;
|
||||
|
||||
// scan the string
|
||||
const char* pPos = pStr;
|
||||
@@ -1783,8 +1813,8 @@ bool CLocalizedStringsManager::LocalizeStringInternal(const char* pStr, size_t l
|
||||
}
|
||||
|
||||
// localize token
|
||||
string token(pLabel, pLabelEnd);
|
||||
string sLocalizedToken;
|
||||
AZStd::string token(pLabel, pLabelEnd);
|
||||
AZStd::string sLocalizedToken;
|
||||
if (bEnglish)
|
||||
{
|
||||
GetEnglishString(token.c_str(), sLocalizedToken);
|
||||
@@ -1803,7 +1833,7 @@ bool CLocalizedStringsManager::LocalizeStringInternal(const char* pStr, size_t l
|
||||
|
||||
void CLocalizedStringsManager::LocalizeAndSubstituteInternal(AZStd::string& locString, const AZStd::vector<AZStd::string>& keys, const AZStd::vector<AZStd::string>& values)
|
||||
{
|
||||
string outString;
|
||||
AZStd::string outString;
|
||||
LocalizeString_ch(locString.c_str(), outString);
|
||||
locString = outString .c_str();
|
||||
if (values.size() != keys.size())
|
||||
@@ -1866,7 +1896,7 @@ static void LogDecompTimer(__int64 nTotalTicks, __int64 nDecompTicks, __int64 nA
|
||||
}
|
||||
#endif
|
||||
|
||||
string CLocalizedStringsManager::SLocalizedStringEntry::GetTranslatedText(const SLanguage* pLanguage) const
|
||||
AZStd::string CLocalizedStringsManager::SLocalizedStringEntry::GetTranslatedText(const SLanguage* pLanguage) const
|
||||
{
|
||||
FUNCTION_PROFILER_FAST(GetISystem(), PROFILE_SYSTEM, g_bProfilerEnabled);
|
||||
if ((flags & IS_COMPRESSED) != 0)
|
||||
@@ -1876,7 +1906,7 @@ string CLocalizedStringsManager::SLocalizedStringEntry::GetTranslatedText(const
|
||||
nTotalTicks = CryGetTicks();
|
||||
#endif //LOG_DECOMP_TIMES
|
||||
|
||||
string outputString;
|
||||
AZStd::string outputString;
|
||||
if (TranslatedText.szCompressed != NULL)
|
||||
{
|
||||
uint8 decompressionBuffer[COMPRESSION_FIXED_BUFFER_LENGTH];
|
||||
@@ -1923,7 +1953,7 @@ string CLocalizedStringsManager::SLocalizedStringEntry::GetTranslatedText(const
|
||||
}
|
||||
else
|
||||
{
|
||||
string emptyOutputString;
|
||||
AZStd::string emptyOutputString;
|
||||
return emptyOutputString;
|
||||
}
|
||||
}
|
||||
@@ -1949,7 +1979,7 @@ void CLocalizedStringsManager::ListAndClearProblemLabels()
|
||||
CryLog ("These labels caused localization problems:");
|
||||
INDENT_LOG_DURING_SCOPE();
|
||||
|
||||
for (std::map<string, bool>::iterator iter = m_warnedAboutLabels.begin(); iter != m_warnedAboutLabels.end(); iter++)
|
||||
for (std::map<AZStd::string, bool>::iterator iter = m_warnedAboutLabels.begin(); iter != m_warnedAboutLabels.end(); iter++)
|
||||
{
|
||||
CryLog ("%s", iter->first.c_str());
|
||||
}
|
||||
@@ -1961,7 +1991,7 @@ void CLocalizedStringsManager::ListAndClearProblemLabels()
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CLocalizedStringsManager::LocalizeLabel(const char* sLabel, string& outLocalString, bool bEnglish)
|
||||
bool CLocalizedStringsManager::LocalizeLabel(const char* sLabel, AZStd::string& outLocalString, bool bEnglish)
|
||||
{
|
||||
assert(sLabel);
|
||||
if (!m_pLanguage || !sLabel)
|
||||
@@ -1979,8 +2009,7 @@ bool CLocalizedStringsManager::LocalizeLabel(const char* sLabel, string& outLoca
|
||||
|
||||
if (entry != NULL)
|
||||
{
|
||||
|
||||
string translatedText = entry->GetTranslatedText(m_pLanguage);
|
||||
AZStd::string translatedText = entry->GetTranslatedText(m_pLanguage);
|
||||
if ((bEnglish || translatedText.empty()) && entry->pEditorExtension != NULL)
|
||||
{
|
||||
//assert(!"No Localization Text available!");
|
||||
@@ -2011,7 +2040,7 @@ bool CLocalizedStringsManager::LocalizeLabel(const char* sLabel, string& outLoca
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CLocalizedStringsManager::GetEnglishString(const char* sKey, string& sLocalizedString)
|
||||
bool CLocalizedStringsManager::GetEnglishString(const char* sKey, AZStd::string& sLocalizedString)
|
||||
{
|
||||
assert(sKey);
|
||||
if (!m_pLanguage || !sKey)
|
||||
@@ -2086,7 +2115,7 @@ bool CLocalizedStringsManager::GetLocalizedInfoByKey(const char* sKey, SLocalize
|
||||
const SLocalizedStringEntry* entry = stl::find_in_map(m_pLanguage->m_keysMap, keyCRC32, NULL);
|
||||
if (entry != NULL)
|
||||
{
|
||||
outGameInfo.szCharacterName = entry->sCharacterName;
|
||||
outGameInfo.szCharacterName = entry->sCharacterName.c_str();
|
||||
outGameInfo.sUtf8TranslatedText = entry->GetTranslatedText(m_pLanguage);
|
||||
|
||||
outGameInfo.bUseSubtitle = (entry->flags & SLocalizedStringEntry::USE_SUBTITLE);
|
||||
@@ -2119,7 +2148,7 @@ bool CLocalizedStringsManager::GetLocalizedInfoByKey(const char* sKey, SLocalize
|
||||
{
|
||||
bResult = true;
|
||||
|
||||
pOutSoundInfo->szCharacterName = pEntry->sCharacterName;
|
||||
pOutSoundInfo->szCharacterName = pEntry->sCharacterName.c_str();
|
||||
pOutSoundInfo->sUtf8TranslatedText = pEntry->GetTranslatedText(m_pLanguage);
|
||||
|
||||
//pOutSoundInfo->sOriginalActorLine = pEntry->sOriginalActorLine.c_str();
|
||||
@@ -2213,7 +2242,7 @@ bool CLocalizedStringsManager::GetLocalizedInfoByIndex(int nIndex, SLocalizedInf
|
||||
}
|
||||
const SLocalizedStringEntry* pEntry = entryVec[nIndex];
|
||||
|
||||
outGameInfo.szCharacterName = pEntry->sCharacterName;
|
||||
outGameInfo.szCharacterName = pEntry->sCharacterName.c_str();
|
||||
outGameInfo.sUtf8TranslatedText = pEntry->GetTranslatedText(m_pLanguage);
|
||||
|
||||
outGameInfo.bUseSubtitle = (pEntry->flags & SLocalizedStringEntry::USE_SUBTITLE);
|
||||
@@ -2233,18 +2262,18 @@ bool CLocalizedStringsManager::GetLocalizedInfoByIndex(int nIndex, SLocalizedInf
|
||||
return false;
|
||||
}
|
||||
const SLocalizedStringEntry* pEntry = entryVec[nIndex];
|
||||
outEditorInfo.szCharacterName = pEntry->sCharacterName;
|
||||
outEditorInfo.szCharacterName = pEntry->sCharacterName.c_str();
|
||||
outEditorInfo.sUtf8TranslatedText = pEntry->GetTranslatedText(m_pLanguage);
|
||||
|
||||
assert(pEntry->pEditorExtension != NULL);
|
||||
|
||||
outEditorInfo.sKey = pEntry->pEditorExtension->sKey;
|
||||
outEditorInfo.sKey = pEntry->pEditorExtension->sKey.c_str();
|
||||
|
||||
outEditorInfo.sOriginalActorLine = pEntry->pEditorExtension->sOriginalActorLine;
|
||||
outEditorInfo.sUtf8TranslatedActorLine = pEntry->pEditorExtension->sUtf8TranslatedActorLine;
|
||||
outEditorInfo.sOriginalActorLine = pEntry->pEditorExtension->sOriginalActorLine.c_str();
|
||||
outEditorInfo.sUtf8TranslatedActorLine = pEntry->pEditorExtension->sUtf8TranslatedActorLine.c_str();
|
||||
|
||||
//outEditorInfo.sOriginalText = pEntry->sOriginalText;
|
||||
outEditorInfo.sOriginalCharacterName = pEntry->pEditorExtension->sOriginalCharacterName;
|
||||
outEditorInfo.sOriginalCharacterName = pEntry->pEditorExtension->sOriginalCharacterName.c_str();
|
||||
|
||||
outEditorInfo.nRow = pEntry->pEditorExtension->nRow;
|
||||
outEditorInfo.bUseSubtitle = (pEntry->flags & SLocalizedStringEntry::USE_SUBTITLE);
|
||||
@@ -2252,7 +2281,7 @@ bool CLocalizedStringsManager::GetLocalizedInfoByIndex(int nIndex, SLocalizedInf
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool CLocalizedStringsManager::GetSubtitle(const char* sKeyOrLabel, string& outSubtitle, bool bForceSubtitle)
|
||||
bool CLocalizedStringsManager::GetSubtitle(const char* sKeyOrLabel, AZStd::string& outSubtitle, bool bForceSubtitle)
|
||||
{
|
||||
assert(sKeyOrLabel);
|
||||
if (!m_pLanguage || !sKeyOrLabel || !*sKeyOrLabel)
|
||||
@@ -2376,13 +2405,13 @@ void InternalFormatStringMessage(StringClass& outString, const StringClass& sStr
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CLocalizedStringsManager::FormatStringMessage_List(string& outString, const string& sString, const char** sParams, int nParams)
|
||||
void CLocalizedStringsManager::FormatStringMessage_List(AZStd::string& outString, const AZStd::string& sString, const char** sParams, int nParams)
|
||||
{
|
||||
InternalFormatStringMessage(outString, sString, sParams, nParams);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
void CLocalizedStringsManager::FormatStringMessage(string& outString, const string& sString, const char* param1, const char* param2, const char* param3, const char* param4)
|
||||
void CLocalizedStringsManager::FormatStringMessage(AZStd::string& outString, const AZStd::string& sString, const char* param1, const char* param2, const char* param3, const char* param4)
|
||||
{
|
||||
InternalFormatStringMessage(outString, sString, param1, param2, param3, param4);
|
||||
}
|
||||
@@ -2462,7 +2491,7 @@ void CLocalizedStringsManager::InternalSetCurrentLanguage(CLocalizedStringsManag
|
||||
#if defined (WIN32) || defined(WIN64)
|
||||
if (m_pLanguage != 0)
|
||||
{
|
||||
g_currentLanguageID = GetLanguageID(m_pLanguage->sLanguage);
|
||||
g_currentLanguageID = GetLanguageID(m_pLanguage->sLanguage.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2494,7 +2523,7 @@ void CLocalizedStringsManager::InternalSetCurrentLanguage(CLocalizedStringsManag
|
||||
}
|
||||
}
|
||||
|
||||
void CLocalizedStringsManager::LocalizeDuration(int seconds, string& outDurationString)
|
||||
void CLocalizedStringsManager::LocalizeDuration(int seconds, AZStd::string& outDurationString)
|
||||
{
|
||||
int s = seconds;
|
||||
int d, h, m;
|
||||
@@ -2504,27 +2533,27 @@ void CLocalizedStringsManager::LocalizeDuration(int seconds, string& outDuration
|
||||
s -= h * 3600;
|
||||
m = s / 60;
|
||||
s = s - m * 60;
|
||||
string str;
|
||||
AZStd::string str;
|
||||
if (d > 1)
|
||||
{
|
||||
str.Format("%d @ui_days %02d:%02d:%02d", d, h, m, s);
|
||||
str = AZStd::string::format("%d @ui_days %02d:%02d:%02d", d, h, m, s);
|
||||
}
|
||||
else if (d > 0)
|
||||
{
|
||||
str.Format("%d @ui_day %02d:%02d:%02d", d, h, m, s);
|
||||
str = AZStd::string::format("%d @ui_day %02d:%02d:%02d", d, h, m, s);
|
||||
}
|
||||
else if (h > 0)
|
||||
{
|
||||
str.Format("%02d:%02d:%02d", h, m, s);
|
||||
str = AZStd::string::format("%02d:%02d:%02d", h, m, s);
|
||||
}
|
||||
else
|
||||
{
|
||||
str.Format("%02d:%02d", m, s);
|
||||
str = AZStd::string::format("%02d:%02d", m, s);
|
||||
}
|
||||
LocalizeString_s(str, outDurationString);
|
||||
}
|
||||
|
||||
void CLocalizedStringsManager::LocalizeNumber(int number, string& outNumberString)
|
||||
void CLocalizedStringsManager::LocalizeNumber(int number, AZStd::string& outNumberString)
|
||||
{
|
||||
if (number == 0)
|
||||
{
|
||||
@@ -2535,7 +2564,7 @@ void CLocalizedStringsManager::LocalizeNumber(int number, string& outNumberStrin
|
||||
outNumberString.assign("");
|
||||
|
||||
int n = abs(number);
|
||||
string separator;
|
||||
AZStd::string separator;
|
||||
AZStd::fixed_string<64> tmp;
|
||||
LocalizeString_ch("@ui_thousand_separator", separator);
|
||||
while (n > 0)
|
||||
@@ -2544,41 +2573,41 @@ void CLocalizedStringsManager::LocalizeNumber(int number, string& outNumberStrin
|
||||
int b = n - (a * 1000);
|
||||
if (a > 0)
|
||||
{
|
||||
tmp.Format("%s%03d%s", separator.c_str(), b, tmp.c_str());
|
||||
tmp = AZStd::string::format("%s%03d%s", separator.c_str(), b, tmp.c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
tmp.Format("%d%s", b, tmp.c_str());
|
||||
tmp = AZStd::string::format("%d%s", b, tmp.c_str());
|
||||
}
|
||||
n = a;
|
||||
}
|
||||
|
||||
if (number < 0)
|
||||
{
|
||||
tmp.Format("-%s", tmp.c_str());
|
||||
tmp = AZStd::string::format("-%s", tmp.c_str());
|
||||
}
|
||||
|
||||
outNumberString.assign(tmp.c_str());
|
||||
}
|
||||
|
||||
void CLocalizedStringsManager::LocalizeNumber_Decimal(float number, int decimals, string& outNumberString)
|
||||
void CLocalizedStringsManager::LocalizeNumber_Decimal(float number, int decimals, AZStd::string& outNumberString)
|
||||
{
|
||||
if (number == 0.0f)
|
||||
{
|
||||
AZStd::fixed_string<64> tmp;
|
||||
tmp.Format("%.*f", decimals, number);
|
||||
tmp = AZStd::fixed_string<64>::format("%.*f", decimals, number);
|
||||
outNumberString.assign(tmp.c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
outNumberString.assign("");
|
||||
|
||||
string commaSeparator;
|
||||
AZStd::string commaSeparator;
|
||||
LocalizeString_ch("@ui_decimal_separator", commaSeparator);
|
||||
float f = number > 0.0f ? number : -number;
|
||||
int d = (int)f;
|
||||
|
||||
string intPart;
|
||||
AZStd::string intPart;
|
||||
LocalizeNumber(d, intPart);
|
||||
|
||||
float decimalsOnly = f - (float)d;
|
||||
@@ -2586,7 +2615,7 @@ void CLocalizedStringsManager::LocalizeNumber_Decimal(float number, int decimals
|
||||
int decimalsAsInt = aznumeric_cast<int>(int_round(decimalsOnly * pow(10.0f, decimals)));
|
||||
|
||||
AZStd::fixed_string<64> tmp;
|
||||
tmp.Format("%s%s%0*d", intPart.c_str(), commaSeparator.c_str(), decimals, decimalsAsInt);
|
||||
tmp = AZStd::fixed_string<64>::format("%s%s%0*d", intPart.c_str(), commaSeparator.c_str(), decimals, decimalsAsInt);
|
||||
|
||||
outNumberString.assign(tmp.c_str());
|
||||
}
|
||||
@@ -2640,7 +2669,7 @@ namespace
|
||||
}
|
||||
};
|
||||
|
||||
void CLocalizedStringsManager::LocalizeTime(time_t t, bool bMakeLocalTime, bool bShowSeconds, string& outTimeString)
|
||||
void CLocalizedStringsManager::LocalizeTime(time_t t, bool bMakeLocalTime, bool bShowSeconds, AZStd::string& outTimeString)
|
||||
{
|
||||
if (bMakeLocalTime)
|
||||
{
|
||||
@@ -2664,7 +2693,7 @@ void CLocalizedStringsManager::LocalizeTime(time_t t, bool bMakeLocalTime, bool
|
||||
}
|
||||
}
|
||||
|
||||
void CLocalizedStringsManager::LocalizeDate(time_t t, bool bMakeLocalTime, bool bShort, bool bIncludeWeekday, string& outDateString)
|
||||
void CLocalizedStringsManager::LocalizeDate(time_t t, bool bMakeLocalTime, bool bShort, bool bIncludeWeekday, AZStd::string& outDateString)
|
||||
{
|
||||
if (bMakeLocalTime)
|
||||
{
|
||||
@@ -2689,7 +2718,7 @@ void CLocalizedStringsManager::LocalizeDate(time_t t, bool bMakeLocalTime, bool
|
||||
// len includes terminating null!
|
||||
tmpString.resize(len);
|
||||
::GetDateFormatW(lcID, 0, &systemTime, L"ddd", (wchar_t*) tmpString.c_str(), len);
|
||||
string utf8;
|
||||
AZStd::string utf8;
|
||||
Unicode::Convert(utf8, tmpString);
|
||||
outDateString.append(utf8);
|
||||
outDateString.append(" ");
|
||||
@@ -2702,7 +2731,7 @@ void CLocalizedStringsManager::LocalizeDate(time_t t, bool bMakeLocalTime, bool
|
||||
// len includes terminating null!
|
||||
tmpString.resize(len);
|
||||
::GetDateFormatW(lcID, flags, &systemTime, 0, (wchar_t*) tmpString.c_str(), len);
|
||||
string utf8;
|
||||
AZStd::string utf8;
|
||||
Unicode::Convert(utf8, tmpString);
|
||||
outDateString.append(utf8);
|
||||
}
|
||||
@@ -2710,7 +2739,7 @@ void CLocalizedStringsManager::LocalizeDate(time_t t, bool bMakeLocalTime, bool
|
||||
|
||||
#else // #if defined (WIN32) || defined(WIN64)
|
||||
|
||||
void CLocalizedStringsManager::LocalizeTime(time_t t, bool bMakeLocalTime, bool bShowSeconds, string& outTimeString)
|
||||
void CLocalizedStringsManager::LocalizeTime(time_t t, bool bMakeLocalTime, bool bShowSeconds, AZStd::string& outTimeString)
|
||||
{
|
||||
struct tm theTime;
|
||||
if (bMakeLocalTime)
|
||||
@@ -2737,7 +2766,7 @@ void CLocalizedStringsManager::LocalizeTime(time_t t, bool bMakeLocalTime, bool
|
||||
Unicode::Convert(outTimeString, buf);
|
||||
}
|
||||
|
||||
void CLocalizedStringsManager::LocalizeDate(time_t t, bool bMakeLocalTime, bool bShort, bool bIncludeWeekday, string& outDateString)
|
||||
void CLocalizedStringsManager::LocalizeDate(time_t t, bool bMakeLocalTime, bool bShort, bool bIncludeWeekday, AZStd::string& outDateString)
|
||||
{
|
||||
struct tm theTime;
|
||||
if (bMakeLocalTime)
|
||||
|
||||
Reference in New Issue
Block a user