Beispiel #1
0
        public KeyLanguageTextMap RepopulateAllTranslations()
        {
            // Setup or clear the dictionary
            if (allTranslations == null)
            {
                allTranslations = new KeyLanguageTextMap(this);
            }
            allTranslations.Clear();

            // Populate the dictionary
            LanguageTextMap toAdd = null;

            foreach (TranslationCollection collection in translations)
            {
                // Create a new dictionary
                toAdd = allTranslations.Add(collection.Key);
                if (toAdd != null)
                {
                    // Add all the pairs
                    foreach (LanguageTextPair pair in collection.AllTranslations)
                    {
                        // Make sure the language is supported before adding to the map
                        if (SupportedLanguages.Contains(pair.LanguageIndex) == true)
                        {
                            toAdd[pair.LanguageIndex] = pair.Text;
                        }
                    }
                }
            }

            // Indicate the dictionary matches the serialization
            IsAllTranslationsSerialized = true;
            return(allTranslations);
        }
Beispiel #2
0
        public List <TranslationCollection> UpdateSerializedTranslations(ProgressReport report = null)
        {
            // Check if we need to report our progress
            if (report != null)
            {
                // Set the number of steps involved in serialization
                report.SetTotalSteps(AllTranslations.Count);
            }

            // Grab a soft-copy of all translations
            KeyLanguageTextMap translationCopy = AllTranslations;

            // Clear the translations list (this needs to happen AFTER calling AllTranslations' getter)
            translations.Clear();

            // Go through all the keys
            TranslationCollection collectionToAdd;
            LanguageTextPair      pairToAdd;

            foreach (KeyValuePair <string, LanguageTextMap> collection in translationCopy)
            {
                // Create a new collection of translations
                collectionToAdd = new TranslationCollection(collection.Key);

                // Go through all translations
                foreach (KeyValuePair <int, string> pair in collection.Value)
                {
                    // Create a new pair
                    pairToAdd = new LanguageTextPair(pair.Key, pair.Value);

                    // Add the pair to the collection
                    collectionToAdd.AllTranslations.Add(pairToAdd);
                }

                // Add new collection to the list
                translations.Add(collectionToAdd);

                // Check if we need to report our progress
                if (report != null)
                {
                    // Increment
                    report.IncrementCurrentStep();
                }
            }

            // Indicate the dictionary matches the serialization
            IsAllTranslationsSerialized = true;

            // Return the updated translations list
            return(translations);
        }
Beispiel #3
0
 public LanguageTextMap(KeyLanguageTextMap parent)
 {
     dictionary = new SortedDictionary <int, string>();
     Parent     = parent;
 }