private static void MergeDictionaries(LocalizationDictionary current, LocalizationDictionary modified, bool addContext)
        {
            int added   = 0;
            int deleted = 0;
            int updated = 0;

            foreach (var key in modified.Keys.ToList())
            {
                if (!current.ContainsKey(key))
                {
                    Logger.Write("+ " + key);
                    added++;
                    current[key] = new LocalizationEntry()
                    {
                        Text    = modified[key].Text,
                        Context = modified[key].Context
                    };
                }
                else
                {
                    var currentEntry = current[key];
                    var newEntry     = modified[key];
                    if (currentEntry.Context != newEntry.Context)
                    {
                        Logger.Write("Context updated for: " + key);
                        updated++;
                        currentEntry.Context = newEntry.Context;
                    }
                }
                if (!addContext)
                {
                    current[key].Context = "";
                }
            }
            foreach (var key in current.Keys.ToList())
            {
                if (!modified.ContainsKey(key) && !LocalizationDictionary.IsComment(key))
                {
                    Logger.Write("- " + key);
                    deleted++;
                    current.Remove(key);
                }
            }

            Logger.Write("Added {0}\nDeleted {1}\nContext updated {2}", added, deleted, updated);
        }
Beispiel #2
0
        private void MergeDictionaries(LocalizationDictionary current, LocalizationDictionary modified)
        {
            int added = 0, deleted = 0;

            foreach (var key in modified.Keys.ToList())
            {
                if (!current.ContainsKey(key))
                {
                    Logger.Write("+ " + key);
                    added++;
                    current[key] = modified[key];
                }
            }
            foreach (var key in current.Keys.ToList())
            {
                if (!modified.ContainsKey(key) && !LocalizationDictionary.IsComment(key))
                {
                    Logger.Write("- " + key);
                    deleted++;
                    current.Remove(key);
                }
            }
            Logger.Write("Added {0}\nDeleted {1}", added, deleted);
        }