Show / Hide Table of Contents

Class LocaleIdentifier

Identifies a set of preferences that tend to be shared across significant swaths of the world.

Inheritance
Object
LocaleIdentifier
Inherited Members
Object.Equals(Object)
Object.Equals(Object, Object)
Object.ReferenceEquals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Namespace: Sepia.Globalization
Assembly: Sepia.Globalization.dll
Syntax
public class LocaleIdentifier
Remarks

An identifier is based on BCP47 and Unicode TR 35 for distinguishing among languages, locales, regions, currencies, time zones, transforms, and so on.

Properties

| Improve this Doc View Source

Extensions

Language extension subtag(s).

Declaration
public IEnumerable<string> Extensions { get; }
Property Value
Type Description
IEnumerable<String>

A sequence of extension subtags.

Remarks

Extensions provide a mechanism for extending the Language subtag for use in various applications.

All subtags are case insensitive but stored in the lower-case form.

| Improve this Doc View Source

Language

The language subtag.

Declaration
public string Language { get; }
Property Value
Type Description
String

ISO 639 code or the empty string.

Remarks

The language subtag is case insensitive but stored in the lower-case form.

| Improve this Doc View Source

Region

The region subtag.

Declaration
public string Region { get; }
Property Value
Type Description
String

ISO 3166-1 or UN M.49 code or the empty string.

Remarks

The region subtag is case insensitive but stored in the upper-case form.

| Improve this Doc View Source

Script

The script (writing system) subtag.

Declaration
public string Script { get; }
Property Value
Type Description
String

ISO 15924 code or the empty string.

Remarks

The script subtag is case insensitive but stored in the title-case form.

| Improve this Doc View Source

UnicodeExtension

The Unicode BCP 47 U Extension.

Declaration
public LocaleExtension UnicodeExtension { get; }
Property Value
Type Description
LocaleExtension
| Improve this Doc View Source

Variants

Locale variations.

Declaration
public IEnumerable<string> Variants { get; }
Property Value
Type Description
IEnumerable<String>

A sequence of variant subtags.

Remarks

Variant subtags are used to indicate additional, well-recognized variations that define a language or its dialects that are not covered by other available subtags.

All subtags are case insensitive but stored in the lower-case form.

Methods

| Improve this Doc View Source

CanonicalForm()

A new locale identifier in the canonical form.

Declaration
public LocaleIdentifier CanonicalForm()
Returns
Type Description
LocaleIdentifier

A new locale identifier in the canonical form.

Remarks

The canonical form has all subtags MostLikelySubtags().

| Improve this Doc View Source

MostLikelySubtags()

A new locale identifier with the all the empty subtags filled in with a likely value.

Declaration
public LocaleIdentifier MostLikelySubtags()
Returns
Type Description
LocaleIdentifier

A new locale identifier with all subtags filled in.

| Improve this Doc View Source

Parse(String)

Parses the string representation of a locale identifier to a LanguageIdentifier.

Declaration
public static LocaleIdentifier Parse(string s)
Parameters
Type Name Description
String s

A case insensitive string containing a locale identifier, based on BCP47.

Returns
Type Description
LocaleIdentifier

A locale identifier that refers to s.

Exceptions
Type Condition
FormatException

s is not in the correct format.

| Improve this Doc View Source

ParseBcp47(String)

Parses the string representation of a locale identifier to a LanguageIdentifier.

Declaration
public static LocaleIdentifier ParseBcp47(string s)
Parameters
Type Name Description
String s

A case insensitive string containing a locale identifier, based on BCP47.

Returns
Type Description
LocaleIdentifier

A local identifier that refers to s.

Remarks

The transformation rules for converting a BCP 47 tag into a Unicode Locale ID are not applied.

Exceptions
Type Condition
FormatException

s is not in the correct format.

| Improve this Doc View Source

RemoveMostLikelySubtags()

A new locale idenyifer with empty subtags that MostLikelySubtags() would fill.

Declaration
public LocaleIdentifier RemoveMostLikelySubtags()
Returns
Type Description
LocaleIdentifier

A new locale identifier.

| Improve this Doc View Source

SearchChain()

The search chain for a resource.

Declaration
public IEnumerable<string> SearchChain()
Returns
Type Description
IEnumerable<String>

A sequence of "languages" that should be searched.

Remarks

The sequence contains a combination of Language, Script, Region and Variants subtags.

| Improve this Doc View Source

ToString()

Declaration
public override string ToString()
Returns
Type Description
String
Overrides
Object.ToString()
Remarks

Uses the casing recommendations in [BCP47] for subtag casing. The Region subtag is in uppercase, the Script subtag is in title case, and all other subtags are in lowercase.

| Improve this Doc View Source

ToUnicodeLanguage(Boolean)

Get the Unicode Language ID.

Declaration
public string ToUnicodeLanguage(bool variantUppercase = false)
Parameters
Type Name Description
Boolean variantUppercase

Controls the casing of the Variants. The default is false, which is lowercase. When true the variant(s) are in uppecase.

Returns
Type Description
String

The unicode language ID, consists of the Language, Script and Region and Variants separated by "_".

Remarks

Uses the casing recommendations in [BCP47] for subtag casing. The Region subtag is in uppercase, the Script subtag is in title case, and all other subtags are in lowercase.

| Improve this Doc View Source

TryParse(String, out LocaleIdentifier)

Tries parsing the string representation of a locale identifier.

Declaration
public static bool TryParse(string s, out LocaleIdentifier result)
Parameters
Type Name Description
String s

A case insensitive string containing a locale identifier, based on BCP47.

LocaleIdentifier result

A locale identifier that refers to s or null if the parsing failed.

Returns
Type Description
Boolean

true if s was parsed successfully; otherwise, false.

| Improve this Doc View Source

TryParse(String, out LocaleIdentifier, out String)

Tries parsing the string representation of a locale identifier.

Declaration
public static bool TryParse(string s, out LocaleIdentifier result, out string message)
Parameters
Type Name Description
String s

A case insensitive string containing a locale identifier, based on BCP47.

LocaleIdentifier result

A local identifier that refers to s or null if the parsing failed.

String message

The reason why the parsing failed.

Returns
Type Description
Boolean

true if s was parsed successfully; otherwise, false.

Remarks

A locale identifier that refers to s.

| Improve this Doc View Source

TryParseBcp47(String, out LocaleIdentifier, out String)

Tries parsing the string representation of a locale identifier.

Declaration
public static bool TryParseBcp47(string s, out LocaleIdentifier result, out string message)
Parameters
Type Name Description
String s

A case insensitive string containing a locale identifier, based on BCP47.

LocaleIdentifier result

A BCP 47 language identifier that refers to s or null if the parsing failed.

String message

The reason why the parsing failed.

Returns
Type Description
Boolean

true if s was parsed successfully; otherwise, false.

Remarks

The transformation rules for converting a BCP 47 tag into a Unicode Locale ID are not applied.

  • Improve this Doc
  • View Source
Back to top Generated by DocFX