LocalizableEntity ProcessPropertyLine(ClasslikeEntity jsObject, String line) { Match m1; m1 = lineForLocalizationSimple.Match(line); if (m1.Success) { var name = m1.Result("${name}"); var value = m1.Result("${value}").TrimEnd(',', ';', ' ', '\t', '\r', '\n'); bool quotes = (value.StartsWith("'") && value.EndsWith("'")); bool dquotes = (value.StartsWith("\"") && value.EndsWith("\"")); return(new LocalizableEntity { EnclosingEntity = jsObject, EntityName = name, ShallowEntityPath = jsObject.ShortEntityName + "." + name, FullEntityPath = jsObject.EntityNameForOverride + "." + name, IsQuoteEnclosed = quotes, Value = quotes ? value.TrimStart('\'').TrimEnd('\'') : (dquotes ? value.TrimStart('"').TrimEnd('"') : value) }); } else { return(null); } }
private LocalizableEntity GetLocalizableProperty(string filePath, string fieldName, string fieldValue) { var ee = new ClasslikeEntity { EntityNameForOverride = String.Empty, FilePath = filePath, FullEntityName = fieldName, ShortEntityName = String.Empty }; return new LocalizableEntity { EnclosingEntity = ee, FullEntityPath = fieldName, IsQuoteEnclosed = false, // KISS EntityName = fieldName, ShallowEntityPath = fieldName, Value = fieldValue }; }
private LocalizableEntity GetLocalizableProperty(string filePath, string fieldName, string fieldValue) { var ee = new ClasslikeEntity { EntityNameForOverride = String.Empty, FilePath = filePath, FullEntityName = fieldName, ShortEntityName = String.Empty }; return(new LocalizableEntity { EnclosingEntity = ee, FullEntityPath = fieldName, IsQuoteEnclosed = false, // KISS EntityName = fieldName, ShallowEntityPath = fieldName, Value = fieldValue }); }
public override void ProcessFile(String filePath, Dictionary <String, LocalizableEntity> map) { ClasslikeEntity jsObject = null; System.IO.TextReader reader = new System.IO.StreamReader(filePath, Encoding.UTF8); //Logger.LogFormat("Processing file {0}", filePath); try { while (reader.Peek() > 0) { String line = reader.ReadLine(); ClasslikeEntity o = ProcessEntityDefinitionLine(filePath, line); if (o != null) { jsObject = o; } else if (jsObject != null) { LocalizableEntity prop = ProcessPropertyLine(jsObject, line); if (prop != null && !map.ContainsKey(prop.FullEntityPath)) { map.Add(prop.FullEntityPath, prop); } } } Logger.LogFormat("Processing file {0} - Success", filePath); } catch (Exception ex) { Logger.LogFormat("Processing file {0} - Error", filePath); throw ex; } finally { reader.Close(); } }
LocalizableEntity ProcessPropertyLine(ClasslikeEntity jsObject, String line) { Match m1; m1 = lineForLocalizationSimple.Match(line); if (m1.Success) { var name = m1.Result("${name}"); var value = m1.Result("${value}").TrimEnd(',', ';', ' ', '\t', '\r', '\n'); bool quotes = (value.StartsWith("'") && value.EndsWith("'")); bool dquotes = (value.StartsWith("\"") && value.EndsWith("\"")); return new LocalizableEntity { EnclosingEntity = jsObject, EntityName = name, ShallowEntityPath = jsObject.ShortEntityName + "." + name, FullEntityPath = jsObject.EntityNameForOverride + "." + name, IsQuoteEnclosed = quotes, Value = quotes ? value.TrimStart('\'').TrimEnd('\'') : (dquotes ? value.TrimStart('"').TrimEnd('"') : value) }; } else return null; }