Class LocaleIdentifier
Identifies a set of preferences that tend to be shared across significant swaths of the world.
Inherited Members
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 SourceExtensions
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.
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.
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.
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.
UnicodeExtension
The Unicode BCP 47 U Extension.
Declaration
public LocaleExtension UnicodeExtension { get; }
Property Value
| Type | Description |
|---|---|
| LocaleExtension |
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 SourceCanonicalForm()
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().
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. |
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 |
Exceptions
| Type | Condition |
|---|---|
| FormatException |
|
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 |
Remarks
The transformation rules for converting a BCP 47 tag into a Unicode Locale ID are not applied.
Exceptions
| Type | Condition |
|---|---|
| FormatException |
|
RemoveMostLikelySubtags()
A new locale idenyifer with empty subtags that MostLikelySubtags() would fill.
Declaration
public LocaleIdentifier RemoveMostLikelySubtags()
Returns
| Type | Description |
|---|---|
| LocaleIdentifier | A new locale identifier. |
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
| Improve this Doc View SourceToString()
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| String |
Overrides
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.
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.
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 |
Returns
| Type | Description |
|---|---|
| Boolean | true if |
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 |
| String | message | The reason why the parsing failed. |
Returns
| Type | Description |
|---|---|
| Boolean | true if |
Remarks
A locale identifier that refers to s.
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 |
| String | message | The reason why the parsing failed. |
Returns
| Type | Description |
|---|---|
| Boolean | true if |
Remarks
The transformation rules for converting a BCP 47 tag into a Unicode Locale ID are not applied.