本文整理汇总了C#中SIL.Utils.StringTable.LocalizeAttributeValue方法的典型用法代码示例。如果您正苦于以下问题:C# StringTable.LocalizeAttributeValue方法的具体用法?C# StringTable.LocalizeAttributeValue怎么用?C# StringTable.LocalizeAttributeValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SIL.Utils.StringTable
的用法示例。
在下文中一共展示了StringTable.LocalizeAttributeValue方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SummarySlice
/// <summary>
/// Construct one, using the "part ref" element (caller) that
/// invoked the "slice" node that specified this editor.
/// </summary>
/// <param name="caller"></param>
/// <param name="node"></param>
public SummarySlice(ICmObject obj, XmlNode caller, XmlNode node, StringTable stringTbl)
: base()
{
string paramType = XmlUtils.GetOptionalAttributeValue(node.ParentNode, "paramType");
if (paramType == "LiteralString")
{
// Instead of the parameter being a layout name, it is literal text which will be
// the whole contents of the slice, with standard properties.
string text = XmlUtils.GetManditoryAttributeValue(caller, "label");
if (stringTbl != null)
text = stringTbl.LocalizeAttributeValue(text);
m_view = new LiteralLabelView(text, this);
m_fLiteralString = true;
}
else
{
string layout = XmlUtils.GetOptionalAttributeValue(caller, "param");
if (layout == null)
layout = XmlUtils.GetManditoryAttributeValue(node, "layout");
m_view = new SummaryXmlView(obj.Hvo, layout, stringTbl, this);
}
UserControl mainControl = new UserControl();
m_view.Dock = DockStyle.Left;
m_view.LayoutSizeChanged += new EventHandler(m_view_LayoutSizeChanged);
mainControl.Height = m_view.Height;
Control = mainControl;
m_commandControl = new SummaryCommandControl(this);
m_commandControl.Dock = DockStyle.Fill;
m_commandControl.Visible = XmlUtils.GetOptionalBooleanAttributeValue(caller, "commandVisible", false);
mainControl.Controls.Add(m_commandControl);
mainControl.Dock = DockStyle.Fill;
mainControl.Controls.Add(m_view);
}
示例2: LayoutTreeNode
public LayoutTreeNode(XmlNode config, StringTable stringTbl, string classParent)
{
m_xnConfig = config;
m_sLabel = XmlUtils.GetLocalizedAttributeValue(stringTbl, config, "label", null);
if (config.Name == "configure")
{
m_sClassName = XmlUtils.GetManditoryAttributeValue(config, "class");
m_sLayoutName = XmlUtils.GetManditoryAttributeValue(config, "layout");
m_sPartName = String.Empty;
m_sVisibility = "required";
}
else if (config.Name == "part")
{
m_sClassName = classParent;
string sRef = XmlUtils.GetManditoryAttributeValue(config, "ref");
if (m_sLabel == null && stringTbl != null)
m_sLabel = stringTbl.LocalizeAttributeValue(sRef);
if (config.ParentNode != null && config.ParentNode.Name == "layout")
m_sLayoutName = XmlUtils.GetManditoryAttributeValue(config.ParentNode, "name");
else
m_sLayoutName = String.Empty;
m_sPartName = String.Format("{0}-Jt-{1}", classParent, sRef);
m_sVisibility = XmlUtils.GetOptionalAttributeValue(config, "visibility", "always");
m_fContentVisible = m_sVisibility.ToLowerInvariant() != "never";
m_sParam = XmlUtils.GetOptionalAttributeValue(config, "param");
m_sWsLabel = XmlUtils.GetOptionalAttributeValue(config, "ws");
if (m_sWsLabel != null)
{
if (m_sWsLabel.StartsWith(LangProject.WsParamLabel))
m_sWsLabel = m_sWsLabel.Substring(LangProject.WsParamLabel.Length);
}
m_sWsType = XmlUtils.GetOptionalAttributeValue(config, "wsType");
if (m_sWsLabel != null && String.IsNullOrEmpty(m_sWsType))
{
// Try to calculate a WS type from the WS label.
int ichVern = m_sWsLabel.ToLowerInvariant().IndexOf("vern");
int ichAnal = m_sWsLabel.ToLowerInvariant().IndexOf("anal");
int ichPronun = m_sWsLabel.ToLowerInvariant().IndexOf("pronun");
int ichRevers = m_sWsLabel.ToLowerInvariant().IndexOf("revers");
if (ichVern >= 0 && ichAnal >= 0 && ichVern > ichAnal)
m_sWsType = "analysis vernacular";
else if (ichVern >= 0 && ichAnal >= 0 && ichAnal > ichVern)
m_sWsType = "vernacular analysis";
else if (ichVern >= 0)
m_sWsType = "vernacular";
else if (ichAnal >= 0)
m_sWsType = "analysis";
else if (ichPronun >= 0)
m_sWsType = "pronunciation";
else if (ichRevers >= 0)
m_sWsType = "reversal";
else
{
Debug.Fail(String.Format("This layout node ({0}) does not specify @wsType "
+ "and we couldn't compute something reasonable from @ws='{1}' "
+ "so we're setting @wsType to 'vernacular analysis'",
config.Attributes["ref"].Value, config.Attributes["ws"].Value));
m_sWsType = "vernacular analysis"; // who knows???
}
// store the wsType attribute on the node, so that if 'ws' changes to something
// specific, we still know what type of wss to provide options for in the m_lvWritingSystems.
XmlAttribute xa = config.OwnerDocument.CreateAttribute("wsType");
xa.Value = m_sWsType;
config.Attributes.Append(xa);
}
if (m_sWsType != null)
{
if (m_sWsType.StartsWith(LangProject.WsParamLabel))
m_sWsType = m_sWsType.Substring(LangProject.WsParamLabel.Length);
if (m_sWsLabel == null)
m_sWsLabel = "";
}
string sSep = null;
// By default, if we have a ws type or ws label we should be able to show multiple wss,
// and thus need a separator between them.
if (!String.IsNullOrEmpty(m_sWsLabel) || !String.IsNullOrEmpty(m_sWsType))
sSep = " ";
m_sBefore = XmlUtils.GetOptionalAttributeValue(config, "before", "");
m_sSep = XmlUtils.GetOptionalAttributeValue(config, "sep", sSep);
m_sAfter = XmlUtils.GetOptionalAttributeValue(config, "after", " ");
m_sStyleName = XmlUtils.GetOptionalAttributeValue(config, "style");
string sFlowType = XmlUtils.GetOptionalAttributeValue(config, "flowType", "span");
if (sFlowType == "span")
{
m_fAllowCharStyle = true;
if (m_sBefore == null)
m_sBefore = "";
if (m_sAfter == null)
m_sAfter = "";
}
m_sNumber = XmlUtils.GetOptionalAttributeValue(config, "number");
m_sNumStyle = XmlUtils.GetOptionalAttributeValue(config, "numstyle");
m_fNumSingle = XmlUtils.GetOptionalBooleanAttributeValue(config, "numsingle", false);
m_sNumFont = XmlUtils.GetOptionalAttributeValue(config, "numfont");
m_fSingleGramInfoFirst = XmlUtils.GetOptionalBooleanAttributeValue(config, "singlegraminfofirst", false);
m_fShowComplexFormPara = XmlUtils.GetOptionalBooleanAttributeValue(config, "showasindentedpara", false);
m_fShowWsLabels = XmlUtils.GetOptionalBooleanAttributeValue(config, "showLabels", false);
m_sDup = XmlUtils.GetOptionalAttributeValue(config, "dup");
//.........这里部分代码省略.........
示例3: RDENewSense
/// <summary>
/// This is invoked (using reflection) by an XmlRDEBrowseView when the user presses
/// "Enter" in an RDE view that is displaying lexeme form and definition.
/// (Maybe also on loss of focus, switch domain, etc?)
/// It creates a new entry, lexeme form, and sense that are linked to the specified domain.
/// Typically, later, a call to RDEMergeSense will be made to see whether this
/// new entry should be merged into some existing sense.
/// Note that this method is NOT responsible to insert the new sense into
/// the fake property tagList of hvoDomain. (The caller will do that.)
/// </summary>
/// <param name="hvoDomain">database id of the semantic domain</param>
/// <param name="tagList">id of the inverse relation for the senses that belong to the
/// domain</param>
/// <param name="columns"></param>
/// <param name="rgtss"></param>
/// <param name="cache"></param>
/// <param name="stringTbl"></param>
public static int RDENewSense(int hvoDomain, int tagList,
List<XmlNode> columns, ITsString[] rgtss, FdoCache cache, StringTable stringTbl)
{
Debug.Assert(hvoDomain != 0);
Debug.Assert(rgtss.Length == columns.Count);
// Make a new sense in a new entry.
ILexEntry le = cache.LangProject.LexDbOA.EntriesOC.Add(
new LexEntry());
IMoForm morph = null;
// create a LexSense that has the given definition and semantic domain
// Needs to be LexSense, since later calls use non-interface methods.
LexSense ls = (LexSense)le.SensesOS.Append(new LexSense());
ILgWritingSystemFactory wsf = cache.LanguageWritingSystemFactoryAccessor;
// go through each column and store the appropriate information.
for (int i = 0; i < columns.Count; ++i)
{
// Review: Currently we key off the column labels to determine which columns
// correspond to CitationForm and which correspond to Definition.
// Ideally we'd like to get at the flids used to build the column display strings.
// Instead of passing in only ITsStrings, we could pass in a structure containing
// an index of strings with any corresponding flids. Here we'd expect strings
// based upon either LexemeForm.Form or LexSense.Definition. We could probably
// do this as part of the solution to handling duplicate columns in LT-3763.
XmlNode column = columns[i] as XmlNode;
string columnLabel = XmlUtils.GetManditoryAttributeValue(column, "label");
string[] columnLabelComponents = columnLabel.Split(new char[] {' ', ':'});
// get column label without writing system or extraneous information.
string columnBasicLabel = columnLabelComponents[0];
if (!String.IsNullOrEmpty(columnBasicLabel) && stringTbl != null)
columnBasicLabel = stringTbl.LocalizeAttributeValue(columnBasicLabel);
ITsTextProps ttp = rgtss[i].get_PropertiesAt(0);
int var;
int ws = ttp.GetIntPropValues((int)FwTextPropType.ktptWs, out var);
Debug.Assert(ws != 0);
ITsString tssStr = rgtss[i];
string sStr = tssStr.Text;
if (sStr == null)
sStr = ""; // otherwise Trim below blows up.
sStr = sStr.Trim();
if (columnBasicLabel == Strings.ksWord)
{
// This is a lexeme form.
if (morph == null)
morph = MoForm.MakeMorph(cache, le, tssStr);
Debug.Assert(le.LexemeFormOAHvo != 0);
if (morph is IMoStemAllomorph)
{
// Make sure we have a proper allomorph and MSA for this new entry and sense.
// (See LT-1318 for details and justification.)
MoMorphTypeCollection typesCol = new MoMorphTypeCollection(cache);
if (sStr.IndexOf(' ') > 0)
morph.MorphTypeRA = typesCol.Item(MoMorphType.kmtPhrase);
else
morph.MorphTypeRA = typesCol.Item(MoMorphType.kmtStem);
morph.Form.SetAlternative(sStr, ws);
}
}
else if (columnBasicLabel == Strings.ksDefinition)
{
// This is a Definition.
if (sStr != "")
ls.Definition.SetAlternative(sStr, ws);
}
else
{
Debug.Fail("column (" + columnLabel + ") not supported.");
}
}
if (morph == null)
morph = le.LexemeFormOA = new MoStemAllomorph();
ls.RDEAddDomain(hvoDomain, tagList, cache);
if (le.MorphoSyntaxAnalysesOC.Count == 0)
{
// Commonly, it's a new entry with no MSAs; make sure it has at least one.
// This way of doing it allows a good bit of code to be shared with the normal
//.........这里部分代码省略.........
示例4: GetLocalizedAttributeValue
/// <summary>
/// Get an optional attribute value from an XmlNode, and look up its localized value in the
/// given StringTable.
/// </summary>
/// <param name="tbl"></param>
/// <param name="node"></param>
/// <param name="attrName"></param>
/// <param name="defaultString"></param>
/// <returns></returns>
public static string GetLocalizedAttributeValue(StringTable tbl, XmlNode node,
string attrName, string defaultString)
{
string sValue = GetOptionalAttributeValue(node, attrName, defaultString);
if (tbl == null)
return sValue;
return tbl.LocalizeAttributeValue(sValue);
}
示例5: LayoutTreeNode
public LayoutTreeNode(XmlNode config, StringTable stringTbl, string classParent)
{
m_xnConfig = config;
m_sLabel = XmlUtils.GetLocalizedAttributeValue(stringTbl, config, "label", null);
if (config.Name == "configure")
{
m_sClassName = XmlUtils.GetManditoryAttributeValue(config, "class");
m_sLayoutName = XmlUtils.GetManditoryAttributeValue(config, "layout");
m_sPartName = String.Empty;
m_sVisibility = "required";
}
else if (config.Name == "part")
{
m_sClassName = classParent;
string sRef = XmlUtils.GetManditoryAttributeValue(config, "ref");
if (m_sLabel == null && stringTbl != null)
m_sLabel = stringTbl.LocalizeAttributeValue(sRef);
if (config.ParentNode != null && config.ParentNode.Name == "layout")
m_sLayoutName = XmlUtils.GetManditoryAttributeValue(config.ParentNode, "name");
else
m_sLayoutName = String.Empty;
m_sPartName = String.Format("{0}-Jt-{1}", classParent, sRef);
m_sVisibility = XmlUtils.GetOptionalAttributeValue(config, "visibility", "always");
m_fContentVisible = m_sVisibility.ToLowerInvariant() != "never";
m_sParam = XmlUtils.GetOptionalAttributeValue(config, "param");
m_sWsLabel = StringServices.GetWsSpecWithoutPrefix(config);
m_sWsType = XmlUtils.GetOptionalAttributeValue(config, "wsType");
if (m_sWsLabel != null && String.IsNullOrEmpty(m_sWsType))
{
// Try to calculate a WS type from the WS label.
int ichVern = m_sWsLabel.ToLowerInvariant().IndexOf("vern");
int ichAnal = m_sWsLabel.ToLowerInvariant().IndexOf("anal");
int ichPronun = m_sWsLabel.ToLowerInvariant().IndexOf("pronun");
int ichRevers = m_sWsLabel.ToLowerInvariant().IndexOf("revers");
if (ichVern >= 0 && ichAnal >= 0 && ichVern > ichAnal)
m_sWsType = "analysis vernacular";
else if (ichVern >= 0 && ichAnal >= 0 && ichAnal > ichVern)
m_sWsType = "vernacular analysis";
else if (ichVern >= 0)
m_sWsType = "vernacular";
else if (ichAnal >= 0)
m_sWsType = "analysis";
else if (ichPronun >= 0)
m_sWsType = "pronunciation";
else if (ichRevers >= 0)
m_sWsType = "reversal";
else
{
m_sWsType = "vernacular analysis"; // who knows???
string refValue = String.Empty;
string wsValue = String.Empty;
if (config.Attributes != null)
{
refValue = config.Attributes["ref"].Value;
wsValue = config.Attributes["ws"].Value;
}
Debug.Fail(String.Format("This layout node ({0}) does not specify @wsType "
+ "and we couldn't compute something reasonable from @ws='{1}' "
+ "so we're setting @wsType to 'vernacular analysis'",
refValue, wsValue));
}
// store the wsType attribute on the node, so that if 'ws' changes to something
// specific, we still know what type of wss to provide options for in the m_lvWritingSystems.
if (config.OwnerDocument != null)
{
XmlAttribute xa = config.OwnerDocument.CreateAttribute("wsType");
xa.Value = m_sWsType;
if (config.Attributes != null)
config.Attributes.Append(xa);
}
}
m_sWsType = StringServices.GetWsSpecWithoutPrefix(m_sWsType);
if (m_sWsType != null && m_sWsLabel == null)
m_sWsLabel = "";
string sSep = null;
// By default, if we have a ws type or ws label we should be able to show multiple wss,
// and thus need a separator between them.
if (!String.IsNullOrEmpty(m_sWsLabel) || !String.IsNullOrEmpty(m_sWsType))
sSep = " ";
m_sBeforeStyleName = XmlUtils.GetOptionalAttributeValue(config, "beforeStyle");
m_fAllowBeforeStyle = !String.IsNullOrEmpty(m_sBeforeStyleName);
m_sBefore = XmlUtils.GetOptionalAttributeValue(config, "before", "");
m_sSep = XmlUtils.GetOptionalAttributeValue(config, "sep", sSep);
m_sAfter = XmlUtils.GetOptionalAttributeValue(config, "after", " ");
m_sStyleName = XmlUtils.GetOptionalAttributeValue(config, "style");
m_sFlowType = XmlUtils.GetOptionalAttributeValue(config, "flowType", "span");
if (m_sFlowType == "span")
{
m_fAllowCharStyle = !XmlUtils.GetOptionalBooleanAttributeValue(
config, "disallowCharStyle", false);
if (m_sBefore == null)
m_sBefore = "";
if (m_sAfter == null)
m_sAfter = "";
}
// Special handling for div flow elements, which can contain a sequence of paragraphs.
else if (m_sFlowType == "div")
{
//.........这里部分代码省略.........