Show / Hide Table of Contents

Class Locale

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

Inheritance
Object
Locale
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 Locale

Constructors

| Improve this Doc View Source

Locale(LocaleIdentifier)

Creates a new instance of the Locale class with the specified LocaleIdentifier.

Declaration
public Locale(LocaleIdentifier id)
Parameters
Type Name Description
LocaleIdentifier id

Identifies a set of preferences.

Remarks

The Create method should be used, so that locale caching can be used.

Properties

| Improve this Doc View Source

CurrencyCode

The primary currency of the locale.

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

An ISO 4217 currency code.

Remarks

The primary currency is based on the locale's Region.

| Improve this Doc View Source

Id

Identifies a set of preferences for the locale.

Declaration
public LocaleIdentifier Id { get; }
Property Value
Type Description
LocaleIdentifier

The LocaleIdentifier of the locale identifier.

Methods

| Improve this Doc View Source

Create(LocaleIdentifier)

Creates or reuses a locale with the specified LocaleIdentifier.

Declaration
public static Locale Create(LocaleIdentifier id)
Parameters
Type Name Description
LocaleIdentifier id

A locale identifier.

Returns
Type Description
Locale

A locale for the specified id.

Remarks

Uses the CanonicalForm() of the id.

| Improve this Doc View Source

Create(String)

Creates or reuses a locale with the specified string locale identifier.

Declaration
public static Locale Create(string id)
Parameters
Type Name Description
String id

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

Returns
Type Description
Locale

A locale for the specified id.

Exceptions
Type Condition
FormatException

id is not in the correct format.

See Also
Parse(String)
| Improve this Doc View Source

Find(String)

Find the first XML element that matches the XPath expression in the ResourceBundle(String, String).

Declaration
public XPathNavigator Find(string predicate)
Parameters
Type Name Description
String predicate

The XPath expression to match.

Returns
Type Description
XPathNavigator

The matched element.

Remarks

If the predicate cannot be matched, then it is recursively modified with the "root aliases" and retried. Lateral inheritance is also implemented. [@count='x'] becomes [@count='x' or @count='other'].

The predicate is cached to improve performance.

Exceptions
Type Condition
KeyNotFoundException

No elements match the predicate.

| Improve this Doc View Source

FindOrDefault(String)

Find the first (or none) XML element that matches the XPath expression in the ResourceBundle(String, String).

Declaration
public XPathNavigator FindOrDefault(string predicate)
Parameters
Type Name Description
String predicate

The XPath expression to match.

Returns
Type Description
XPathNavigator

The matched element or null.

Remarks

If the predicate cannot be matched, then it is recursively modified with the "root aliases" and retried. Lateral inheritance is also implemented. [@count='x'] becomes [@count='x' or @count='other'].

The predicate is cached to improve performance.

| Improve this Doc View Source

ResourceBundle(String, String)

A sequence of CLDR documents that can contain a locale resource.

Declaration
public IEnumerable<XPathDocument> ResourceBundle(string prefix = "common/main/", string suffix = ".xml")
Parameters
Type Name Description
String prefix

The SVN trunk relative name of the document. Defaults to "common/main/".

String suffix

The file extension. Defaults to ".xml".

Returns
Type Description
IEnumerable<XPathDocument>

All the documents that are named by the SearchChain().

| Improve this Doc View Source

SearchChain()

The search chain for a locale resource.

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

A sequence of "files" that should be searched.

Remarks

Same as SearchChain() but applies any "parent locales" overrides.

| Improve this Doc View Source

ToString()

Declaration
public override string ToString()
Returns
Type Description
String
Overrides
Object.ToString()
  • Improve this Doc
  • View Source
Back to top Generated by DocFX