private void Init(string theme) { theme = theme.ToLower(); //ищем полное совпадение ThemeCultureInfo selectedCulture = Cultures.FirstOrDefault(x => x.Name.ToLower() == theme); if (selectedCulture != null) { CurrentCulture = selectedCulture; return; } //если не находим полное совпадение культуры, то ищем совпадение с более общей культурой if (theme.IndexOf('-') != -1) { theme = theme.Remove(theme.IndexOf('-')); } selectedCulture = Cultures.FirstOrDefault(x => x.Name.ToLower() == theme); if (selectedCulture != null) { CurrentCulture = selectedCulture; } else { //если не нашли ни одного совпадение - назначаем дефолтную культуру(первую) CurrentCulture = Cultures.First(); } }
public Eu4Culture AddCulture(PdxSublist data, Eu4WorldBase world) { var culture = new Eu4Culture(data, this, world); Cultures.Add(culture); return(culture); }
public override void OnInspectorGUI() { var cultures = Cultures.GetCultures().ToList(); var cultureDisplayName = cultures.Where(c => c.Name == languageNameProperty.stringValue) .Select(c => c.DisplayName) .DefaultIfEmpty("Development") .FirstOrDefault(); EditorGUILayout.LabelField("Language", cultureDisplayName); EditorGUILayout.Space(); if (serializedObject.isEditingMultipleObjects) { EditorGUILayout.HelpBox($"Select a single {nameof(Localization).ToLowerInvariant()} to view its contents.", MessageType.None); } else { var target = this.target as Localization; DrawLocalizationContents(target); } if (serializedObject.hasModifiedProperties) { serializedObject.ApplyModifiedProperties(); } }
public override void ExpandView(MixCmsContext _context = null, IDbContextTransaction _transaction = null) { Cultures = LoadCultures(Specificulture, _context, _transaction); Cultures.ForEach(c => c.IsSupported = _context.MixModule.Any(m => m.Id == Id && m.Specificulture == c.Specificulture)); Columns = new List <ModuleFieldViewModel>(); JArray arrField = !string.IsNullOrEmpty(Fields) ? JArray.Parse(Fields) : new JArray(); foreach (var field in arrField) { ModuleFieldViewModel thisField = new ModuleFieldViewModel() { Name = CommonHelper.ParseJsonPropertyName(field["name"].ToString()), Title = field["title"]?.ToString(), Options = field["options"] != null ? field["options"].Value <JArray>() : new JArray(), Priority = field["priority"] != null ? field["priority"].Value <int>() : 0, DataType = (MixDataType)(int)field["dataType"], Width = field["width"] != null ? field["width"].Value <int>() : 3, IsUnique = field["isUnique"] != null ? field["isUnique"].Value <bool>() : true, IsRequired = field["isRequired"] != null ? field["isRequired"].Value <bool>() : true, IsDisplay = field["isDisplay"] != null ? field["isDisplay"].Value <bool>() : true, IsSelect = field["isSelect"] != null ? field["isSelect"].Value <bool>() : false, IsGroupBy = field["isGroupBy"] != null ? field["isGroupBy"].Value <bool>() : false, }; Columns.Add(thisField); } this.Templates = this.Templates ?? MixTemplates.UpdateViewModel.Repository.GetModelListBy( t => t.Theme.Name == ActivedTheme && t.FolderType == this.TemplateFolderType).Data; this.View = MixTemplates.UpdateViewModel.GetTemplateByPath(Template, Specificulture, MixEnums.EnumTemplateFolder.Modules, _context, _transaction); this.Template = CommonHelper.GetFullPath(new string[] { this.View?.FileFolder , this.View?.FileName }); }
public void Export(string filePath) { using (var workbook = new XLWorkbook(XLEventTracking.Disabled)) { IEnumerable <CultureInfo> cultures = null; if (Cultures != null) { cultures = Cultures.Select(vc => vc.Culture); } else { cultures = Solution.Cultures.Keys; } IEnumerable <VSProject> projects = Projects; if (Projects == null) { projects = (IEnumerable <VSProject>)Solution.Projects.Values; } foreach (var project in projects) { var data = GetData(project, cultures); if (IncludeProjectsWithoutTranslations || data.Count() > 0) { AddProject(project, workbook, cultures, data); } } workbook.SaveAs(filePath); } }
private async void RemoveLanguage(object sender, RoutedEventArgs e) { MenuItem menuItem = sender as MenuItem; if (menuItem == null) { return; } CultureItem culture = menuItem.Tag as CultureItem; if (culture == null) { return; } string message = StringUtils.String("MB_RemoveLanguage", culture.Culture.Description); MessageBoxResult mbResult = await App.MainWindow.ShowMessage(message); if (mbResult == MessageBoxResult.Yes) { App.MainWindow.Document.RemoveLanguage(culture.Culture.CultureCode); Cultures.Remove(culture); } }
static void Main(string[] args) { if (args.Length == 0) { WriteLine("Hello World!"); return; } switch (args[0]) { case "types": System.IO.File.WriteAllText("../docs/types.md", Types.Print()); break; case "repl": ExecuteCSharpRepl(); break; case "roslyn": ExecuteCSharp(); break; case "cultures": System.IO.File.WriteAllText("../docs/cultures.md", Cultures.Print()); break; case "date-format": System.IO.File.WriteAllText("../docs/date-format.md", DateFormat.Print()); break; case "inr": WriteLine(Cultures.FormatToIndianCurrency(29531.96M)); WriteLine(Cultures.FormatToIndianCurrency(446517.7099M)); break; case "xml-writer": FileSystem.CreateCSProjXmlFile(); break; case "stream-writer": FileSystem.WriteUsingStreamWriter(); break; case "file-stream": FileSystem.WriteUsingFileStream(); break; case "stream-reader": WriteLine(FileSystem.ReadUsingStreamReader("Program.cs")); break; case "file-store-demo": FileStoreDemo(); break; default: WriteLine("Bye"); break; } }
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; } }
static void Main(string[] args) { XmlConfigurator.Configure(); var cultures = new Cultures(); IResourceQuerier resourceQuerier = new ResourceQuerier( typeof(BWF.Globalisation.Resources).Assembly); var globalisationProvider = new GlobalisationProvider(resourceQuerier, cultures.LanguageCultures, cultures.FormattingCultures); var hostSettings = new Settings(); var dataserviceHostSettings = new DataServiceHostSettings( hostSettings.ServiceName, hostSettings.ServiceDisplayName, hostSettings.ServiceDescription, hostSettings.HostUrl, null, //let discovery handle this globalisationProvider); var host = new DataServiceHost(dataserviceHostSettings); host.Start(); }
/// <summary> /// Returns a valid culture name based on "name" parameter. If "name" is not valid, it returns the default culture "en-US" /// </summary> /// <param name="name" />Culture's name (e.g. en-US)</param> public static string GetImplementedCulture(string name) { Cultures = Cultures == null ? ValidCultures : Cultures; // make sure it's not null if (string.IsNullOrEmpty(name)) { return(GetDefaultCulture); // return Default culture } // make sure it is a valid culture first if (ValidCultures.Where(c => c.Equals(name, StringComparison.Ordinal)).Count() == 0) // StringComparison.InvariantCultureIgnoreCase)).Count() == 0) { return(GetDefaultCulture); // return Default culture if it is invalid } // if it is implemented, accept it if (Cultures.Where(c => c.Equals(name, StringComparison.Ordinal)).Count() > 0) { return(name); // accept it } // Find a close match. For example, if you have "en-US" defined and the user requests "en-GB", // the function will return closes match that is "en-US" because at least the language is the same (ie English) var n = GetNeutralCulture(name); foreach (var c in Cultures) { if (c.StartsWith(n, StringComparison.Ordinal)) { return(c); } } // else // It is not implemented return(GetDefaultCulture); // return Default culture as no match found }
private void LoadTextLanguagesIntoDropdowns() { if (textLanguagesDropdown || textLanguagesTMPDropdown) { var textLanguageList = new List <string>(); if (ProjectSettings.TextProjectLanguages.Count > 0) { foreach (var language in ProjectSettings.TextProjectLanguages) { var culture = Cultures.GetCulture(language); textLanguageList.Add(culture.NativeName); } } else { // If no project settings have been defined, show all available cultures foreach (var culture in Cultures.GetCultures()) { textLanguageList.Add(culture.NativeName); } } PopulateLanguagesListToDropdown(textLanguageList, textLanguagesTMPDropdown, textLanguagesDropdown, ref textLanguageSelected, PreferencesSetting.TextLanguage); } }
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); }
public static string GetString <T>(string name, Cultures culture) { Type resourcesType = typeof(T); var manager = new ResourceManager(resourcesType); return(manager.GetString(name, new System.Globalization.CultureInfo(culture.ToString()))); }
internal void LanguageAdded([NotNull] CultureKey cultureKey) { if (!Cultures.Contains(cultureKey)) { Cultures.Add(cultureKey); } }
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)); } } }
/// <summary> /// Changes the culture. /// </summary> /// <param name="cultureId">The culture ID.</param> public static void ChangeCulture(string cultureId) { Culture newCulture = Cultures.FirstOrDefault(c => c.Identifier.ToUpper(CultureInfo.InvariantCulture) == cultureId.ToUpper(CultureInfo.InvariantCulture)); Debug.Assert(newCulture != null, "new culture is null"); if (newCulture != CurrentCulture) { if (CurrentCulture != null) { CurrentCulture.UpdateSelected(false); } Thread.CurrentThread.CurrentUICulture = newCulture.Info; newCulture.UpdateSelected(true); CurrentCulture = newCulture; foreach (var culture in Cultures) { culture.UpdateName(); } if (CultureChanged != null) { CultureChanged(null, new EventArgs()); } } }
private bool InternalLoad([NotNull][ItemNotNull] IEnumerable <IGrouping <string, ProjectFile> > resourceFilesByDirectory) { Contract.Requires(resourceFilesByDirectory != null); if (!LoadEntities(resourceFilesByDirectory)) { return(false); // nothing has changed, no need to continue } if (!string.IsNullOrEmpty(_snapshot)) { ResourceEntities.LoadSnapshot(_snapshot); } var cultureKeys = ResourceEntities .SelectMany(entity => entity.Languages) .Select(lang => lang.CultureKey) .Distinct() .OrderBy(item => item.Culture?.DisplayName) .ToArray(); Cultures.SynchronizeWith(cultureKeys); OnLoaded(); return(true); }
public override void ExpandView(MixCmsContext _context = null, IDbContextTransaction _transaction = null) { Cultures = MixModules.Helper.LoadCultures(Id, Specificulture, _context, _transaction); Cultures.ForEach(c => c.IsSupported = _context.MixModule.Any(m => m.Id == Id && m.Specificulture == c.Specificulture)); Columns = new List <ModuleFieldViewModel>(); JArray arrField = !string.IsNullOrEmpty(Fields) ? JArray.Parse(Fields) : new JArray(); foreach (var field in arrField) { ModuleFieldViewModel thisField = new ModuleFieldViewModel() { Name = CommonHelper.ParseJsonPropertyName(field["name"].ToString()), Title = field["title"]?.ToString(), Options = field["options"] != null ? field["options"].Value <JArray>() : new JArray(), Priority = field["priority"] != null ? field["priority"].Value <int>() : 0, DataType = (MixDataType)(int)field["dataType"], Width = field["width"] != null ? field["width"].Value <int>() : 3, IsUnique = field["isUnique"] != null ? field["isUnique"].Value <bool>() : true, IsRequired = field["isRequired"] != null ? field["isRequired"].Value <bool>() : true, IsDisplay = field["isDisplay"] != null ? field["isDisplay"].Value <bool>() : true, IsSelect = field["isSelect"] != null ? field["isSelect"].Value <bool>() : false, IsGroupBy = field["isGroupBy"] != null ? field["isGroupBy"].Value <bool>() : false, }; Columns.Add(thisField); } // Load Attributes LoadAttributes(_context, _transaction); this.Templates = MixTemplates.UpdateViewModel.Repository.GetModelListBy( t => t.Theme.Id == ActivedTheme && t.FolderType == this.TemplateFolderType, _context, _transaction).Data; var templateName = Template?.Substring(Template.LastIndexOf('/') + 1) ?? MixConstants.DefaultTemplate.Module; this.View = Templates.FirstOrDefault(t => !string.IsNullOrEmpty(templateName) && templateName.Equals($"{t.FileName}{t.Extension}")); if (this.View == null) { this.View = Templates.FirstOrDefault(t => MixConstants.DefaultTemplate.Module.Equals($"{t.FileName}{t.Extension}")); } this.Template = $"{View?.FileFolder}/{View?.FileName}{View.Extension}"; this.Forms = MixTemplates.UpdateViewModel.Repository.GetModelListBy( t => t.Theme.Id == ActivedTheme && t.FolderType == this.FormFolderType).Data; this.FormView = MixTemplates.UpdateViewModel.GetTemplateByPath(FormTemplate, Specificulture, MixEnums.EnumTemplateFolder.Forms, _context, _transaction); this.FormTemplate = $"{FormView?.FileFolder}/{FormView?.FileName}{View.Extension}"; this.Edms = MixTemplates.UpdateViewModel.Repository.GetModelListBy( t => t.Theme.Id == ActivedTheme && t.FolderType == this.EdmFolderType).Data; this.EdmView = MixTemplates.UpdateViewModel.GetTemplateByPath(EdmTemplate, Specificulture, MixEnums.EnumTemplateFolder.Edms, _context, _transaction); this.EdmTemplate = $"{EdmView?.FileFolder}/{EdmView?.FileName}{View.Extension}"; // TODO: Verified why use below code //if (SetAttributeId.HasValue) //{ // AttributeSet = MixAttributeSets.UpdateViewModel.Repository.GetSingleModel(s => s.Id == SetAttributeId.Value).Data; //} //else //{ // AttributeSet = new MixAttributeSets.UpdateViewModel(); //} }
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); } }
public KeyValuePair <string, Culture> GetRandomCulture(Random rand) { if (m_useCustomCulture && rand.Next(2) == 0) { return(m_customCultures.RandomItem(rand)); } return(Cultures.RandomItem(rand)); }
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); } }
internal void LanguageAdded([NotNull] CultureKey cultureKey) { Contract.Requires(cultureKey != null); if (!Cultures.Contains(cultureKey)) { Cultures.Add(cultureKey); } }
/// <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); }
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 static void Main() { Cultures.SetAllCulture(); Application.EnableVisualStyles(); #if NET5_0 || NET6_0 Application.SetHighDpiMode(HighDpiMode.SystemAware); #endif Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MAIN()); }
public ActionResult SetFacility(long organizationId) { SetOrganizationInRootObject(organizationId); string returnUrl = Session["ReturnUrl"].ToString(); string language = Cultures.GetSiteLanguage(Request); string url = "/" + language + returnUrl; CleanSession(); return(Redirect(url)); }
private void Campaign_SelectedIndexChanged(object sender, EventArgs e) { Cultures.Clear(); var list = Culture.GetCulturesForCampaign(GenerationConfiguration.Campaign); foreach (var item in list) { Cultures.Add(item); } }
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 }); } }
/// <summary> /// Tries to get the culture from two letter iso code if not found default will returned. /// </summary> /// <param name="twoLetterISOLanguageName">Name of the two letter iso language.</param> /// <returns></returns> internal static CultureInfo TryGetCultureFromTwoLetterIsoCode(string twoLetterISOLanguageName) { if (IsValidLanguage(twoLetterISOLanguageName)) { return(Cultures.First(o => o.Name.StartsWith(twoLetterISOLanguageName))); } else { return(DefaultCulture); } }
public override MixUrlAlias ParseModel(MixCmsContext _context = null, IDbContextTransaction _transaction = null) { if (Id == 0) { Id = UpdateViewModel.Repository.Max(c => c.Id).Data + 1; CreatedDateTime = DateTime.UtcNow; Cultures = Cultures ?? LoadCultures(Specificulture, _context, _transaction); Cultures.ForEach(c => c.IsSupported = true); } return(base.ParseModel(_context, _transaction)); }
private void BuildUiCulturesAndProductCultures() { var cultures = new Cultures(); foreach (var cultureName in cultures.SupportedUiCultures) { var uiCulture = GetUiCultureFromCultureName(cultureName); UiCultures.Add(uiCulture); } foreach (var cultureName in cultures.SupportedProductCultures) { var productCulture = GetProductCultureFromCultureName(cultureName); ProductCultures.Add(productCulture); } }
private string FindCultureNameByProductCulture(string productCulture) { var index = ProductCultures.IndexOf(productCulture); var cultures = new Cultures(); return cultures.SupportedProductCultures[index]; }
private string FindCultureNameByUiCulture(string uiCulture) { var index = UiCultures.IndexOf(uiCulture); var cultures = new Cultures(); return cultures.SupportedUiCultures[index]; }
public static void InitializeResourceManager(Cultures culture) { ResourceManager = new ResourceManager(ResourceFiles[Culture], Assembly.GetExecutingAssembly()); }