forked from 0ad/0ad
Add support for adding translation context to XML elements. Patch by Gallaecio.
Add translation context to some lobby headers. This was SVN commit r15078.
This commit is contained in:
parent
057fa79bdb
commit
62f5476dec
@ -95,7 +95,7 @@
|
||||
|
||||
<object size="100%-425 355 100%-285 470" name="mapTypeSelectionTooltip">
|
||||
<object type="text" style="ModernRightLabelText" size="0 0 100% 30">
|
||||
<translatableAttribute id="caption">Match Type:</translatableAttribute>
|
||||
<translatableAttribute id="caption">Map Type:</translatableAttribute>
|
||||
</object>
|
||||
<object type="text" style="ModernRightLabelText" size="0 32 100% 62">
|
||||
<translatableAttribute id="caption">Map Filter:</translatableAttribute>
|
||||
|
@ -132,10 +132,10 @@
|
||||
<translatableAttribute id="heading">Map Name</translatableAttribute>
|
||||
</def>
|
||||
<def id="mapSize" color="128 128 128" width="16%">
|
||||
<translatableAttribute id="heading">Size</translatableAttribute>
|
||||
<translatableAttribute id="heading" context="map">Size</translatableAttribute>
|
||||
</def>
|
||||
<def id="mapType" color="0 128 128" width="16%">
|
||||
<translatableAttribute id="heading">Type</translatableAttribute>
|
||||
<translatableAttribute id="heading" context="map">Type</translatableAttribute>
|
||||
</def>
|
||||
<def id="nPlayers" color="0 128 128" width="16%">
|
||||
<translatableAttribute id="heading">Players</translatableAttribute>
|
||||
|
@ -1109,6 +1109,7 @@ void CGUI::Xeromyces_ReadObject(XMBElement Element, CXeromyces* pFile, IGUIObjec
|
||||
ATTR(on);
|
||||
ATTR(file);
|
||||
ATTR(id);
|
||||
ATTR(context);
|
||||
|
||||
//
|
||||
// Read Style and set defaults
|
||||
@ -1290,8 +1291,17 @@ void CGUI::Xeromyces_ReadObject(XMBElement Element, CXeromyces* pFile, IGUIObjec
|
||||
CStr value(child.GetText());
|
||||
if (!value.empty())
|
||||
{
|
||||
CStr translatedValue(L10n::Instance().Translate(value));
|
||||
object->SetSetting(attributeName, translatedValue.UnescapeBackslashes().FromUTF8(), true);
|
||||
CStr context(child.GetAttributes().GetNamedItem(attr_context)); // Read the context if any.
|
||||
if (!context.empty())
|
||||
{
|
||||
CStr translatedValue(L10n::Instance().TranslateWithContext(context, value));
|
||||
object->SetSetting(attributeName, translatedValue.UnescapeBackslashes().FromUTF8(), true);
|
||||
}
|
||||
else
|
||||
{
|
||||
CStr translatedValue(L10n::Instance().Translate(value));
|
||||
object->SetSetting(attributeName, translatedValue.UnescapeBackslashes().FromUTF8(), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
else // Ignore.
|
||||
|
@ -129,6 +129,7 @@ bool COList::HandleAdditionalChildren(const XMBElement& child, CXeromyces* pFile
|
||||
ELMT(def);
|
||||
ELMT(translatableAttribute);
|
||||
ATTR(id);
|
||||
ATTR(context);
|
||||
|
||||
if (child.GetNodeName() == elmt_item)
|
||||
{
|
||||
@ -198,8 +199,17 @@ bool COList::HandleAdditionalChildren(const XMBElement& child, CXeromyces* pFile
|
||||
CStr value(grandchild.GetText());
|
||||
if (!value.empty())
|
||||
{
|
||||
CStr translatedValue(L10n::Instance().Translate(value));
|
||||
oDef.m_Heading = translatedValue.FromUTF8();
|
||||
CStr context(grandchild.GetAttributes().GetNamedItem(attr_context)); // Read the context if any.
|
||||
if (!context.empty())
|
||||
{
|
||||
CStr translatedValue(L10n::Instance().TranslateWithContext(context, value));
|
||||
oDef.m_Heading = translatedValue.FromUTF8();
|
||||
}
|
||||
else
|
||||
{
|
||||
CStr translatedValue(L10n::Instance().Translate(value));
|
||||
oDef.m_Heading = translatedValue.FromUTF8();
|
||||
}
|
||||
}
|
||||
}
|
||||
else // Ignore.
|
||||
|
@ -413,6 +413,8 @@ class xml(Extractor):
|
||||
position += " ({attributes})".format(attributes=", ".join(attributes))
|
||||
if "tagAsContext" in self.keywords[keyword]:
|
||||
context = keyword
|
||||
if "context" in element.attrib:
|
||||
context = element.get("context")
|
||||
if "comment" in element.attrib:
|
||||
comment = element.get("comment")
|
||||
comment = u" ".join(comment.split()) # Remove tabs, line breaks and unecessary spaces.
|
||||
|
Loading…
Reference in New Issue
Block a user