public override string GenerateOutputFile(LocalizedEntityBlock[] blocks) { StringBuilder output = new StringBuilder(); output.AppendLine("/*"); output.AppendLine(" * Auto-generated file"); output.AppendLine(String.Format(" * {0}", DateTime.Now)); output.AppendLine("*/"); output.AppendLine(); foreach (var block in blocks) { bool firstLine = true; output.AppendLine(String.Format("{0} = {{", block.EntityNameForOverride)); foreach (var d in block.LocalizationGridRows) { var value = d.LocalizableProperty.IsQuoteEnclosed ? ("'" + d.Value + "'") : d.Value; output.AppendLine(String.Format("\t{0}{1}: {2}", firstLine ? "" : ",", d.LocalizableProperty.EntityName, value)); firstLine = false; } output.AppendLine("};"); output.AppendLine(); } return output.ToString(); }
public override string GenerateOutputFile(LocalizedEntityBlock[] blocks) { StringBuilder sb = new StringBuilder(); XmlWriter xw = XmlWriter.Create(sb, new XmlWriterSettings { Indent = true, OmitXmlDeclaration = true, NewLineChars = "\r\n" }); xw.WriteStartElement("localization"); foreach (var block in blocks) { xw.WriteStartElement("type"); xw.WriteAttributeString("name", block.EntityNameForOverride); foreach (var r in block.LocalizationGridRows) { xw.WriteStartElement("field"); xw.WriteAttributeString("name", r.LocalizableProperty.EntityName); xw.WriteValue(r.Value); xw.WriteEndElement(); } xw.WriteEndElement(); } xw.WriteEndElement(); xw.Close(); return sb.ToString(); }
public override string GenerateOutputFile(LocalizedEntityBlock[] blocks) { var ms = new MemoryStream(); using (var resxw = new ResXResourceWriter(ms)) foreach (var block in blocks) foreach (var r in block.LocalizationGridRows) resxw.AddResource(r.LocalizableProperty.EntityName, r.Value); var array = ms.ToArray(); return Encoding.UTF8.GetString(array, 3, array.Length - 3); }
public abstract String GenerateOutputFile(LocalizedEntityBlock[] blocks);