Class LanguagePair
A LanguagePair represents a combination of a source language and a target language. Languages are specified using their culture or the culture which usually maps to CultureInfo.Name. However, since the XmlSerializer cannot serialize CultureInfo objects, the culture can also be specified using the name.
Implements
Inherited Members
Namespace: SdlSdl.LanguagePlatformCore
Assembly: Sdl.LanguagePlatform.Core.dll
Syntax
[DataContract]
public class LanguagePair : IComparable<LanguagePair>
Constructors
LanguagePair()
Instantiates a new object and initializes both languages to the invariant culture.
Declaration
public LanguagePair()
LanguagePair(CultureCode, CultureCode)
Instantiates a new object and initializes it with the provided language direction.
Declaration
public LanguagePair(CultureCode srcCulture, CultureCode trgCulture)
Parameters
Type | Name | Description |
---|---|---|
CultureCode | srcCulture | The source culture name |
CultureCode | trgCulture | The target culture name |
Properties
SourceCulture
Gets or sets the source culture
Declaration
public CultureCode SourceCulture { get; set; }
Property Value
Type | Description |
---|---|
CultureCode |
SourceCultureName
Gets or sets the source language in form of a culture code.
Declaration
[DataMember]
public string SourceCultureName { get; set; }
Property Value
Type | Description |
---|---|
string |
TargetCulture
Gets or sets the target culture
Declaration
public CultureCode TargetCulture { get; set; }
Property Value
Type | Description |
---|---|
CultureCode |
TargetCultureName
Gets or sets the target language in form of a culture code.
Declaration
[DataMember]
public string TargetCultureName { get; set; }
Property Value
Type | Description |
---|---|
string |
Methods
CompareTo(LanguagePair)
Compares the language directions, which is achieved by lexically comparing the source and target culture names.
Declaration
public int CompareTo(LanguagePair other)
Parameters
Type | Name | Description |
---|---|---|
LanguagePair | other |
Returns
Type | Description |
---|---|
int | A comparision result |
Equals(object)
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
object | obj | The object to compare with the current object. |
Returns
Type | Description |
---|---|
bool | true if the specified object is equal to the current object; otherwise, false. |
Overrides
GetHashCode()
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
int | A hash code for this object |
Overrides
IsCompatible(LanguagePair)
Checks whether a language pair is compatible to another language pair, which is the case if the source and target cultures of both language pairs are non-null and are pairwise compatible with each other (AreCompatible(CultureInfo, CultureInfo)).
Declaration
public bool IsCompatible(LanguagePair other)
Parameters
Type | Name | Description |
---|---|---|
LanguagePair | other |
Returns
Type | Description |
---|---|
bool |
IsCompatiblePairAsync(LanguagePair, ICultureMetadataManager)
Checks whether a language pair is compatible to another language pair, which is the case if the source and target cultures of both language pairs are non-null and are pairwise compatible with each other (AreCompatibleCodesAsync(CultureCode, CultureCode, ICultureMetadataManager)).
Declaration
public Task<bool> IsCompatiblePairAsync(LanguagePair other, ICultureMetadataManager cultureMetadataManager)
Parameters
Type | Name | Description |
---|---|---|
LanguagePair | other | |
ICultureMetadataManager | cultureMetadataManager |
Returns
Type | Description |
---|---|
Taskbool |
Reverse()
Creates a new language pair object with the reversed language direction.
Declaration
public LanguagePair Reverse()
Returns
Type | Description |
---|---|
LanguagePair |
ToString()
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string | A string representation of the object, for display purposes. |
Overrides
TryParse(string, out LanguagePair)
Attempts to parse a language pair represented by a string, as produced by ToString().
Declaration
public static bool TryParse(string s, out LanguagePair lp)
Parameters
Type | Name | Description |
---|---|---|
string | s | The input string |
LanguagePair | lp | Will hold the deserialized (parsed) return value upon success, and is set to |
Returns
Type | Description |
---|---|
bool |
|