Class Locale
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 Locale
Constructors
| Improve this Doc View SourceLocale(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 SourceCurrencyCode
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.
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 SourceCreate(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 |
Remarks
Uses the CanonicalForm() of the
id
.
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 |
Exceptions
Type | Condition |
---|---|
FormatException |
|
See Also
| Improve this Doc View SourceFind(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 |
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.
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(). |
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.
ToString()
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
String |