public void SendMessage(TranslationContainer message) { if (message.Args == null) { Logger.Info(new CultureTextContainer(message.Key)); } else { Logger.Info(new CultureTextContainer(message.Key, message.Args)); } }
public void SendMessage(TranslationContainer message) { if (message.Args == null) { this.SendMessage(message.GetText(), new object[0]); } else { this.SendMessage(message.GetText(), message.Args); } }
public static PropertyContainer FromXliff(TranslationContainer container) { if (container is Group) { return(PropertyGroup.FromXliff(container)); } if (container is Unit) { return(Property.FromXliff(container)); } return(null); }
public static new PropertyContainer FromXliff(TranslationContainer xliffGroup) { var group = xliffGroup as Group; var propertyGroup = new PropertyGroup(xliffGroup.Name); foreach (var container in group.Containers) { propertyGroup.Containers.Add(PropertyContainer.FromXliff(container)); } return(propertyGroup); }
public void BroadcastMessage(TranslationContainer message, Player[] players = null) { if (players == null) { players = this.GetPlayers(); } for (int i = 0; i < players.Length; ++i) { players[i].SendMessage(message); } }
public static new PropertyContainer FromXliff(TranslationContainer xliffUnit) { var unit = xliffUnit as Unit; //TODO: Add test for this condition if (unit.Resources.Count > 1) { throw new InvalidOperationException("Error on unit " + unit.SelectorPath + ": Cannot operate on multiple segments. Make sure previous steps of the import have merged all segments into one."); } var segment = unit.Resources[0] as Segment; //TODO: Add test for this condition if (segment.Target == null || segment.Target.Text == null || segment.Target.Text.Count == 0) { throw new InvalidOperationException("Unit " + unit.SelectorPath + " doesn't have a target: cannot import."); } //TODO: Add test for this condition if (segment.Target.Text.Count > 1) { throw new InvalidOperationException("Error on unit " + unit.SelectorPath + ": Cannot operate on target with multiple elements. Make sure previous steps have converted all inline markup into a CData section"); } string textValue = string.Empty; var text = segment.Target.Text[0] as PlainText; if (text != null) { textValue = text.Text; } var html = segment.Target.Text[0] as CDataTag; if (html != null) { textValue = html.Text; } if (!String.IsNullOrWhiteSpace(textValue)) { var property = new Property(unit.Name, textValue); if (unit.Metadata != null) { property.Attributes = AttributeList.FromXliffMetadata(unit.Metadata); } return(property); } //TODO: Add test for this condition return(null); }
public static PropertyContainer FromXliff(TranslationContainer container) { PropertyContainer propertyContainer = null; if (container is Group) { propertyContainer = PropertyGroup.FromXliff(container); } if (container is Unit) { propertyContainer = Property.FromXliff(container); } return(propertyContainer); }
/// <summary> /// The add element. /// </summary> /// <param name="xw"> /// The xmlWriter. /// </param> /// <param name="container"> /// The container. /// </param> /// <param name="cultureInfo"> /// The culture info. /// </param> private void AddElement(XmlWriter xw, ContentReference container, CultureInfo cultureInfo) { List <PageData> children = this.ContentRepository.GetChildren <PageData>(container, new LanguageSelector(cultureInfo.Name)).ToList(); foreach (PageData child in children) { TranslationContainer translationContainer = child as TranslationContainer; if (translationContainer != null) { string key = Regex.Replace( translationContainer.Name.ToLowerInvariant(), @"[^A-Za-z0-9]+", string.Empty); xw.WriteStartElement(key); this.AddElement(xw, child.PageLink, cultureInfo); xw.WriteEndElement(); } CategoryTranslationContainer categoryTranslationContainer = child as CategoryTranslationContainer; if (categoryTranslationContainer != null) { xw.WriteStartElement("categories"); this.AddCategoryElement(xw, child.PageLink, cultureInfo); xw.WriteEndElement(); } TranslationItem translationItem = child as TranslationItem; if (translationItem != null) { string key = Regex.Replace( translationItem.OriginalText.ToLowerInvariant(), @"[^A-Za-z0-9]+", string.Empty); xw.WriteElementString(key, translationItem.Translation); } } }
public static new PropertyContainer FromXliff(TranslationContainer xliffGroup) { var group = xliffGroup as Group; var propertyGroup = new PropertyGroup(xliffGroup.Name); if (group.Metadata != null) { propertyGroup.Attributes = AttributeList.FromXliffMetadata(group.Metadata); } foreach (var container in group.Containers) { var property = PropertyContainer.FromXliff(container); if (property != null) { propertyGroup.Containers.Add(property); } } return(propertyGroup); }
public void BroadcastMessageAndLoggerSend(TranslationContainer message, Player[] players = null) { if (players == null) { players = this.GetPlayers(); } for (int i = 0; i < players.Length; ++i) { players[i].SendMessage(message); } if (message.Args == null) { IO.Logger.Info(new CultureTextContainer(message.Key)); } else { IO.Logger.Info(new CultureTextContainer(message.Key, message.Args)); } }
public static new PropertyContainer FromXliff(TranslationContainer xliffUnit) { var unit = xliffUnit as Unit; //TODO: Add test for this condition if (unit.Resources.Count > 1) { throw new InvalidOperationException("Cannot operate on multiple segments. Make sure previous steps of the import have merged all segments into one."); } var segment = unit.Resources[0] as Segment; //TODO: Add test for this condition if (segment.Target == null || segment.Target.Text == null || segment.Target.Text.Count == 0) { throw new InvalidOperationException("Property doesn't have a target: cannot import."); } //TODO: Add test for this condition if (segment.Target.Text.Count > 1) { throw new InvalidOperationException("Cannot operate on target with multiple elements. Make sure previous steps have converted all inline markup into a CData section"); } var text = segment.Target.Text[0] as PlainText; if (text != null) { return(new Property(xliffUnit.Name, text.Text)); } var html = segment.Target.Text[0] as CDataTag; if (html != null) { return(new Property(xliffUnit.Name, html.Text)); } //TODO: Add test for this condition return(null); }
/// <summary> /// Get the translation container. /// </summary> /// <returns> /// The <see cref="PageReference" /> to the translation container. /// </returns> private PageReference GetTranslationContainer() { PageReference containerPageReference = this.ContentRepository.Get <ContentData>(ContentReference.StartPage) .GetPropertyValue("TranslationContainer", ContentReference.StartPage); if (containerPageReference == ContentReference.StartPage) { Logger.Info("[Localization] No translation container specified."); TranslationContainer containerReference = this.ContentRepository.GetChildren <PageData>(containerPageReference).OfType <TranslationContainer>().FirstOrDefault(); if (containerReference != null) { Logger.Info("[Localization] First translation container used."); containerPageReference = containerReference.PageLink; } } return(containerPageReference); }