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 System.Globalization.CultureInfo objects, the culture can also be specified using the name.
Inheritance
Implements
Inherited Members
Namespace: Sdl.LanguagePlatform.Core
Assembly: Sdl.LanguagePlatform.Core.dll
Syntax
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 |
---|---|---|
Sdl.Core.Globalization.CultureCode | srcCulture | The source culture name |
Sdl.Core.Globalization.CultureCode | trgCulture | The target culture name |
Properties
SourceCulture
Gets or sets the source culture
Declaration
public CultureCode SourceCulture { get; set; }
Property Value
Type | Description |
---|---|
Sdl.Core.Globalization.CultureCode |
SourceCultureName
Gets or sets the source language in form of a culture code.
Declaration
public string SourceCultureName { get; set; }
Property Value
Type | Description |
---|---|
System.String |
TargetCulture
Gets or sets the target culture
Declaration
public CultureCode TargetCulture { get; set; }
Property Value
Type | Description |
---|---|
Sdl.Core.Globalization.CultureCode |
TargetCultureName
Gets or sets the target language in form of a culture code.
Declaration
public string TargetCultureName { get; set; }
Property Value
Type | Description |
---|---|
System.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 |
---|---|
System.Int32 | A comparision result |
Equals(Object)
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
System.Object | obj | The object to compare with the current object. |
Returns
Type | Description |
---|---|
System.Boolean | true if the specified object is equal to the current object; otherwise, false. |
Overrides
GetHashCode()
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
System.Int32 | 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 |
---|---|
System.Boolean |
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 | |
Sdl.Core.Globalization.CultureMetadataManager.ICultureMetadataManager | cultureMetadataManager |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Boolean> |
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 |
---|---|
System.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 |
---|---|---|
System.String | s | The input string |
LanguagePair | lp | Will hold the deserialized (parsed) return value upon success, and is set to |
Returns
Type | Description |
---|---|
System.Boolean |
|