예제 #1
0
        public PlatformCulture(string platformCultureString)
        {
            if (string.IsNullOrEmpty(platformCultureString))
            {
                throw new ArgumentException("Expected culture identifier", "platformCultureString");  // in C# 6 use nameof(platformCultureString)
                                
            }

            PlatformString = platformCultureString.Replace("_", "-");  // .NET expects dash, not underscore
                        var dashIndex = PlatformString.IndexOf("-", StringComparison.Ordinal);

            if (dashIndex > 0)
            {
                var parts = PlatformString.Split('-');
                LanguageCode = parts[0];
                LocaleCode   = parts[1];
            }
            else
            {
                LanguageCode = PlatformString;
                LocaleCode   = "";
            }
        }
예제 #2
0
        public PlatformCulture(string platformCultureString)
        {
            if (string.IsNullOrWhiteSpace(platformCultureString))
            {
                throw new ArgumentException("Expected culture identifier.", nameof(platformCultureString));
            }

            // .NET expects dash, not underscore
            PlatformString = platformCultureString.Replace("_", "-");
            var dashIndex = PlatformString.IndexOf("-", StringComparison.Ordinal);

            if (dashIndex > 0)
            {
                var parts = PlatformString.Split('-');
                LanguageCode = parts[0];
                LocaleCode   = parts[1];
            }
            else
            {
                LanguageCode = PlatformString;
                LocaleCode   = string.Empty;
            }
        }
예제 #3
0
        public PlatformCulture(string platformCultureString)
        {
            if (string.IsNullOrEmpty(platformCultureString))
            {
                throw new ArgumentException("Expected culture identifier", "platformCultureString"); // en C# 6 use nameof("platformCultureString")
            }

            PlatformString = platformCultureString.Replace("_", "-"); // .NET espera guion, no guion bajo

            var dashIndex = PlatformString.IndexOf("-", StringComparison.Ordinal);

            if (dashIndex > 0)
            {
                var parts = PlatformString.Split('-');
                LanguageCode = parts[0];
                LocaleCode   = parts[1];
            }
            else
            {
                LanguageCode = PlatformString;
                LocaleCode   = "";
            }
        }
예제 #4
0
        public PlatformCulture(String platformCultureString)
        {
            if (String.IsNullOrEmpty(platformCultureString))
            {
                throw new ArgumentException("Expected culture identifier", nameof(platformCultureString));
            }

            this.PlatformString = platformCultureString.Replace("_", "-"); // .NET expects dash, not underscore

            Int32 dashIndex = PlatformString.IndexOf("-", StringComparison.Ordinal);

            if (dashIndex > 0)
            {
                String[] parts = PlatformString.Split('-');

                this.LanguageName = parts[0];
                this.LocaleName   = parts[1];
            }
            else
            {
                this.LanguageName = this.PlatformString;
                this.LocaleName   = String.Empty;
            }
        }