aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjmarshallnz <jmarshallnz@svn>2009-11-15 02:14:09 +0000
committerjmarshallnz <jmarshallnz@svn>2009-11-15 02:14:09 +0000
commit734b228395b97416f28f559e9604b68aeea2da37 (patch)
tree596ef1058c6501ea8d1e2a28e322723151e68ac4
parentd51b635a3d6e2b531176e2c734f1b772aea3277e (diff)
changed: factor out the search for $LOCALIZE[] in infolabels into a separate function
git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/trunk@24618 568bbfeb-2a22-0410-94d2-cc84cf5bfa90
-rw-r--r--guilib/GUIInfoTypes.cpp17
-rw-r--r--guilib/GUIInfoTypes.h8
2 files changed, 20 insertions, 5 deletions
diff --git a/guilib/GUIInfoTypes.cpp b/guilib/GUIInfoTypes.cpp
index 28fcf2e7e8..4c7cf04e15 100644
--- a/guilib/GUIInfoTypes.cpp
+++ b/guilib/GUIInfoTypes.cpp
@@ -194,11 +194,10 @@ bool CGUIInfoLabel::IsConstant() const
return m_info.size() == 0 || (m_info.size() == 1 && m_info[0].m_info == 0);
}
-void CGUIInfoLabel::Parse(const CStdString &label)
+CStdString CGUIInfoLabel::ReplaceLocalize(const CStdString &label)
{
- m_info.clear();
CStdString work(label);
- // Step 1: Replace all $LOCALIZE[number] with the real string
+ // Replace all $LOCALIZE[number] with the real string
int pos1 = work.Find("$LOCALIZE[");
while (pos1 >= 0)
{
@@ -215,12 +214,20 @@ void CGUIInfoLabel::Parse(const CStdString &label)
else
{
CLog::Log(LOGERROR, "Error parsing label - missing ']'");
- return;
+ return "";
}
pos1 = work.Find("$LOCALIZE[", pos1);
}
+ return work;
+}
+
+void CGUIInfoLabel::Parse(const CStdString &label)
+{
+ m_info.clear();
+ // Step 1: Replace all $LOCALIZE[number] with the real string
+ CStdString work = ReplaceLocalize(label);
// Step 2: Find all $INFO[info,prefix,postfix] blocks
- pos1 = work.Find("$INFO[");
+ int pos1 = work.Find("$INFO[");
while (pos1 >= 0)
{
// output the first block (contents before first $INFO)
diff --git a/guilib/GUIInfoTypes.h b/guilib/GUIInfoTypes.h
index bd3db7fe04..1989ed36e3 100644
--- a/guilib/GUIInfoTypes.h
+++ b/guilib/GUIInfoTypes.h
@@ -81,6 +81,14 @@ public:
const CStdString GetFallback() const { return m_fallback; };
static CStdString GetLabel(const CStdString &label, bool preferImage = false);
+
+ /*!
+ \brief Replaces instances of $LOCALIZE[number] with the appropriate localized string
+ \param label text to replace
+ \return text with any localized strings filled in.
+ */
+ static CStdString ReplaceLocalize(const CStdString &label);
+
private:
void Parse(const CStdString &label);