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 = ""; } }
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; } }
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 = ""; } }
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; } }