public OpenTranslationAction(TranslationKeyInfo translationKeyInfo, IServiceProvider serviceProvider)
 {
     _translationKeyInfo = translationKeyInfo;
     _serviceProvider = serviceProvider;
     DisplayText = string.Format("{0}: {1} line {2}", _translationKeyInfo.Language, _translationKeyInfo.FilePath, _translationKeyInfo.LineNumber);
     IsEnabled = true;
 }
        public void AddKey(string key, string language, string value, string filePath, int lineNumber)
        {
            var translationInfo = new TranslationKeyInfo
                                      {
                                          Key = key,
                                          Value = value,
                                          FilePath = filePath,
                                          LineNumber = lineNumber,
                                          Language = language
                                      };

            _translations.Add(translationInfo);

            ResetLookups();
        }
 public void AddKey(TranslationKeyInfo keyInfo)
 {
     _translations.Add(keyInfo);
     ResetLookups();
 }
 private string CreateFileKey(TranslationKeyInfo keyInfo)
 {
     var keyEnding = keyInfo.Key.Split('/').LastOrDefault();
     return GetFilePositionKey(keyInfo.FilePath, keyInfo.LineNumber, keyEnding);
 }
        public IEnumerable<TranslationKeyInfo> ReadTranslationKeys(XDocument doc, string xmlFile)
        {
            var languages = doc.Element("languages");
            if (languages == null)
            {
                yield break;
            }

            foreach (var language in languages.Elements("language"))
            {
                var languageIdAttribute = language.Attribute("id");
                if (languageIdAttribute == null)
                {
                    continue;
                }
                var languageId = languageIdAttribute.Value;

                var nodes = language.Descendants().Where(el => !el.Descendants().Any());
                foreach (var xNode in nodes)
                {
                    var ancestors = xNode.Ancestors().ToList();
                    var ancestorsString = ancestors.Take(ancestors.Count - 2)
                        // Skip two last ancestors - languages and language nodes
                        .Aggregate("", AddElementToPath);

                    var key = KeysSeparator + ancestorsString + GetElementXPath(xNode);
                    var seeAttribute = xNode.Attributes("see").FirstOrDefault();
                    var seeReference = seeAttribute == null ? null : seeAttribute.Value;

                    var value = xNode.Value;

                    int lineNumber = ((IXmlLineInfo) xNode).HasLineInfo() ? ((IXmlLineInfo) xNode).LineNumber : -1;

                    var translationInfo = new TranslationKeyInfo
                                              {
                                                  Key = key,
                                                  Value = value,
                                                  SeeReference = seeReference,
                                                  FilePath = xmlFile,
                                                  LineNumber = lineNumber,
                                                  Language = languageId
                                              };

                    yield return translationInfo;
                }
            }
        }