当前位置: 首页>>代码示例>>C#>>正文


C# CultureInfo.ToString方法代码示例

本文整理汇总了C#中System.Globalization.CultureInfo.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# CultureInfo.ToString方法的具体用法?C# CultureInfo.ToString怎么用?C# CultureInfo.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Globalization.CultureInfo的用法示例。


在下文中一共展示了CultureInfo.ToString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TranslateToTranslatedValue

        public RouteValueTranslation TranslateToTranslatedValue(string routeValue, CultureInfo culture)
        {
            RouteValueTranslation translation = null;

            // Find translation in specified CultureInfo
            translation = this.Translations.Where(
                t => t.RouteValue == routeValue
                    && (t.Culture.ToString() == culture.ToString() || t.Culture.ToString().Substring(0, 2) == culture.ToString().Substring(0, 2)))
                .OrderByDescending(t => t.Culture)
                .FirstOrDefault();
            if (translation != null)
            {
                return translation;
            }

            // Find translation without taking account on CultureInfo
            translation = this.Translations.Where(t => t.RouteValue == routeValue)
                .FirstOrDefault();
            if (translation != null)
            {
                return translation;
            }

            // Return the current values
            return new RouteValueTranslation
            {
                Culture = culture,
                RouteValue = routeValue,
                TranslatedValue = routeValue
            };
        }
开发者ID:algola,项目名称:backup,代码行数:31,代码来源:DictionaryRouteValueTranslationProvider.cs

示例2: PrintCalendar

 /// <summary>
 /// Prints the calendar for a month and year.
 /// </summary>
 /// <param name="month">Month to print.</param>
 /// <param name="year">Year to specify the month.</param>
 /// <param name="culture">Given Culture info.</param>
 public static void PrintCalendar(int month, int year, CultureInfo culture)
 {
     Console.WriteLine(new CultureInfo(culture.ToString()).DateTimeFormat.GetMonthName(month));
     for (int i = 0; i < 7; i++)
     {
         Console.Write(new CultureInfo(culture.ToString()).DateTimeFormat.GetDayName((DayOfWeek)i) + " ");
     }
 }
开发者ID:ViktorBarzin,项目名称:HackBulgaria-CSharp,代码行数:14,代码来源:Program.cs

示例3: CreateResource

        private static ResourceBase CreateResource(string resourceName, CultureInfo culture, string resourceLocation)
        {
            Func<string, string> fixResourceName = c => resourceName + ((c != null) ? "." + c : string.Empty) + ".resx";

            IVirtualPathProvider vpp = ServiceLocator.Current.Resolve<IVirtualPathProvider>();

            // First try the file path Resource.fr-CA.resx
            string fullResourcePath = vpp.CombinePaths(resourceLocation, fixResourceName(culture.ToString()));
            bool exists = vpp.FileExists(fullResourcePath);

            // If not found, try Resource.fr.resx
            if (!exists)
            {
                fullResourcePath = vpp.CombinePaths(resourceLocation, fixResourceName(culture.TwoLetterISOLanguageName));
                exists = vpp.FileExists(fullResourcePath);
            }

            // If nothing is found try Resource.resx
            if (!exists)
            {
                fullResourcePath = vpp.CombinePaths(resourceLocation, fixResourceName(null));
                exists = vpp.FileExists(fullResourcePath);
            }

            ResourceBase resource = exists ?
                                    new ResXResource(ServiceLocator.Current.Resolve<IPathResolver>().Resolve(fullResourcePath)) :
                                    new EmbeddedResource(resourceName, culture) as ResourceBase;

            return resource;
        }
开发者ID:juanplopes,项目名称:simple-telerik,代码行数:30,代码来源:LocalizationService.cs

示例4: Region

 public Region(CultureInfo culture)
 {
     DisplayName = culture.DisplayName;
     EnglishName = culture.EnglishName;
     NativeName = culture.NativeName;
     ShortName = culture.ToString();
 }
开发者ID:strnguv,项目名称:marketplaceconfig,代码行数:7,代码来源:Region.cs

示例5: GetBundle

 public static ResourceBundle GetBundle (string bundleClass, CultureInfo culture)
 {
     Assembly asm = null;
     foreach (Assembly a in AppDomain.CurrentDomain.GetAssemblies ()) {
         if (a.GetType (bundleClass) != null) {
             asm = a;
             break;
         }
     }
     if (asm == null)
         throw new MissingResourceException ();
     Stream manifestResourceStream;
     manifestResourceStream = asm.GetManifestResourceStream (bundleClass + "_" + culture.ToString().Replace ('-','_') + ".properties");
     if (manifestResourceStream == null)
         manifestResourceStream = asm.GetManifestResourceStream (bundleClass + "_" + culture.TwoLetterISOLanguageName + ".properties");
     if (manifestResourceStream == null)
         manifestResourceStream = asm.GetManifestResourceStream (bundleClass + ".properties");
     if (manifestResourceStream != null) {
         ResourceBundle bundle = new ResourceBundle ();
         bundle.culture = culture;
         bundle.Load (manifestResourceStream);
         return bundle;
     } else
         throw new MissingResourceException ();
 }
开发者ID:FireflyLogic,项目名称:couchbase-lite-net,代码行数:25,代码来源:ResourceBundle.cs

示例6: LoadTemplate

 public string LoadTemplate(string templateName, CultureInfo culture, FogBugzCase cases)
 {
     if (culture == null)
         culture = CultureInfo.InvariantCulture;
     string text = File.ReadAllText(Path.Combine("Views", culture.ToString(), templateName + ".cshtml"));
     return Razor.Parse(text, cases);
 }
开发者ID:katiesenger,项目名称:EMailFogBugz,代码行数:7,代码来源:FileSystemTemplateLoader.cs

示例7: InternalGetResourceSet

        protected override ResourceSet InternalGetResourceSet(CultureInfo culture,
            bool createIfNotExists, bool tryParents)
        {
            ResourceSet rs = (ResourceSet)ResourceSets[culture];
            if (rs == null)
            {
                string resourceFileName = null;

                //lazy-load default language (without caring about duplicate assignment in race conditions, no harm done);
                if (_neutralResourcesCulture == null)
                {
                    _neutralResourcesCulture =
                        GetNeutralResourcesLanguage(MainAssembly);
                }

                // if we're asking for the default language, then ask for the
                // invariant (non-specific) resources.
                if (_neutralResourcesCulture.Equals(culture))
                    culture = CultureInfo.InvariantCulture;
                
                resourceFileName = GetResourceFileName(culture);

                // Only bother to try the lookup based on the resource property if we haven't tried this language before
                if (!_prevCultures.Contains(culture.ToString()) && culture != CultureInfo.InvariantCulture)
                {
                    _prevCultures.Add(culture.ToString());
                    // The T4 template resource generator will link the culture specific resources in to the invariant culture resource
                    // We'll try and load the culture specific resource here

                    var content = GetString("Resources." + culture);
                    if (content != null)
                    {
                        using (var stream = new MemoryStream(Encoding.ASCII.GetBytes(content)))
                        using (var reader = new ResXResourceReader(stream))
                        {
                            rs = new ResourceSet(reader);
                        }
                    }
                }

                if (rs == null)
                    rs = base.InternalGetResourceSet(culture, createIfNotExists, tryParents);
                 
            }
            return rs;
        }
开发者ID:offbyoneBB,项目名称:mp-onlinevideos2,代码行数:46,代码来源:SingleAssemblyComponentResourceManager.cs

示例8: SetLanguage

        /// <summary>
        /// Set language culture for the application.
        /// </summary>
        /// <param name="cultureInfo"><see cref="CultureInfo"/> to be set.</param>
        public static void SetLanguage(CultureInfo cultureInfo)
        {
            LanguageManager.cultureInfo = cultureInfo;
            resourceManager = new ResourceManager(string.Format("PawnPlus.Language.Languages.{0}", cultureInfo.ToString()), typeof(LanguageManager).Assembly); // Use this way because I don't want "satellite assembly" for language.

            Thread.CurrentThread.CurrentCulture = cultureInfo;
            Thread.CurrentThread.CurrentUICulture = cultureInfo;
        }
开发者ID:BroneKot,项目名称:PawnPlus,代码行数:12,代码来源:LanguageManager.cs

示例9: GetEulaText

        public string GetEulaText(string packageServerUrl, Guid eulaId, CultureInfo userCulture)
        {
            PackagesSoapClient client = CreateClient(packageServerUrl);

            string eulaText = client.GetEulaText(eulaId, userCulture.ToString());

            return eulaText;
        }
开发者ID:RuneAndersen,项目名称:C1-CMS,代码行数:8,代码来源:PackageServerFacadeImpl.cs

示例10: SetCulture

        public void SetCulture(CultureInfo culture, HttpContextBase httpContext)
        {
            var currentCulture = httpContext.Request.Cookies["CurrentCulture"];

            if (currentCulture == null || currentCulture.Value != culture.ToString())
            {

                var cookie = new HttpCookie("CurrentCulture")
                    {
                        Value = culture.ToString(),
                        Expires = DateTime.Now.AddYears(30)
                    };

                httpContext.Response.Cookies.Add(cookie);
            }

            Thread.CurrentThread.CurrentCulture = culture;
            Thread.CurrentThread.CurrentUICulture = culture;
        }
开发者ID:robinvanderknaap,项目名称:SkaeleArchitecture,代码行数:19,代码来源:CultureService.cs

示例11: GetResourceWriter

		public System.Resources.IResourceWriter GetResourceWriter(CultureInfo info)
		{
			try {
				LoggingService.Debug("ResourceWriter requested for culture: " + info.ToString());
				return this.store.GetWriter(info);
			} catch (Exception e) {
				MessageService.ShowException(e);
				return null;
			}
		}
开发者ID:2594636985,项目名称:SharpDevelop,代码行数:10,代码来源:DesignerResourceService.cs

示例12: GetPackageDescriptions

        public IEnumerable<PackageDescription> GetPackageDescriptions(string packageServerUrl, Guid installationId, CultureInfo userCulture)
        {
            List<PackageDescription> packageDescriptions = _packageServerFacadeImplCache.GetCachedPackageDescription(packageServerUrl, installationId, userCulture);
            if (packageDescriptions != null) return packageDescriptions;

            PackageDescriptor[] packageDescriptors = null;
            try
            {
                PackagesSoapClient client = CreateClient(packageServerUrl);

                packageDescriptors = client.GetPackageList(installationId, userCulture.ToString());
            }
            catch (Exception ex)
            {
                Log.LogError("PackageServerFacade", ex);
            }

            packageDescriptions = new List<PackageDescription>();
            if (packageDescriptors != null)
            {
                foreach (PackageDescriptor packageDescriptor in packageDescriptors)
                {
                    if (ValidatePackageDescriptor(packageDescriptor))
                    {
                        packageDescriptions.Add(new PackageDescription
                        {
                            PackageFileDownloadUrl = packageDescriptor.PackageFileDownloadUrl,
                            PackageVersion = packageDescriptor.PackageVersion,
                            Description = packageDescriptor.Description,
                            EulaId = packageDescriptor.EulaId,
                            GroupName = packageDescriptor.GroupName,
                            Id = packageDescriptor.Id,
                            InstallationRequireLicenseFileUpdate = packageDescriptor.InstallationRequireLicenseFileUpdate,
                            IsFree = packageDescriptor.IsFree,
                            IsTrial = packageDescriptor.IsTrial,
                            LicenseRuleId = packageDescriptor.LicenseId,
                            MaxCompositeVersionSupported = packageDescriptor.MaxCompositeVersionSupported,
                            MinCompositeVersionSupported = packageDescriptor.MinCompositeVersionSupported,
                            Name = packageDescriptor.Name,
                            PriceAmmount = packageDescriptor.PriceAmmount,
                            PriceCurrency = packageDescriptor.PriceCurrency,
                            ReadMoreUrl = packageDescriptor.ReadMoreUrl,
                            TechicalDetails = packageDescriptor.TechicalDetails,
                            TrialPeriodDays = packageDescriptor.TrialPeriodDays,
                            UpgradeAgreementMandatory = packageDescriptor.UpgradeAgreementMandatory,
                            Vendor = packageDescriptor.Author
                        });
                    }
                }

                _packageServerFacadeImplCache.AddCachedPackageDescription(packageServerUrl, installationId, userCulture, packageDescriptions);
            }

            return packageDescriptions;
        }
开发者ID:RuneAndersen,项目名称:C1-CMS,代码行数:55,代码来源:PackageServerFacadeImpl.cs

示例13: Store

 public Store(int version, string displayName, string storeName, string storeID,
     bool storeEnabled, Uri storeImage, CultureInfo storeLocale)
 {
     this.datVersion = version;
     this.displayName = displayName;
     this.storeName = storeName;
     this.storeID = storeID;
     this.storeEnabled = storeEnabled;
     this.storeImage = storeImage;
     this.storeLocale = storeLocale.ToString();
 }
开发者ID:strnguv,项目名称:marketplaceconfig,代码行数:11,代码来源:Store.cs

示例14: Main

 static void Main(string[] args)
 {
     DateTime d = new DateTime(2002, 2, 13);
      // current culture
      System.Console.WriteLine(d.ToLongDateString());
      // use IFormatProvider
      System.Console.WriteLine(d.ToString("D", new CultureInfo("fr-fr")));
      // use culture of thread
      CultureInfo ci = Thread.CurrentThread.CurrentCulture;
      Console.WriteLine(ci.ToString() + ": " + d.ToString("D"));
      ci = new CultureInfo("de-de");
      Thread.CurrentThread.CurrentCulture = ci;
      Console.WriteLine(ci.ToString() + ": " + d.ToString("D"));
 }
开发者ID:alannet,项目名称:example,代码行数:14,代码来源:LocalizationDates.cs

示例15: getLanguage

        public static string getLanguage()
        {
            string strOut = string.Empty;

            LanguageSettings objLanguageSetting = Globals.ThisAddIn.Application.LanguageSettings;
            CultureInfo ci = new CultureInfo(objLanguageSetting.get_LanguageID(Office.MsoAppLanguageID.msoLanguageIDUI));

            switch (ci.ToString())
            {
                case "zh-CN":
                    strOut = "zh-CN";
                    break;
                case "en-US":
                    strOut = "en-US";
                    break;
                case "ja-JP":
                    strOut = "ja-JP";
                    break;
                case "ja":
                    strOut = "ja";
                    break;
                case "pl":
                    strOut = "pl";
                    break;
                case "it":
                    strOut = "it";
                    break;
                case "ru-RU":
                    strOut = "ru-RU";
                    break;
                case "ru":
                    strOut = "ru";
                    break;
                case "fr":
                    strOut = "fr";
                    break;
                case "de":
                    strOut = "de";
                    break;
                case "es":
                    strOut = "es";
                    break;
                default:
                    strOut = "others";
                    break;
            }
            return strOut;
        }
开发者ID:eSDK,项目名称:esdk_OutlookPlugin,代码行数:48,代码来源:GlobalResourceClass.cs


注:本文中的System.Globalization.CultureInfo.ToString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。