Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
        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
            };
        }
Exemplo n.º 3
0
        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
            });
        }
Exemplo n.º 4
0
        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();
            }
        }
Exemplo n.º 5
0
        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;
        }