/// <summary>
 /// Read the translations from an executable file
 /// </summary>
 public static IEnumerable<TranslationFileValue> ReadExecutableFile(String group, String file)
 {
     // Load the assembly
     Assembly asm = Assembly.LoadFile(file);
     // Explore all resources
     var resourceNames = asm.GetManifestResourceNames().Where(n => n.EndsWith(".resources"));
     foreach (var resName in resourceNames)
     {
         // Cleanup the name
         var cleanResName = resName.Replace(".resources", "");
         // Open the stream for String type
         using (var stream = asm.GetManifestResourceStream(resName))
         {
             if (stream != null)
             {
                 using (var reader = new ResourceReader(stream))
                 {
                     foreach (DictionaryEntry item in reader)
                     {
                         if (!(item.Key is string) && !(item.Value is string))
                             continue;
                         TranslationFileValue tData = new TranslationFileValue
                         {
                             ReferenceGroup = group,
                             ReferenceCode = item.Key.ToString(),
                             Translation = item.Value.ToString()
                         };
                         yield return tData;
                     }
                 }
             }
         }
     }
     yield break;
 }
        /// <summary>
        /// Load the content
        /// </summary>
        public void LoadContent()
        {
            Content.Clear();
            _NeutralFileContent = TranslationFileContent.Load(NeutralFile, this.Group);
            if (TranslationsFile == null)
            {
                _TranslationsFileContent = null;
            }
            else
            {
                _TranslationsFileContent = TranslationFileContent.Load(TranslationsFile, this.Group);
            }
            // Merge the values
            foreach (var nValue in _NeutralFileContent.Content)
            {
                TranslationFileValue tValue = null;
                if (_TranslationsFileContent != null)
                {
                    int pos = Content.Count(c => String.Equals(c.ReferenceKey, nValue.ReferenceKey, StringComparison.OrdinalIgnoreCase));
                    var tValues = _TranslationsFileContent.Content.Where(c => String.Equals(c.ReferenceKey, nValue.ReferenceKey, StringComparison.OrdinalIgnoreCase)).ToList();

                    tValue = tValues.Skip(pos).FirstOrDefault();
                    if (tValue == null)
                    {
                        tValue = new TranslationFileValue
                        {
                            ReferenceGroup = nValue.ReferenceGroup,
                            ReferenceCode = nValue.ReferenceCode,
                            Description = nValue.Description
                        };
                        _TranslationsFileContent.Content.Add(tValue);
                    }
                }
                TranslationContentValue cValue = new TranslationContentValue(this, nValue, tValue);
                Content.Add(cValue);
            }
        }
 internal TranslationContentValue(TranslationContent content, TranslationFileValue neutral, TranslationFileValue translation)
 {
     this.Content = content;
     this.Neutral = neutral;
     this.Translation = translation;
     this.ReferenceGroup = this.Neutral.ReferenceGroup;
     this.ReferenceCode = this.Neutral.ReferenceCode;
     this.ReferenceKey = this.Neutral.ReferenceKey;
     this.Description = this.Neutral.Description;
     if (String.IsNullOrWhiteSpace(this.Description))
         this.Description = this.Translation != null ? this.Translation.Description : String.Empty;
     this.NeutralValue = this.Neutral.Translation;
 }
 /// <summary>
 /// Read the translations from a resource file
 /// </summary>
 public static IEnumerable<TranslationFileValue> ReadResourceFile(String group, String file)
 {
     // Load the file
     XDocument xdoc = XDocument.Load(file, LoadOptions.None);
     // Check the root
     if (xdoc.Root.Name != "root")
         throw new InvalidOperationException(Locales.SR.Error_Project_InvalidResourceFile);
     // Search all 'data' tag
     foreach (var dataTag in xdoc.Root.Elements("data"))
     {
         TranslationFileValue tData = new TranslationFileValue
         {
             ReferenceGroup = group,
             ReferenceCode = (string)dataTag.Attribute("name"),
             Description = (string)dataTag.Element("comment"),
             Translation = (string)dataTag.Element("value")
         };
         yield return tData;
     }
 }
 /// <summary>
 /// Read the translations from a XmlDoc file
 /// </summary>
 public static IEnumerable<TranslationFileValue> ReadXmlDocFile(String file)
 {
     // Load the file
     XDocument xdoc = XDocument.Load(file, LoadOptions.None);
     // Check the root
     if (xdoc.Root.Name != "doc")
         throw new InvalidOperationException(Locales.SR.Error_Project_InvalidXmlDocFile);
     // Search all 'member' tag
     foreach (var memberTag in xdoc.Root.Descendants("member"))
     {
         String category = (string)memberTag.Attribute("name");
         foreach (var element in memberTag.Elements())
         {
             String refObj =
                 element.Name.ToString()
                 + String.Concat(element.Attributes().OrderBy(a => a.Name).Select(a => String.Format("@{0}:{1}", a.Name, a.Value)));
             String transValue = String.Empty;
             using (var rdr = element.CreateReader())
             {
                 rdr.MoveToContent();
                 transValue = rdr.ReadInnerXml();
             }
             TranslationFileValue tData = new TranslationFileValue
             {
                 ReferenceGroup = category,
                 ReferenceCode = refObj,
                 Translation = transValue
             };
             yield return tData;
         }
     }
 }