<xs:element name="box-label">
<xs:complexType mixed="true">
+ <xs:attribute ref="xml:lang" minOccurs="1"/>
</xs:complexType>
</xs:element>
return &IgnoringParser::Create; //ignore unknown according to w3c
}
- virtual void Accept(const XmlAttribute& /*attribute*/)
- {}
-
+ virtual void Accept(const XmlAttribute& attribute)
+ {
+ if (m_properNamespace) {
+ m_lang = attribute.lang;
+ }
+ }
virtual void Accept(const Element& element)
{
if (element.ns ==
ThrowMsg(Exception::ParseError,
"box-label element cannot be empty - ignoring");
}
- m_data.m_label = m_label;
+ std::pair<DPL::String, DPL::String> boxLabel;
+ boxLabel.first = m_lang;
+ boxLabel.second = m_label;
+ m_data.m_label.push_back(boxLabel);
}
BoxLabelParser(ConfigParserData::LiveboxInfo& data) :
{}
private:
+ DPL::String m_lang;
DPL::String m_label;
bool m_properNamespace;
ConfigParserData::LiveboxInfo& m_data;
writeAttribute(writer, "nodisplay", "false");
if (!this->label.empty()) {
- startElement(writer, "label");
- writeText(writer, this->label);
- endElement(writer);
+ int defaultLabelChk = 0;
+ FOREACH(m, this->label)
+ {
+ std::pair<DPL::String, DPL::String> boxLabel = *m;
+ startElement(writer, "label");
+ if (!boxLabel.first.empty()) {
+ writeAttribute(writer, "xml:lang", boxLabel.first);
+ } else {
+ defaultLabelChk++;
+ }
+ writeText(writer, boxLabel.second);
+ endElement(writer);
+ }
+ if(!defaultLabelChk) {
+ startElement(writer, "label");
+ writeText(writer, DPL::FromUTF8String("NO NAME"));
+ endElement(writer);
+ }
}
-
if (!this->icon.empty()) {
startElement(writer, "icon");
writeText(writer, this->icon);
* @brief LiveBox element
*/
typedef std::list<std::pair<DPL::String, DPL::String> > boxSizeType;
+typedef std::list<std::pair<DPL::String, DPL::String> > boxLabelType;
struct BoxInfo
{
{
this->updatePeriod = x;
}
- void setLabel(const NcnameType &x)
+ void setLabel(const boxLabelType &x)
{
this->label = x;
}
NcnameType autoLaunch;
NcnameType updatePeriod;
NcnameType timeout;
- NcnameType label;
+ boxLabelType label;
NcnameType icon;
+ NcnameType lang;
BoxInfoType box;
};
liveBox.setUpdatePeriod(ConfigInfo->m_updatePeriod);
}
- if (ConfigInfo->m_label != L"") {
- liveBox.setLabel(ConfigInfo->m_label);
+ std::list<std::pair<DPL::String, DPL::String> > boxLabelList;
+ if (!ConfigInfo->m_label.empty()) {
+ FOREACH(im, ConfigInfo->m_label) {
+ std::pair<DPL::String, DPL::String> boxSize;
+ Locale i = (*im).first;
+ // translate en -> en_US etc
+ DPL::OptionalString tag = getLangTag(i);
+ if (tag.IsNull()) {
+ tag = i;
+ }
+ boxSize.first = (*tag);
+ boxSize.second = (*im).second;
+ boxLabelList.push_back(boxSize);
+ }
+ liveBox.setLabel(boxLabelList);
}
DPL::String defaultLocale =