Ejemplo n.º 1
0
        public string this[string name, CultureInfo culture]
        {
            get
            {
                var texts = from phrase in Phrases
                            where phrase.Name == name
                            from translation in phrase.Translations
                            where translation.Culture.Equals(culture)
                            select translation.Text;

                return(texts.FirstOrDefault());
            }
            set
            {
                if (!Cultures.Any(c => c.Equals(culture)))
                {
                    Cultures.Add(culture);
                }

                var phrase = Phrases.FirstOrDefault(p => p.Name == name);
                if (phrase == null)
                {
                    phrase = new Phrase
                    {
                        Name = name,
                    };

                    Phrases.Add(phrase);
                }

                phrase.Translations[culture].Text = value;
            }
        }
Ejemplo n.º 2
0
        public void LoadFromArchive(string Culture, string FileText)
        {
            if (Subnamespaces == null)
            {
                throw new System.InvalidOperationException("Load manifest first.");
            }

            if (Cultures.Contains(Culture))
            {
                throw new System.ArgumentException("Culture already appended: " + Culture);
            }

            LocaleArchive archive = JsonConvert.DeserializeObject <LocaleArchive>(FileText);

            if (ArchiveVersion != archive.FormatVersion)
            {
                throw new FormatException("Invalid Archive::FormatVersion.");
            }

            if (ArchiveNamespace != archive.Namespace)
            {
                throw new FormatException("Invalid Archive::Namespace. Must be empty.");
            }

            // Move "Children" to "Subnamespace" without name
            if (archive.Children != null && archive.Children.Count > 0)
            {
                LocaleArchiveNamespace emptyNS = new LocaleArchiveNamespace();
                emptyNS.Namespace = "";
                emptyNS.Children  = archive.Children;
                archive.Subnamespaces.Insert(0, emptyNS);
            }

            foreach (var ns in archive.Subnamespaces)
            {
                InternalNamespace ins = GetNamespace(ns.Namespace);

                if (ins == null)
                {
                    throw new FormatException("Archive::Subnamespace not found: " + ns.Namespace + "!");
                }

                foreach (var child in ns.Children)
                {
                    InternalKey ikey = ins.GetKey(child.Key);

                    if (ikey == null)
                    {
                        throw new FormatException("Invalid key (" + child.Key + ") in Archive::Subnamespace::Child " + child.Source.Text + "!");
                    }

                    InternalText text = new InternalText();
                    text.Culture = Culture;
                    text.Text    = child.Translation.Text;
                    ikey.Translations.Add(text);
                }
            }

            Cultures.Add(Culture);
        }
Ejemplo n.º 3
0
        public Eu4Culture AddCulture(PdxSublist data, Eu4WorldBase world)
        {
            var culture = new Eu4Culture(data, this, world);

            Cultures.Add(culture);
            return(culture);
        }
        public override void Initialize()
        {
            Debug.Assert(MultiplayerClassDivisions.AvailableCultures != null, "Available Cultures should not be null");
            if (MultiplayerClassDivisions.AvailableCultures == null)
            {
                return;
            }
            Cultures.Clear();
            foreach (var eachCulture in MultiplayerClassDivisions.AvailableCultures)
            {
                Cultures.Add(eachCulture.StringId);
                var groupsInCurrentCulture = new List <Group>();
                GroupsInCultures.Add(eachCulture.StringId, groupsInCurrentCulture);
                foreach (var mpHeroClass in MultiplayerClassDivisions.GetMPHeroClasses(eachCulture))
                {
                    var group =
                        groupsInCurrentCulture.Find(g => g.Info.StringId == mpHeroClass.ClassGroup.StringId) as MPGroup;
                    if (group == null)
                    {
                        var newGroup = new MPGroup(mpHeroClass.ClassGroup,
                                                   mpHeroClass.HeroCharacter.DefaultFormationClass);
                        groupsInCurrentCulture.Add(newGroup);
                        groupsInCurrentCulture.Sort((lhs, rhs) => lhs.Info.FormationClass - rhs.Info.FormationClass);
                        group = newGroup;
                    }

                    group.CharactersInGroup.Add(mpHeroClass.StringId, new MPCharacter(mpHeroClass, group.Info));
                }
            }
        }
Ejemplo n.º 5
0
 internal void LanguageAdded([NotNull] CultureKey cultureKey)
 {
     if (!Cultures.Contains(cultureKey))
     {
         Cultures.Add(cultureKey);
     }
 }
Ejemplo n.º 6
0
 public Locale()
 {
     Indexes.Add(LocaleCategory.NameInvoker.Instance);
     Cultures.Add(CultureInfo.GetCultureInfo("ru-RU"));
     Cultures.Add(CultureInfo.GetCultureInfo("en-US"));
     //try { Cultures.Add(CultureInfo.GetCultureInfo("kk-KZ")); }
     //catch (Exception ex) { Helper.OnException(ex); }
 }
Ejemplo n.º 7
0
 public Locale()
 {
     Indexes.Add(LocaleCategory.NameInvoker.Instance.Name,
                 new ListIndex <LocaleCategory, string>(LocaleCategory.NameInvoker.Instance, ListIndexFabric.GetNullKey <string>(), StringComparer.Ordinal));
     Cultures.Add(CultureInfo.GetCultureInfo("ru-RU"));
     Cultures.Add(CultureInfo.GetCultureInfo("en-US"));
     //try { Cultures.Add(CultureInfo.GetCultureInfo("kk-KZ")); }
     //catch (Exception ex) { Helper.OnException(ex); }
 }
Ejemplo n.º 8
0
        internal void LanguageAdded([NotNull] CultureKey cultureKey)
        {
            Contract.Requires(cultureKey != null);

            if (!Cultures.Contains(cultureKey))
            {
                Cultures.Add(cultureKey);
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Adds the culture.
        /// </summary>
        /// <param name="newCulture">The new culture.</param>
        public static void AddCulture(Culture newCulture)
        {
            if (Cultures.Contains(newCulture))
            {
                return;
            }

            Cultures.Add(newCulture);
        }
Ejemplo n.º 10
0
        public DefaultEpiserverFixture(EpiserverEngine <Startup> engine)
        {
            Engine = engine;
            Engine.Start();

            Register("episerver.site.name", "Lorem");
            Register("episerver.site.url", new Uri("http://localhost:65099/"));

            Cultures.Add(CultureInfo.GetCultureInfo("en"));
        }
        private void Campaign_SelectedIndexChanged(object sender, EventArgs e)
        {
            Cultures.Clear();
            var list = Culture.GetCulturesForCampaign(GenerationConfiguration.Campaign);

            foreach (var item in list)
            {
                Cultures.Add(item);
            }
        }
Ejemplo n.º 12
0
        public Vic2Culture AddCulture(string eu4Culture, Vic2World vic2World, string vic2Name = null, string prefix = "", bool neoCulture = false)
        {
            if (vic2Name == "british_north_america")
            {
                Console.WriteLine();
            }
            var culture = new Vic2Culture(eu4Culture, vic2World, vic2Name, this, prefix, neoCulture);

            Cultures.Add(culture);
            return(culture);
        }
Ejemplo n.º 13
0
        private static void AddRegions(string parentCulture)
        {
            var regions = CultureInfo.GetCultures(CultureTypes.AllCultures).Where(x => x.Parent.Name == parentCulture);

            foreach (var regionInstance in regions)
            {
                Cultures.Add(new CCulture {
                    DisplayName = regionInstance.DisplayName, Parent = Cultures.First(culture => culture.ISO == regionInstance.Parent.Name), ISO = regionInstance.Name
                });
            }
        }
Ejemplo n.º 14
0
        public DefaultFixture(IEngine engine)
            : base(engine)
        {
            Cultures.Add(CultureInfo.GetCultureInfo("en"));

            RegisterBuilder <SiteDefinition>(s => {
                s.Name    = "Lorem";
                s.SiteUrl = new Uri("http://localhost:65099");
            });

            Start();
        }
Ejemplo n.º 15
0
        public Eu4Culture AddCulture(string name, Eu4WorldBase world, bool vanilla = true, string display = null)
        {
            var culture = new Eu4Culture(name, this, world);

            culture.DisplayName = display;
            Cultures.Add(culture);
            if (!vanilla)
            {
                culture.IsVanilla = false;
            }
            return(culture);
        }
Ejemplo n.º 16
0
        public DefaultEpiserverFixture(EpiserverEngine <Startup> engine)
        {
            Engine = engine;
            Engine.Start();

            Cultures.Add(CultureInfo.GetCultureInfo("en"));

            Register("episerver.site.name", "lorem");
            Register("episerver.site.url", new Uri("http://*****:*****@supersecretpassword.io", Roles.Administrators);
        }
Ejemplo n.º 17
0
        /// <summary>
        ///     Sets the cultures list
        /// </summary>
        public static async void SetCultures()
        {
            Cultures.Clear();
            Cultures.Add(new CCulture {
                DisplayName = "German", ISO = "de"
            });
            Cultures.Add(new CCulture {
                DisplayName = "English", ISO = "en"
            });
            Cultures.Add(new CCulture {
                DisplayName = "Spanish", ISO = "es"
            });
            Cultures.Add(new CCulture {
                DisplayName = "Franch", ISO = "fr"
            });
            Cultures.Add(new CCulture {
                DisplayName = "Hindi", ISO = "hi"
            });
            Cultures.Add(new CCulture {
                DisplayName = "Italian", ISO = "it"
            });
            Cultures.Add(new CCulture {
                DisplayName = "Japanese", ISO = "ja"
            });
            Cultures.Add(new CCulture {
                DisplayName = "Korean", ISO = "ko"
            });
            Cultures.Add(new CCulture {
                DisplayName = "Polish", ISO = "pl"
            });
            Cultures.Add(new CCulture {
                DisplayName = "Portuguese", ISO = "pt"
            });
            Cultures.Add(new CCulture {
                DisplayName = "Russian", ISO = "ru"
            });
            Cultures.Add(new CCulture {
                DisplayName = "Swedish", ISO = "sv"
            });
            Cultures.Add(new CCulture {
                DisplayName = "Chinese", ISO = "zh"
            });
            Cultures.ToList().ForEach(culture => AddRegions(culture.ISO));
            await AddAdditionalCultures();

            await CTranslator.GetAvailableLanguages();

            Cultures = Cultures.OrderBy(culture => culture.ISO).ToObservableList();
            var config = new CConfig();
            await config.LoadFromFileTask(@"D:\Dev\Desktop\ULocalizer\ULocalizer\bin\Debug\data\Localization.ini");
        }
Ejemplo n.º 18
0
        public MainWindowViewModel()
        {
            var a        = LocalizationService.RegisteredPacks;
            var cultures = a.Keys;

            foreach (var culture in cultures)
            {
                var pack = BaseLanguagePack.GetResources(culture);
                Cultures.Add(pack);
                CultureMenus.Add(new MenuItem()
                {
                    Header = $"{pack.EnglishName} ({pack.CultureName})", Tag = pack
                });
            }
        }
        public ExploratoryFixture(Engine engine)
            : base(engine)
        {
            Cultures.Add(CultureInfo.GetCultureInfo("sv"));
            Cultures.Add(CultureInfo.GetCultureInfo("en"));

            RegisterBuilder <SiteDefinition>(s => {
                s.Name    = "Lorem";
                s.SiteUrl = new Uri("http://localhost:61352");
            });

            RegisterBuilder <StartPage>(p => p.Heading = "Welcome to Lorem minimum");

            Start();
        }
Ejemplo n.º 20
0
        public CultureChangerViewModel(ref CultureChangerProperties cultureChangerProperties)
        {
            this._cultureChangerProperties = cultureChangerProperties;
            this.Cultures = new MBBindingList <CultureItemVM>();

            var cultures = MBObjectManager.Instance.GetObjectTypeList <CultureObject>();

            foreach (CultureObject element in cultures)
            {
                if (element.IsMainCulture)
                {
                    Cultures.Add(new CultureItemVM(element, ref this._cultureItems, ref this._cultureChangerProperties));
                }
            }
        }
Ejemplo n.º 21
0
        private static async Task AddAdditionalCultures()
        {
            var isSuccessful = true;

            try
            {
                var additionalCulturesTextData = File.ReadAllLines(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"data\additionalCultures.txt"));
                if (additionalCulturesTextData.Any())
                {
                    foreach (var additionalCultureInfo in additionalCulturesTextData)
                    {
                        var additionalCultureSplitted = new[] { additionalCultureInfo.Substring(0, additionalCultureInfo.IndexOf(" ", StringComparison.Ordinal)), additionalCultureInfo.Substring(additionalCultureInfo.IndexOf(" ", StringComparison.Ordinal) + 1) };
                        var isoSplitted       = additionalCultureSplitted[0].Split('-');
                        var parentCultureIso  = isoSplitted[0];
                        var additionalCulture = new CCulture {
                            ISO = additionalCultureSplitted[0]
                        };
                        if (Cultures.FirstOrDefault(culture => culture.ISO == parentCultureIso) != null)
                        {
                            additionalCulture.Parent      = Cultures.First(culture => culture.ISO == parentCultureIso);
                            additionalCulture.DisplayName = string.Join(" ", additionalCulture.Parent.DisplayName, additionalCultureSplitted[1]);
                        }
                        else
                        {
                            additionalCulture.DisplayName = additionalCultureSplitted[1];
                        }
                        Cultures.Add(additionalCulture);
                    }
                }
                else
                {
                    WriteToConsole("File with additional cultures is empty", MessageType.Error);
                    isSuccessful = false;
                }
            }
            catch (Exception ex)
            {
                WriteToConsole(ex.Message, MessageType.Error);
                isSuccessful = false;
            }
            if (!isSuccessful)
            {
                await ShowError("Additional cultures are not loaded. See console for details.");
            }
        }
        public override void Initialize()
        {
            Cultures.Clear();

            foreach (var basicCharacterObject in TaleWorlds.Core.Game.Current.ObjectManager.GetObjectTypeList <BasicCharacterObject>())
            {
                if (basicCharacterObject is CharacterObject characterObject)
                {
                    if (characterObject.IsTemplate || characterObject.IsChildTemplate)
                    {
                        continue;
                    }
                    var culture   = characterObject.Culture;
                    var cultureId = culture?.StringId ?? "null";
                    if (!Cultures.Contains(cultureId))
                    {
                        Cultures.Add(cultureId);
                    }
                    if (!GroupsInCultures.TryGetValue(cultureId, out var groupsInCurrentCulture))
                    {
                        GroupsInCultures[cultureId] = groupsInCurrentCulture = new List <Group>();
                    }

                    var formationClass = characterObject.DefaultFormationClass;
                    var group          = groupsInCurrentCulture.Find(g => g.Info.FormationClass == formationClass) as SPGroup;
                    if (group == null)
                    {
                        var newGroup = new SPGroup(formationClass);
                        groupsInCurrentCulture.Add(newGroup);
                        groupsInCurrentCulture.Sort((lhs, rhs) => lhs.Info.FormationClass - rhs.Info.FormationClass);
                        group = newGroup;
                    }

                    var occupation = characterObject.Occupation;
                    if (!group.OccupationsInGroup.TryGetValue(occupation, out var charactersInOccupation))
                    {
                        group.OccupationsInGroup[occupation] = charactersInOccupation = new CharactersInOccupation();
                    }

                    charactersInOccupation.Characters.Add(characterObject.StringId,
                                                          new SPCharacter(characterObject, group.Info));
                }
            }
        }
Ejemplo n.º 23
0
        public IResourceCultureBuilder Culture(string cultureName)
        {
            if (string.IsNullOrEmpty(cultureName))
            {
                throw new ArgumentNullException(nameof(cultureName));
            }

            var rcb = Cultures.FirstOrDefault(res => res.CultureName == cultureName);

            if (rcb != null)
            {
                return(rcb);
            }

            rcb = new ResourceCultureBuilder(this, cultureName);
            Cultures.Add(rcb);

            return(rcb);
        }
Ejemplo n.º 24
0
        public Vic2CultureGroup(Vic2World world, PdxSublist data) : this(data.Key, world)
        {
            //World = world;
            Leader = data.GetString("leader");
            if (data.KeyValuePairs.ContainsKey("unit"))
            {
                Unit = data.GetString("unit");
            }

            data.ForEachSublist(sub =>
            {
                Cultures.Add(new Vic2Culture(world, sub.Value, this));
            });

            if (data.KeyValuePairs.ContainsKey("union"))
            {
                unionKey = data.GetString("union");
            }
        }
        public ExploratoryFixture(IEngine engine)
            : base(engine)
        {
            Cultures.Add(CultureInfo.GetCultureInfo("sv"));
            Cultures.Add(CultureInfo.GetCultureInfo("en"));

            RegisterBuilder <SiteDefinition>(s => {
                s.Name    = "Lorem";
                s.SiteUrl = new Uri("http://*****:*****@supersecretpassword.io",
                "WebAdmins", "Administrators"
                );
        }
Ejemplo n.º 26
0
        public MainWindowViewModel(Window w)
        {
            mainWindow = w;

            DispatcherTimer timer = new DispatcherTimer();

            timer.Interval = TimeSpan.FromSeconds(1);
            timer.Tick    += SetTime;
            timer.Start();

            ChangeThemeCommand = new RelayCommand(ChangeTheme);

            OpenFileCommand = new RelayCommand((path) =>
            {
                FileStream fileStream = new FileStream((string)path, FileMode.Open);
                FileDialogViewModel fileDialogViewModel = (mainWindow.TryFindResource("fileDialog") as FileDialogViewModel);
                TextRange range = new TextRange(fileDialogViewModel.TextEditor.Document.ContentStart, fileDialogViewModel.TextEditor.Document.ContentEnd);
                range.Load(fileStream, DataFormats.Rtf);
                fileStream.Close();
                mainWindow.Title = (string)path;
            });

            ChangeCultureCommand = new RelayCommand(ChangeCulture);

            MenuItem themeItemLight = new MenuItem()
            {
                Header    = Resources.Localization.LightThemeMenuItem,
                Tag       = "-light",
                IsChecked = true
            };
            MenuItem themeItemDark = new MenuItem()
            {
                Tag    = "-dark",
                Header = Resources.Localization.DarkThemeMenuItem
            };
            MenuItem themeItemBlue = new MenuItem()
            {
                Tag    = "-blue",
                Header = Resources.Localization.BlueThemeMenuItem,
            };

            ThemeMenuItems.Add(themeItemLight);
            ThemeMenuItems.Add(themeItemDark);
            ThemeMenuItems.Add(themeItemBlue);
            foreach (MenuItem item in ThemeMenuItems)
            {
                item.IsCheckable      = true;
                item.Command          = ChangeThemeCommand;
                item.CommandParameter = item;
            }

            MenuItem ruCulture = new MenuItem()
            {
                Header = Resources.Localization.LangRuMenuItem,
                Tag    = "ru-RU",
                //IsChecked = true
            };
            MenuItem enCulture = new MenuItem()
            {
                Header = Resources.Localization.LangEnMenuItem,
                Tag    = "en-EN"
            };

            Cultures.Add(ruCulture);
            Cultures.Add(enCulture);
            foreach (MenuItem item in Cultures)
            {
                item.IsCheckable      = true;
                item.Command          = ChangeCultureCommand;
                item.CommandParameter = item;
                if ((string)item.Tag == Thread.CurrentThread.CurrentCulture.Name)
                {
                    item.IsChecked = true;
                }
            }

            LoadRecentFilePaths();
        }
Ejemplo n.º 27
0
 public void AddCultureFile(CultureInfo culture, string filePath)
 {
     Cultures.Add(culture);
     CultureFiles[culture] = filePath;
 }