Ejemplo n.º 1
0
        public static void AddStringList(this Menu m, string uniqueId, string displayName, string[] displayNames,
                                         int defaultValue = 0)
        {
            var slider = m.Add(uniqueId, new Slider(displayName, defaultValue, 0, displayNames.Length - 1));

            slider.DisplayName =
                (LanguageTranslator.GetTranslationFromDisplayName(Language.English, LanguageTranslator.CurrentLanguage,
                                                                  displayName) ?? displayName) + ": " +
                (LanguageTranslator.GetTranslationFromDisplayName(Language.English, LanguageTranslator.CurrentLanguage,
                                                                  displayNames[slider.CurrentValue]) ?? displayNames[slider.CurrentValue]);
            slider.OnValueChange +=
                delegate(ValueBase <int> sender, ValueBase <int> .ValueChangeArgs args)
            {
                slider.DisplayName =
                    (LanguageTranslator.GetTranslationFromDisplayName(Language.English,
                                                                      LanguageTranslator.CurrentLanguage, displayName) ?? displayName) + ": " +
                    (LanguageTranslator.GetTranslationFromDisplayName(Language.English,
                                                                      LanguageTranslator.CurrentLanguage, displayNames[args.NewValue]) ??
                     displayNames[args.NewValue]);
            };
            StringLists.Add(new Tuple <Slider, string, string[]>(slider, displayName, displayNames));
        }
Ejemplo n.º 2
0
 public static void Translate(Language from, Language to)
 {
     foreach (var pair in SubMenus)
     {
         var translation =
             LanguageTranslator.GetTranslationFromDisplayName(from, to, pair.Value.LastTranslation) ??
             pair.Value.OriginalName;
         if (translation != null)
         {
             pair.Value.Menu.DisplayName = translation;
             pair.Value.LastTranslation  = translation;
         }
     }
     foreach (var pair in ValuesBasePerMenu)
     {
         foreach (var pair2 in pair.Value)
         {
             var translation =
                 LanguageTranslator.GetTranslationFromDisplayName(from, to, pair2.Value.LastTranslation) ??
                 pair2.Value.OriginalName;
             if (translation != null)
             {
                 pair2.Value.Value.DisplayName = translation;
                 pair2.Value.LastTranslation   = translation;
             }
         }
     }
     foreach (var tuple in StringLists)
     {
         tuple.Item1.DisplayName =
             (LanguageTranslator.GetTranslationFromDisplayName(Language.English,
                                                               LanguageTranslator.CurrentLanguage, tuple.Item2) ?? tuple.Item2) + ": " +
             (LanguageTranslator.GetTranslationFromDisplayName(Language.English,
                                                               LanguageTranslator.CurrentLanguage, tuple.Item3[tuple.Item1.CurrentValue]) ??
              tuple.Item3[tuple.Item1.CurrentValue]);
     }
 }