/// <summary>Gets the cultures.</summary> /// <param name="cultureTypes">The culture types.</param> /// <returns></returns> public static IReadOnlyCollection<CultureInfo> GetCultures(CultureTypes cultureTypes) { var cultures = new List<CultureInfo>(); EnumLocalesProcExDelegate enumCallback = (locale, flags, lParam) => { try { cultures.Add(new CultureInfo(locale)); } catch (CultureNotFoundException) { // This culture is not supported by .NET (not happened so far) // Must be ignored. } return true; }; if (EnumSystemLocalesEx(enumCallback, (LocaleType)cultureTypes, 0, (IntPtr)0) == false) { int errorCode = Marshal.GetLastWin32Error(); throw new LocalesRetrievalException("Win32 error " + errorCode + " while trying to get the Windows locales"); } // Add the two neutral cultures that Windows misses // (CultureInfo.GetCultures adds them also): if (cultureTypes == CultureTypes.NeutralCultures || cultureTypes == CultureTypes.AllCultures) { //cultures.Add(new CultureInfo("zh-CHS")); //cultures.Add(new CultureInfo("zh-CHT")); } return new ReadOnlyCollection<CultureInfo>(cultures); }
public LanguagesTemplateDropDown(ListItemType type, string colName, CultureTypes types) { this.templateType = type; // this.columnName = colName; this.cultureTypes = types; }
static List <LECulture> GetAll(CultureTypes type) { List <LECulture> cultures = new List <LECulture>(); CultureInfo[] all = CultureInfo.GetCultures(type); foreach (CultureInfo cul in all) { cultures.Add(new LEBuiltInCulture(cul)); } return(cultures); }
public static CultureInfo[] GetCultures(CultureTypes types) { DirectoryInfo cultureDir = new DirectoryInfo(Environment.CultureDirectory); List<CultureInfo> ret = new List<CultureInfo>(); foreach (FileInfo fi in cultureDir.GetFiles()) { CultureInfo ci = CultureInfo.GetCultureInfo(fi.Name); if ((ci.cultureTypes & types) > 0) { ret.Add(ci); } } return ret.ToArray(); }
private static CultureInfo[] IcuEnumCultures(CultureTypes types) { Debug.Assert(!GlobalizationMode.Invariant); Debug.Assert(!GlobalizationMode.UseNls); if ((types & (CultureTypes.NeutralCultures | CultureTypes.SpecificCultures)) == 0) { return(Array.Empty <CultureInfo>()); } int bufferLength = Interop.Globalization.GetLocales(null, 0); if (bufferLength <= 0) { return(Array.Empty <CultureInfo>()); } char [] chars = new char[bufferLength]; bufferLength = Interop.Globalization.GetLocales(chars, bufferLength); if (bufferLength <= 0) { return(Array.Empty <CultureInfo>()); } bool enumNeutrals = (types & CultureTypes.NeutralCultures) != 0; bool enumSpecificss = (types & CultureTypes.SpecificCultures) != 0; List <CultureInfo> list = new List <CultureInfo>(); if (enumNeutrals) { list.Add(CultureInfo.InvariantCulture); } int index = 0; while (index < bufferLength) { int length = (int)chars[index++]; if (index + length <= bufferLength) { CultureInfo ci = CultureInfo.GetCultureInfo(new string(chars, index, length)); if ((enumNeutrals && ci.IsNeutralCulture) || (enumSpecificss && !ci.IsNeutralCulture)) { list.Add(ci); } } index += length; } return(list.ToArray()); }
/** * Get all cultures of a particular type * Used to load the Comboboxes */ public string[] GetCultures(CultureTypes type) { CultureInfo[] cis = CultureInfo.GetCultures(type); string[] names = new string[cis.Length]; for (int i = 0; i < cis.Length; i++) { names[i] = cis[i].Name; } return(names); }
/// <summary> /// GetCultures gets an array of Culture objects for the given culture types /// </summary> /// <param name="cultureTypes">The CultureTypes to get the cultures for</param> /// <returns>An array of Culture objects</returns> public static Culture[] GetCultures(CultureTypes cultureTypes) { if (cultureTypes == CultureTypes.NeutralCultures) { return(GetCultures(true)); } else if (cultureTypes == CultureTypes.SpecificCultures) { return(GetCultures(false)); } return(NCldr.Cultures); }
/// <summary>Gets the list of supported cultures filtered by the specified <see cref="T:System.Globalization.CultureTypes" /> parameter.</summary> /// <returns>An array of type <see cref="T:System.Globalization.CultureInfo" /> that contains the cultures specified by the <paramref name="types" /> parameter. The array of cultures is unsorted.</returns> /// <param name="types">A bitwise combination of <see cref="T:System.Globalization.CultureTypes" /> values that filter the cultures to retrieve. </param> /// <exception cref="T:System.ArgumentOutOfRangeException"> /// <paramref name="types" /> specifies an invalid combination of <see cref="T:System.Globalization.CultureTypes" /> values.</exception> /// <PermissionSet> /// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode" /> /// </PermissionSet> public static CultureInfo[] GetCultures(CultureTypes types) { bool flag = (types & CultureTypes.NeutralCultures) != (CultureTypes)0; bool specific = (types & CultureTypes.SpecificCultures) != (CultureTypes)0; bool installed = (types & CultureTypes.InstalledWin32Cultures) != (CultureTypes)0; CultureInfo[] array = CultureInfo.internal_get_cultures(flag, specific, installed); if (flag && array.Length > 0 && array[0] == null) { array[0] = (CultureInfo)CultureInfo.InvariantCulture.Clone(); } return(array); }
internal static CultureInfo[] GetCultures(CultureTypes types) { bool neutral = ((types & CultureTypes.NeutralCultures) != 0); bool specific = ((types & CultureTypes.SpecificCultures) != 0); bool installed = ((types & CultureTypes.InstalledWin32Cultures) != 0); // TODO int[] ids = get_lcids(); if (ids == null) { return(new CultureInfo[0]); } int n = ids.Length; if (n <= 0) { return(new CultureInfo[0]); } CultureInfo[] infos = new CultureInfo[n]; int k = 0; for (int i = 0; i < n; ++i) { CultureInfo info = new CultureInfo(ids[i]); #if ONLY_1_1 info.m_useUserOverride = true; #endif if (neutral && !info.IsNeutralCulture) { continue; } if (specific && !info.IsSpecific) { continue; } if (installed && !info.IsInstalled) { continue; } infos[k++] = info; } CultureInfo[] result = new CultureInfo[k]; for (int i = 0; i < k; ++i) { result[i] = infos[i]; } return(infos); }
private static CultureInfo[] EnumCultures(CultureTypes types) { uint flags = 0; #pragma warning disable 618 if ((types & (CultureTypes.FrameworkCultures | CultureTypes.InstalledWin32Cultures | CultureTypes.ReplacementCultures)) != 0) { flags |= Interop.Kernel32.LOCALE_NEUTRALDATA | Interop.Kernel32.LOCALE_SPECIFICDATA; } #pragma warning restore 618 if ((types & CultureTypes.NeutralCultures) != 0) { flags |= Interop.Kernel32.LOCALE_NEUTRALDATA; } if ((types & CultureTypes.SpecificCultures) != 0) { flags |= Interop.Kernel32.LOCALE_SPECIFICDATA; } if ((types & CultureTypes.UserCustomCulture) != 0) { flags |= Interop.Kernel32.LOCALE_SUPPLEMENTAL; } if ((types & CultureTypes.ReplacementCultures) != 0) { flags |= Interop.Kernel32.LOCALE_SUPPLEMENTAL; } EnumData context = new EnumData(); context.strings = new LowLevelList <string>(); GCHandle contextHandle = GCHandle.Alloc(context); try { Interop.Kernel32.EnumSystemLocalesEx(EnumAllSystemLocalesProc, flags, (IntPtr)contextHandle, IntPtr.Zero); } finally { contextHandle.Free(); } CultureInfo[] cultures = new CultureInfo[context.strings.Count]; for (int i = 0; i < cultures.Length; i++) { cultures[i] = new CultureInfo(context.strings[i]); } return(cultures); }
public static IReadOnlyCollection <CultureInfo> GetCultures( CultureTypes cultureTypes) { List <CultureInfo> cultures = new List <CultureInfo>(); EnumLocalesProcExDelegate enumCallback = (locale, flags, lParam) => { try { cultures.Add(new CultureInfo(locale)); } catch (CultureNotFoundException) { // This culture is not supported by .NET (not happened so far) // Must be ignored. } return(true); }; if (EnumSystemLocalesEx(enumCallback, (LocaleType)cultureTypes, 0, (IntPtr)0) == false) { int errorCode = Marshal.GetLastWin32Error(); throw new LocalesRetrievalException("Win32 error " + errorCode + " while trying to get the Windows locales"); } // Add the two neutral cultures that Windows misses // (CultureInfo.GetCultures adds them also): if (cultureTypes == CultureTypes.NeutralCultures || cultureTypes == CultureTypes.AllCultures) { try { cultures.Add(new CultureInfo("zh-CHT")); } catch (Exception) { } try { cultures.Add(new CultureInfo("zh-CHS")); } catch (Exception) { } } return(new ReadOnlyCollection <CultureInfo>(cultures)); }
//private DateTimeFormatInfo mDateTimeFormat; internal CultureInfo() { mName = "en-US"; mLCID = 0x7f; mParentName = mDisplayName = mEnglishName = mNativeName = "English"; mTwoLetterISOLanguageName = "en"; mThreeLetterISOLanguageName = "eng"; mThreeLetterWindowsLanguageName = "ENU"; mCultureTypes = Globalization.CultureTypes.AllCultures; mIETFLanguageTag = "en"; mIsNeutralCulture = true; mNumberFormatInfo = NumberFormatInfo.InvariantInfo; mTextInfo = TextInfo.InvariantInfo; //mDateTimeFormat = DateTimeFormatInfo.InvariantInfo; }
// gets culture list for the chosen culture alphabetically ordered public static List <string> GetCulturesList(CultureTypes cultureType) { List <string> cultures = new List <string>(); CultureInfo.GetCultures(cultureType).ToList().ForEach(ci => { if (!string.IsNullOrEmpty(ci.Name)) { cultures.Add(ci.Name); } }); cultures.Sort(); return(cultures); }
public static CultureInfo[] GetCultures(CultureTypes types) { DirectoryInfo cultureDir = new DirectoryInfo(Environment.CultureDirectory); List <CultureInfo> ret = new List <CultureInfo>(); foreach (FileInfo fi in cultureDir.GetFiles()) { CultureInfo ci = CultureInfo.GetCultureInfo(fi.Name); if ((ci.cultureTypes & types) > 0) { ret.Add(ci); } } return(ret.ToArray()); }
internal CultureInfo() { mName = "en-US"; mLCID = 0x7f; mParentName = mDisplayName = mEnglishName = mNativeName = "English"; mTwoLetterISOLanguageName = "en"; mThreeLetterISOLanguageName = "eng"; mThreeLetterWindowsLanguageName = "ENU"; mCultureTypes = Globalization.CultureTypes.AllCultures; mIETFLanguageTag = "en"; mIsNeutralCulture = true; mNumberFormatInfo = NumberFormatInfo.InvariantInfo; mTextInfo = TextInfo.InvariantInfo; mDateTimeFormat = DateTimeFormatInfo.InvariantInfo; }
private void OnCultureTypeMenuItem_Click(object sender, EventArgs e) { foreach (ToolStripMenuItem menuItem in _cultureTypeMenuItems) { menuItem.Checked = false; menuItem.CheckState = CheckState.Unchecked; } var senderMenuItem = (ToolStripMenuItem)sender; senderMenuItem.Checked = true; senderMenuItem.CheckState = CheckState.Checked; _currentCultureType = (CultureTypes)senderMenuItem.Tag; DisplayCultures(); }
private static List <CountryInfo> GetAllCountries(CultureTypes cultureTypes) { var Countries = new List <CountryInfo>(); foreach (var culture in CultureInfo.GetCultures(cultureTypes)) { if (culture.LCID != 127) { Countries.Add(new CountryInfo { Culture = culture, Region = new RegionInfo(culture.TextInfo.CultureName) }); } } return(Countries); }
public static CultureInfo[] GetCultures(CultureTypes types) { bool neutral = ((types & CultureTypes.NeutralCultures) != 0); bool specific = ((types & CultureTypes.SpecificCultures) != 0); bool installed = ((types & CultureTypes.InstalledWin32Cultures) != 0); // TODO CultureInfo [] infos = internal_get_cultures(neutral, specific, installed); // The runtime returns a NULL in the first position of the array when // 'neutral' is true. We fill it in with a clone of InvariantCulture // since it must not be read-only if (neutral && infos.Length > 0 && infos [0] == null) { infos [0] = (CultureInfo)InvariantCulture.Clone(); } return(infos); }
public void LoadCultures(CultureTypes cultureTypes) { // "EnglishName" is chosen over "DisplayName" here because "DisplayName" returns "NativeName" for // custom cultures but the correct display name for non-custom cultures and hence the list appears // schizophrenic if it includes both custom and non-custom cultures. lbxCultures.Items.Clear(); foreach (CultureInfo cultureInfo in CultureInfo.GetCultures(cultureTypes).OrderBy(ci => ci.EnglishName)) { lbxCultures.Items.Add(cultureInfo); } lbxCultures.DisplayMember = "EnglishName"; if (lbxCultures.Items.Count > 0) { lbxCultures.SelectedIndex = 0; } }
public async Task <IActionResult> Index( [FromQuery] int p = 1, [FromQuery] int s = 10, [FromQuery] string q = "", [FromQuery] CultureTypes ct = CultureTypes.AllCultures) { var searchExp = new List <Expression <Func <CultureItem, bool> > >() { }; // If the search text is not empty, then apply where clause if (!string.IsNullOrWhiteSpace(q)) { searchExp.Add(x => x.EnglishName.Contains(q) || x.NativeName.Contains(q) || x.Name.Contains(q)); } //if search filter for culture type is specified, then add where clause if (ct != CultureTypes.AllCultures) { searchExp.Add(x => x.CultureTypes.HasFlag(ct)); } CulturesPagingModel model = new() { P = p, S = s }; //count records that returns after the search model.TotalRecords = await _context.Set <CultureItem>() .AsNoTracking() .WhereList(searchExp) .CountAsync(); model.CulturesList = await _context.Set <CultureItem>() .AsNoTracking() .WhereList(searchExp) .OrderBy(x => x.EnglishName) .Skip((p - 1) * s) .Take(s) .ToListAsync(); return(View(model)); }
private void CopyFrom(CultureInfo ci) { this.name = ci.name; this.lcid = ci.lcid; this.parent = ci.parent; this.englishName = ci.englishName; this.nativeName = ci.nativeName; this.displayName = ci.displayName; this.twoLetterISOLanguageName = ci.twoLetterISOLanguageName; this.threeLetterISOLanguageName = ci.threeLetterISOLanguageName; this.threeLetterWindowsLanguageName = ci.threeLetterWindowsLanguageName; this.cultureTypes = ci.cultureTypes; this.ietfLanguageTag = ci.ietfLanguageTag; this.isNeutralCulture = ci.isNeutralCulture; this.textInfo = ci.textInfo; this.numberFormatInfo = ci.numberFormatInfo; this.dateTimeFormat = ci.dateTimeFormat; }
// Get the list of all cultures supported by this system. public static CultureInfo[] GetCultures(CultureTypes types) { Object obj = Encoding.InvokeI18N("GetCultures", types); if (obj != null) { return((CultureInfo[])obj); } else if ((types & CultureTypes.NeutralCultures) != 0) { CultureInfo[] cultures = new CultureInfo [1]; cultures[0] = InvariantCulture; return(cultures); } else { return(new CultureInfo [0]); } }
private ToolStripMenuItem AddViewMenuItem(string text, bool isChecked, CultureTypes cultureType) { var menuItem = new ToolStripMenuItem { Text = text }; if (isChecked) { _currentCultureType = cultureType; menuItem.Checked = true; menuItem.CheckState = CheckState.Checked; } menuItem.Tag = cultureType; menuItem.Click += OnCultureTypeMenuItem_Click; menuItemView.DropDownItems.Add(menuItem); return(menuItem); }
// Get an array of all cultures in the system. public CultureInfo[] GetCultures(CultureTypes types) { // Count the number of culture handlers in the system. int count = 0; if ((types & CultureTypes.NeutralCultures) != 0) { ++count; } IDictionaryEnumerator e = handlers.GetEnumerator(); String name; while (e.MoveNext()) { name = (String)(e.Key); if (CultureMatch(name, types)) { ++count; } } // Build the list of cultures. CultureInfo[] cultures = new CultureInfo [count]; count = 0; if ((types & CultureTypes.NeutralCultures) != 0) { cultures[count++] = CultureInfo.InvariantCulture; } e.Reset(); while (e.MoveNext()) { name = (String)(e.Key); if (CultureMatch(name, types)) { cultures[count++] = new CultureInfo(FromHex(name, 3)); } } // Return the culture list to the caller. return(cultures); }
/// <summary> /// Gets the list of supported cultures in the form of L10NCultureInfo objects. /// There is some danger in calling this repeatedly in that it creates new objects, /// whereas the CultureInfo version appears to return cached objects. /// </summary> public static IEnumerable <L10NCultureInfo> GetCultures(CultureTypes types) { var list = CultureInfo.GetCultures(types).Select(culture => new L10NCultureInfo(culture.Name)).ToList(); if ((types & CultureTypes.NeutralCultures) == CultureTypes.NeutralCultures) { bool havePbu = false; bool havePrs = false; bool haveTpi = false; foreach (var ci in list) { if (ci.Name == "pbu") { havePbu = true; } else if (ci.Name == "prs") { havePrs = true; } else if (ci.Name == "tpi") { haveTpi = true; } } if (!havePbu) { list.Add(GetCultureInfo("pbu")); } if (!havePrs) { list.Add(GetCultureInfo("prs")); } if (!haveTpi) { list.Add(GetCultureInfo("tpi")); } } return(list); }
private void ConstructFromFile(string name) { string fileName = Environment.CultureDirectory + Path.DirectorySeparatorStr + name; try { using (StreamReader s = File.OpenText(fileName)) { this.name = s.ReadLine(); this.lcid = int.Parse(s.ReadLine().Substring(2), NumberStyles.HexNumber); this.parentName = s.ReadLine(); this.englishName = s.ReadLine(); this.nativeName = s.ReadLine(); this.displayName = s.ReadLine(); this.twoLetterISOLanguageName = s.ReadLine(); this.threeLetterISOLanguageName = s.ReadLine(); this.threeLetterWindowsLanguageName = s.ReadLine(); string calendarName = s.ReadLine(); // Calendar s.ReadLine(); // Optional calendars this.cultureTypes = (CultureTypes)int.Parse(s.ReadLine()); this.ietfLanguageTag = s.ReadLine(); this.isNeutralCulture = bool.Parse(s.ReadLine()); this.textInfo = new TextInfo(this, s); if (!this.isNeutralCulture) { this.numberFormatInfo = new NumberFormatInfo(s); this.dateTimeFormat = new DateTimeFormatInfo(s, calendarName); } else { this.numberFormatInfo = null; this.dateTimeFormat = null; } } } catch (FileNotFoundException) { throw new ArgumentException(string.Format("{0} is not a valid culture", name)); } lock (shareByName) { shareByName.Add(name.ToLowerInvariant(), this); } }
public static CultureInfo[] GetCultures(CultureTypes types) { ArrayList listCultures = new ArrayList(); //Look for all assemblies/satellite assemblies Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); for (int iAssembly = 0; iAssembly < assemblies.Length; iAssembly++) { Assembly assembly = assemblies[iAssembly]; string mscorlib = "mscorlib"; string fullName = assembly.FullName; // consider adding startswith ? if ((mscorlib.Length <= fullName.Length) && (fullName.Substring(0, mscorlib.Length) == mscorlib)) { string[] resources = assembly.GetManifestResourceNames(); for (int iResource = 0; iResource < resources.Length; iResource++) { string resource = resources[iResource]; string ciResource = c_ResourceBase; if (ciResource.Length < resource.Length && resource.Substring(0, ciResource.Length) == ciResource) { //System.Globalization.Resources.CultureInfo.<culture>.tinyresources string cultureName = resource.Substring(ciResource.Length, resource.Length - ciResource.Length - System.Resources.ResourceManager.s_fileExtension.Length); // remove the leading "." if (cultureName != "") { cultureName = cultureName.Substring(1, cultureName.Length - 1); } // if GetManifestResourceNames() changes, we need to change this code to ensure the index is the same. listCultures.Add(new CultureInfo(new ResourceManager(c_ResourceBase, cultureName, iResource, typeof(CultureInfo).Assembly, assembly))); } } } } return((CultureInfo[])listCultures.ToArray(typeof(CultureInfo))); }
private void PrintCultures() { // Create a table of most culture types. CultureTypes[] mostCultureTypes = new CultureTypes[] { CultureTypes.NeutralCultures, CultureTypes.SpecificCultures, CultureTypes.InstalledWin32Cultures, CultureTypes.UserCustomCulture, CultureTypes.ReplacementCultures, CultureTypes.FrameworkCultures, CultureTypes.WindowsOnlyCultures, CultureTypes.AllCultures, }; CultureInfo[] allCultures; CultureTypes combo; // Get and enumerate all cultures. allCultures = CultureInfo.GetCultures(CultureTypes.AllCultures); foreach (CultureInfo ci in allCultures) { // Display the name of each culture. Console.WriteLine("Culture: {0}", ci.Name); // Get the culture types of each culture. combo = ci.CultureTypes; // Display the name of each culture type flag that is set. Console.Write(" "); foreach (CultureTypes ct in mostCultureTypes) { if (0 != (ct & combo)) { Console.Write("{0} ", ct); } } Console.WriteLine(); } }
public static CultureInfo[] GetCultures(CultureTypes types) { bool neutral = ((types & CultureTypes.NeutralCultures) != 0); bool specific = ((types & CultureTypes.SpecificCultures) != 0); bool installed = ((types & CultureTypes.InstalledWin32Cultures) != 0); // TODO CultureInfo [] infos = internal_get_cultures(neutral, specific, installed); // The runtime returns a NULL in the first position of the array when // 'neutral' is true. We fill it in with a clone of InvariantCulture // since it must not be read-only if (neutral && infos.Length > 0 && infos [0] == null) { infos [0] = (CultureInfo)InvariantCulture.Clone(); } for (int i = 1; i < infos.Length; ++i) { var ci = infos [i]; infos [i].m_cultureData = CultureData.GetCultureData(ci.m_name, false, ci.datetime_index, ci.CalendarType, ci.iso2lang); } return(infos); }
public static void AddCultureResourcesToProject(IShortFormProject proj, string filename, string dataName, CultureTypes types = CultureTypes.AllCultures) { foreach (var culture in CultureInfo.GetCultures(types)) { proj.OtherBuildItems.Add(new BuildItem("EmbeddedResource", $"{filename}.{culture.Name}.resx") { TextContent = () => InlineData.ResxWithContents($"<data name=\"{dataName}\"><value>{culture.Name}</value></data>") }); } }
// Get the list of all cultures supported by this system. public static CultureInfo[] GetCultures(CultureTypes types) { Object obj = Encoding.InvokeI18N("GetCultures", types); if(obj != null) { return (CultureInfo[])obj; } else if((types & CultureTypes.NeutralCultures) != 0) { CultureInfo[] cultures = new CultureInfo [1]; cultures[0] = InvariantCulture; return cultures; } else { return new CultureInfo [0]; } }
public static CultureInfo[] GetCultures(CultureTypes types) { return(Safe.Run(() => CultureInfo.GetCultures(types), new CultureInfo[0])); }
public static CultureInfo[] GetCultures(CultureTypes types) { bool neutral=((types & CultureTypes.NeutralCultures)!=0); bool specific=((types & CultureTypes.SpecificCultures)!=0); bool installed=((types & CultureTypes.InstalledWin32Cultures)!=0); // TODO CultureInfo [] infos = internal_get_cultures (neutral, specific, installed); // The runtime returns a NULL in the first position of the array when // 'neutral' is true. We fill it in with a clone of InvariantCulture // since it must not be read-only int i = 0; if (neutral && infos.Length > 0 && infos [0] == null) { infos [i++] = (CultureInfo) InvariantCulture.Clone (); } for (; i < infos.Length; ++i) { var ci = infos [i]; var ti = ci.GetTextInfoData (); infos [i].m_cultureData = CultureData.GetCultureData (ci.m_name, false, ci.datetime_index, ci.CalendarType, ci.number_index, ci.iso2lang, ti.ansi, ti.oem, ti.mac, ti.ebcdic, ti.right_to_left, ((char)ti.list_sep).ToString ()); } return infos; }
/// /// <Summary> /// Gets the list of supported cultures filtered by the specified System.Globalization.CultureTypes /// parameter. /// /// Parameters: /// types: /// A bitwise combination of the enumeration values that filter the cultures /// to retrieve. /// /// </Summary> /// <Returns> /// An array that contains the cultures specified by the types parameter. The /// array of cultures is unsorted. /// </Returns> /// <Exception cref="ArgumentOutOfRangeException"> /// types specifies an invalid combination of System.Globalization.CultureTypes /// </Exception> public CultureInfo[] GetCultures(CultureTypes types) { throw new NotImplementedException(); }
public static CultureInfo[] GetCultures(CultureTypes types) {}
/// <include file='doc\CultureInfo.uex' path='docs/doc[@for="CultureInfo.GetCultures"]/*' /> public static CultureInfo[] GetCultures(CultureTypes types) { return (CultureTable.GetCultures(types)); }
public static CultureInfo[] GetCultures(CultureTypes types) { bool neutral=((types & CultureTypes.NeutralCultures)!=0); bool specific=((types & CultureTypes.SpecificCultures)!=0); bool installed=((types & CultureTypes.InstalledWin32Cultures)!=0); // TODO CultureInfo [] infos = internal_get_cultures (neutral, specific, installed); // The runtime returns a NULL in the first position of the array when // 'neutral' is true. We fill it in with a clone of InvariantCulture // since it must not be read-only if (neutral && infos.Length > 0 && infos [0] == null) { infos [0] = (CultureInfo) InvariantCulture.Clone (); } return infos; }
public static System.Globalization.CultureInfo[] GetCultures(CultureTypes types) { return default(System.Globalization.CultureInfo[]); }
public static CultureInfo[] GetCultures(CultureTypes types) { return new CultureInfo[] { sInvariantCulture }; }
internal static CultureInfo[] GetCultures(CultureTypes types) { // Disable warning 618: System.Globalization.CultureTypes.FrameworkCultures' is obsolete #pragma warning disable 618 // Validate flags if ((int)types <= 0 || ((int)types & (int)~(CultureTypes.NeutralCultures | CultureTypes.SpecificCultures | CultureTypes.InstalledWin32Cultures | CultureTypes.UserCustomCulture | CultureTypes.ReplacementCultures | CultureTypes.WindowsOnlyCultures | CultureTypes.FrameworkCultures)) != 0) { throw new ArgumentOutOfRangeException(nameof(types), SR.Format(SR.ArgumentOutOfRange_Range, CultureTypes.NeutralCultures, CultureTypes.FrameworkCultures)); } // We have deprecated CultureTypes.FrameworkCultures. // When this enum is used, we will enumerate Whidbey framework cultures (for compatibility). // // We have deprecated CultureTypes.WindowsOnlyCultures. // When this enum is used, we will return an empty array for this enum. if ((types & CultureTypes.WindowsOnlyCultures) != 0) { // Remove the enum as it is an no-op. types &= (~CultureTypes.WindowsOnlyCultures); } #pragma warning restore 618 return EnumCultures(types); }
public static CultureInfo[] GetCultures(CultureTypes types) { ArrayList listCultures = new ArrayList(); //Look for all assemblies/satellite assemblies Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); for (int iAssembly = 0; iAssembly < assemblies.Length; iAssembly++) { Assembly assembly = assemblies[iAssembly]; string mscorlib = "mscorlib"; string fullName = assembly.FullName; // consider adding startswith ? if ((mscorlib.Length <= fullName.Length) && (fullName.Substring(0, mscorlib.Length) == mscorlib)) { string[] resources = assembly.GetManifestResourceNames(); for (int iResource = 0; iResource < resources.Length; iResource++) { string resource = resources[iResource]; string ciResource = c_ResourceBase; if (ciResource.Length < resource.Length && resource.Substring(0, ciResource.Length) == ciResource) { //System.Globalization.Resources.CultureInfo.<culture>.tinyresources string cultureName = resource.Substring(ciResource.Length, resource.Length - ciResource.Length - System.Resources.ResourceManager.s_fileExtension.Length); // remove the leading "." if (cultureName != "") { cultureName = cultureName.Substring(1, cultureName.Length - 1); } // if GetManifestResourceNames() changes, we need to change this code to ensure the index is the same. listCultures.Add(new CultureInfo(new ResourceManager(c_ResourceBase, cultureName, iResource, typeof(CultureInfo).Assembly, assembly))); } } } } return (CultureInfo[])listCultures.ToArray(typeof(CultureInfo)); }
// gets culture list for the chosen culture alphabetically ordered public static List<string> GetCulturesList(CultureTypes cultureType) { List<string> cultures = new List<string>(); CultureInfo.GetCultures(cultureType).ToList().ForEach(ci => { if (!string.IsNullOrEmpty(ci.Name)) { cultures.Add(ci.Name); } }); cultures.Sort(); return cultures; }
private ToolStripMenuItem AddViewMenuItem(string text, bool isChecked, CultureTypes cultureType) { var menuItem = new ToolStripMenuItem {Text = text}; if (isChecked) { _currentCultureType = cultureType; menuItem.Checked = true; menuItem.CheckState = CheckState.Checked; } menuItem.Tag = cultureType; menuItem.Click += OnCultureTypeMenuItem_Click; menuItemView.DropDownItems.Add(menuItem); return menuItem; }
private static CultureInfo[] EnumCultures(CultureTypes types) { throw new NotImplementedException(); }
internal static CultureInfo[] GetCultures(CultureTypes types) { if ((types <= 0) || ((types & ~(CultureTypes.FrameworkCultures | CultureTypes.WindowsOnlyCultures | CultureTypes.ReplacementCultures | CultureTypes.UserCustomCulture | CultureTypes.AllCultures)) != 0)) { throw new ArgumentOutOfRangeException("types", string.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("ArgumentOutOfRange_Range"), new object[] { CultureTypes.NeutralCultures, CultureTypes.FrameworkCultures })); } if ((types & CultureTypes.WindowsOnlyCultures) != 0) { types &= ~CultureTypes.WindowsOnlyCultures; } string[] o = null; if (nativeEnumCultureNames((int) types, JitHelpers.GetObjectHandleOnStack<string[]>(ref o)) == 0) { return new CultureInfo[0]; } int length = o.Length; if ((types & (CultureTypes.FrameworkCultures | CultureTypes.NeutralCultures)) != 0) { length += 2; } CultureInfo[] infoArray = new CultureInfo[length]; for (int i = 0; i < o.Length; i++) { infoArray[i] = new CultureInfo(o[i]); } if ((types & (CultureTypes.FrameworkCultures | CultureTypes.NeutralCultures)) != 0) { infoArray[o.Length] = new CultureInfo("zh-CHS"); infoArray[o.Length + 1] = new CultureInfo("zh-CHT"); } return infoArray; }
unsafe internal static CultureInfo[] GetCultures(CultureTypes types) { if ((types <= 0) || (types > CultureTypes.AllCultures)) { throw new ArgumentOutOfRangeException( "types", String.Format(Environment.GetResourceString("ArgumentOutOfRange_Range"), CultureTypes.NeutralCultures, CultureTypes.AllCultures)); } bool isAddInstalled = (types == CultureTypes.InstalledWin32Cultures); bool isAddNeutral = ((types & CultureTypes.NeutralCultures) != 0); bool isAddSpecific = ((types & CultureTypes.SpecificCultures) != 0); ArrayList cultures = new ArrayList(); for (int i = 0; i < m_headerPtr->numCultures; i++) { int cultureID = GetDefaultInt32Value(i, ILANGUAGE); // Unfortunately, data for 0x040a can not be removed from culture.nlp, // since doing so will break the code to retrieve the data item by culture ID. // So we still need to special case 0x040a here. switch (cultureID) { case CultureInfo.SPANISH_TRADITIONAL_SORT: // Exclude this culture. It is not supported in NLS+ anymore. break; default: bool isAdd = false; if (IsNeutralCulture(cultureID)) { // This is a generic (generic) culture. if (isAddNeutral) { isAdd = true; } } else { // This is a specific culture. if (isAddSpecific) { isAdd = true; } else if (isAddInstalled) { if (CultureInfo.IsInstalledLCID(cultureID)) { isAdd = true; } } } if (isAdd) { cultures.Add(new CultureInfo(cultureID)); } break; } } CultureInfo[] result = new CultureInfo[cultures.Count]; cultures.CopyTo(result, 0); return (result); }
unsafe internal CultureInfo [] GetCultures(CultureTypes types) { if ((int)types <= 0 || ((int) types & (int)CultureTypesMask) != 0) { throw new ArgumentOutOfRangeException( "types", String.Format( CultureInfo.CurrentCulture, Environment.GetResourceString("ArgumentOutOfRange_Range"), CultureTypes.NeutralCultures, CultureTypes.FrameworkCultures)); } ArrayList cultures = new ArrayList(); bool isAddSpecific = ((types & CultureTypes.SpecificCultures) != 0); bool isAddNeutral = ((types & CultureTypes.NeutralCultures) != 0); bool isAddInstalled = ((types & CultureTypes.InstalledWin32Cultures) != 0); bool isAddUserCustom = ((types & CultureTypes.UserCustomCulture) != 0); bool isAddReplacement = ((types & CultureTypes.ReplacementCultures) != 0); bool isAddFramework = ((types & CultureTypes.FrameworkCultures) != 0); bool isAddWindowsOnly = ((types & CultureTypes.WindowsOnlyCultures) != 0); if (isAddNeutral || isAddSpecific || isAddFramework || isAddInstalled) { for (int i = 0; i < m_pCultureHeader->numCultureNames; i++) { int cultureID = this.m_pCultureIDIndex[i].actualCultureID; if (CultureInfo.GetSortID(cultureID) != 0 || cultureID == CultureTableRecord.SPANISH_TRADITIONAL_SORT) { // // This is an alternate sort culture. For now, do nothing. // Eventually we may add a new CultureTypes flag. // } else { CultureInfo ci = new CultureInfo(cultureID); CultureTypes ciTypes = ci.CultureTypes; // // Invariant culture (ci.Name.Length = 0) will be returned with the Neutral cultures enumeration. // and will not be returned from specific cultures enumeration. // if (((ciTypes & CultureTypes.ReplacementCultures) == 0) && ( isAddFramework || (isAddSpecific && ci.Name.Length>0 && ((ciTypes & CultureTypes.SpecificCultures) != 0)) || (isAddNeutral && (((ciTypes & CultureTypes.NeutralCultures) != 0) || ci.Name.Length==0)) || (isAddInstalled && ((ciTypes & CultureTypes.InstalledWin32Cultures) != 0)))) cultures.Add(ci); } } } CultureInfo [] result = new CultureInfo[cultures.Count]; cultures.CopyTo(result, 0); return (result); }
public static CultureInfo[] GetCultures(CultureTypes types) { Contract.Ensures(Contract.Result<CultureInfo[]>() != null); return default(CultureInfo[]); }
private static CultureInfo[] EnumCultures(CultureTypes types) { if ((types & (CultureTypes.NeutralCultures | CultureTypes.SpecificCultures)) == 0) { return Array.Empty<CultureInfo>(); } int bufferLength = Interop.GlobalizationInterop.GetLocales(null, 0); if (bufferLength <= 0) { return Array.Empty<CultureInfo>(); } Char [] chars = new Char[bufferLength]; bufferLength = Interop.GlobalizationInterop.GetLocales(chars, bufferLength); if (bufferLength <= 0) { return Array.Empty<CultureInfo>(); } bool enumNeutrals = (types & CultureTypes.NeutralCultures) != 0; bool enumSpecificss = (types & CultureTypes.SpecificCultures) != 0; List<CultureInfo> list = new List<CultureInfo>(); if (enumNeutrals) { list.Add(CultureInfo.InvariantCulture); } int index = 0; while (index < bufferLength) { int length = (int) chars[index++]; if (index + length <= bufferLength) { CultureInfo ci = CultureInfo.GetCultureInfo(new String(chars, index, length)); if ((enumNeutrals && ci.IsNeutralCulture) || (enumSpecificss && !ci.IsNeutralCulture)) { list.Add(ci); } } index += length; } return list.ToArray(); }
public static CultureInfo[] GetCultures(CultureTypes types) { Contract.Ensures(Contract.Result<CultureInfo[]>() != null); // internally we treat UserCustomCultures as Supplementals but v2 // treats as Supplementals and Replacements if((types & CultureTypes.UserCustomCulture) == CultureTypes.UserCustomCulture) { types |= CultureTypes.ReplacementCultures; } return (CultureData.GetCultures(types)); }
public static CultureInfo[] GetCultures(CultureTypes types) { bool neutral=((types & CultureTypes.NeutralCultures)!=0); bool specific=((types & CultureTypes.SpecificCultures)!=0); bool installed=((types & CultureTypes.InstalledWin32Cultures)!=0); // TODO CultureInfo [] infos = internal_get_cultures (neutral, specific, installed); // The runtime returns a NULL in the first position of the array when // 'neutral' is true. We fill it in with a clone of InvariantCulture // since it must not be read-only if (neutral && infos.Length > 0 && infos [0] == null) { infos [0] = (CultureInfo) InvariantCulture.Clone (); } for (int i = 1; i < infos.Length; ++i) { var ci = infos [i]; infos [i].m_cultureData = CultureData.GetCultureData (ci.m_name, false, ci.datetime_index, ci.CalendarType, ci.iso2lang); } return infos; }
unsafe internal static CultureInfo[] GetCultures(CultureTypes types) { if ((types <= 0) || (types > CultureTypes.AllCultures)) { throw new ArgumentOutOfRangeException( "types", String.Format(Environment.GetResourceString("ArgumentOutOfRange_Range"), CultureTypes.NeutralCultures, CultureTypes.AllCultures)); } bool isAddInstalled = (types == CultureTypes.InstalledWin32Cultures); bool isAddNeutral = ((types & CultureTypes.NeutralCultures) != 0); bool isAddSpecific = ((types & CultureTypes.SpecificCultures) != 0); ArrayList cultures = new ArrayList(); for (int i = 0; i < m_headerPtr->numCultures; i++) { int cultureID = GetDefaultInt32Value(i, ILANGUAGE); // Unfortunately, data for 0x040a can not be removed from culture.nlp, // since doing so will break the code to retrieve the data item by culture ID. // So we still need to special case 0x040a here. switch (cultureID) { case CultureInfo.SPANISH_TRADITIONAL_SORT: // Exclude this culture. It is not supported in NLS+ anymore. break; default: bool isAdd = false; if (IsNeutralCulture(cultureID)) { // This is a generic (generic) culture. if (isAddNeutral) { isAdd = true; } } else { // This is a specific culture. if (isAddSpecific) { isAdd = true; } else if (isAddInstalled) { if (CultureInfo.IsInstalledLCID(cultureID)) { isAdd = true; } } } if (isAdd) { cultures.Add(new CultureInfo(cultureID)); } break; } } CultureInfo[] result = new CultureInfo[cultures.Count]; cultures.CopyTo(result, 0); return(result); }
[System.Security.SecuritySafeCritical] // auto-generated internal static CultureInfo[] GetCultures(CultureTypes types) { // Disable warning 618: System.Globalization.CultureTypes.FrameworkCultures' is obsolete #pragma warning disable 618 // Validate flags if ((int)types <= 0 || ((int)types & (int)~(CultureTypes.NeutralCultures | CultureTypes.SpecificCultures | CultureTypes.InstalledWin32Cultures | CultureTypes.UserCustomCulture | CultureTypes.ReplacementCultures | CultureTypes.WindowsOnlyCultures | CultureTypes.FrameworkCultures)) != 0) { throw new ArgumentOutOfRangeException( nameof(types), String.Format( CultureInfo.CurrentCulture, Environment.GetResourceString("ArgumentOutOfRange_Range"), CultureTypes.NeutralCultures, CultureTypes.FrameworkCultures)); } // // CHANGE FROM Whidbey // // We have deprecated CultureTypes.FrameworkCultures. // When this enum is used, we will enumerate Whidbey framework cultures (for compatibility). // // We have deprecated CultureTypes.WindowsOnlyCultures. // When this enum is used, we will return an empty array for this enum. if ((types & CultureTypes.WindowsOnlyCultures) != 0) { // Remove the enum as it is an no-op. types &= (~CultureTypes.WindowsOnlyCultures); } String[] cultureNames = null; // // Call nativeEnumCultureNames() to get a string array of culture names based on the specified // enumeration type. // // nativeEnumCultureNames is a QCall. We need to use a reference to return the string array // allocated from the QCall. That ref has to be wrapped as object handle. // See vm\qcall.h for details in QCall. // if (nativeEnumCultureNames((int)types, JitHelpers.GetObjectHandleOnStack(ref cultureNames)) == 0) { return new CultureInfo[0]; } int arrayLength = cultureNames.Length; #if !FEATURE_CORECLR if ((types & (CultureTypes.NeutralCultures | CultureTypes.FrameworkCultures)) != 0) // add zh-CHT and zh-CHS { arrayLength += 2; } #endif // FEATURE_CORECLR CultureInfo[] cultures = new CultureInfo[arrayLength]; for (int i = 0; i < cultureNames.Length; i++) { cultures[i] = new CultureInfo(cultureNames[i]); } #if !FEATURE_CORECLR if ((types & (CultureTypes.NeutralCultures | CultureTypes.FrameworkCultures)) != 0) // add zh-CHT and zh-CHS { Contract.Assert(arrayLength == cultureNames.Length + 2, "CultureData.nativeEnumCultureNames() Incorrect array size"); cultures[cultureNames.Length] = new CultureInfo("zh-CHS"); cultures[cultureNames.Length + 1] = new CultureInfo("zh-CHT"); } #endif // FEATURE_CORECLR #pragma warning restore 618 return cultures; }
/// <summary> /// Initializes a new instance of the <see cref="LanguagesTemplateDropDown"/> class. /// </summary> /// <param name="type"> /// The type. /// </param> /// <param name="types"> /// The types. /// </param> public LanguagesTemplateDropDown(ListItemType type, CultureTypes types) { this.templateType = type; this.cultureTypes = types; }