Search Results for

    Show / Hide Table of Contents

    Class Language

    Represents a language in the sense of a System.Globalization.CultureInfo object, using a mechanism that allows basic manipulations on a system where the language is not fully supported.

    The reason we use this type as opposed to the CultureInfo class in the .NET Framework is that when working with files we may convert the file on a system that supports a particular language (i.e. the CultureInfo for this language abbreviation is known), but the file may subsequently be opened on a system that does not yet have support for this language.

    Depending on what processing is to be done this may be a perfectly valid use case, and it would be too harsh a restriction to require support for the language to be installed on all systems that may ever look at the file.

    Under normal circumstances the language should be created from a CultureInfo object.

    In addition this wrapper allows a language to be represented by a plain string when no CultureInfo for this language is supported on the system, and thus allows the language to be represented until some truly language specific processing is needed (i.e. when the corresponding CultureInfo is required).

    When supported by the operating system the corresponding CultureInfo can be obtained directly from the CultureInfo property. If not supported this will throw an UnsupportedLanguageException.

    Use the IsValid and IsSupported properties to determine if the language has been set and whether it is supported by the operating system.

    Inheritance
    System.Object
    Language
    Implements
    System.ICloneable
    Inherited Members
    System.Object.Equals(System.Object, System.Object)
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.GetType()
    System.Object.MemberwiseClone()
    Namespace: Sdl.Core.Globalization
    Assembly: Sdl.Core.Globalization.dll
    Syntax
    public class Language : ICloneable

    Constructors

    Language()

    Default constructor, creates an invalid language object.

    Declaration
    public Language()

    Language(Language)

    Protected constructor used in cloning.

    Declaration
    protected Language(Language other)
    Parameters
    Type Name Description
    Language other

    Language(CultureInfo)

    Construction from an existing CultureInfo instance.

    Declaration
    public Language(CultureInfo cultureInfo)
    Parameters
    Type Name Description
    System.Globalization.CultureInfo cultureInfo

    Language(String)

    Construction from an ISO abbreviation string.

    See IsoAbbreviation for information about the expected format of the string.

    Declaration
    public Language(string isoAbbreviation)
    Parameters
    Type Name Description
    System.String isoAbbreviation

    see IsoAbbreviation

    Remarks

    This constructor is intended mainly for serialization purposes. Under normal circumstances language objects should be created from CultureInfo objects.

    Properties

    CultureInfo

    The CultureInfo for this language.

    If this language is not supported on this machine an UnsupportedLanguageException is thrown.

    If the ISO abbreviation is null this property returns null.

    Declaration
    public CultureInfo CultureInfo { get; set; }
    Property Value
    Type Description
    System.Globalization.CultureInfo
    Exceptions
    Type Condition
    UnsupportedLanguageException

    DefaultDisplaySettings

    Default settings for how languages should be shown to users.

    Declaration
    public static LanguageDisplaySettings DefaultDisplaySettings { get; }
    Property Value
    Type Description
    LanguageDisplaySettings
    Remarks

    Since this is a static property, changing its values means changing the language display for the entire process.

    If you are interested to know when these properties change, attach a handler to the SettingsChanged event of this object.

    DefaultSpecificCulture

    Default specific language

    Declaration
    [Obsolete("Obsolete, use DefaultSpecificLanguage")]
    public Language DefaultSpecificCulture { get; set; }
    Property Value
    Type Description
    Language

    DefaultSpecificCultureCode

    ISO code of the default specific culture, used mostly in serialization/deserialization

    Declaration
    [Obsolete("Obsolete, use DefaultSpecificLanguageCode")]
    public string DefaultSpecificCultureCode { get; set; }
    Property Value
    Type Description
    System.String

    DefaultSpecificLanguage

    Default specific language language

    Declaration
    public Language DefaultSpecificLanguage { get; }
    Property Value
    Type Description
    Language

    DefaultSpecificLanguageCode

    ISO code of the default specific culture, used mostly in serialization/deserialization

    Declaration
    public string DefaultSpecificLanguageCode { get; }
    Property Value
    Type Description
    System.String

    Direction

    Marks the direction of the language, can be "ltr"-left-to-right or "rtl"-right-to-left

    Declaration
    public string Direction { get; }
    Property Value
    Type Description
    System.String

    DisplayName

    Returns the name of the language as it should be displayed to users.

    Declaration
    public string DisplayName { get; }
    Property Value
    Type Description
    System.String

    EnglishName

    English name of the language;

    Declaration
    public string EnglishName { get; }
    Property Value
    Type Description
    System.String

    Image

    The flag image used for showing this language in the user interface.

    Declaration
    [Obsolete("Obsolete, use GetFlagImage")]
    public Image Image { get; }
    Property Value
    Type Description
    System.Drawing.Image

    IsNeutral

    Marks a neutral language

    Declaration
    public bool IsNeutral { get; }
    Property Value
    Type Description
    System.Boolean

    IsoAbbreviation

    Declaration
    public string IsoAbbreviation { get; set; }
    Property Value
    Type Description
    System.String

    IsSupported

    true if the language is valid and supported on this system.

    Declaration
    public bool IsSupported { get; }
    Property Value
    Type Description
    System.Boolean

    IsValid

    true if an ISO abbreviation has been set for the language.

    Declaration
    public bool IsValid { get; }
    Property Value
    Type Description
    System.Boolean
    Remarks

    This does not mean that the language code is actual a valid code. Since the ISO code could be unsupported on this system there is no easy way to ensure that the code actually is valid. To check if the code is supported on this system test the IsSupported property.

    LanguageCode

    The ISO formatted code corresponding to the Language

    Declaration
    public string LanguageCode { get; }
    Property Value
    Type Description
    System.String

    LdmlData

    Ldml Data for the language

    Declaration
    public string LdmlData { get; }
    Property Value
    Type Description
    System.String

    ParentIsoCode

    OBSOLETE,use ParentLanguageCode

    Declaration
    [Obsolete("Obsolete, use  ParentLanguageCode")]
    public string ParentIsoCode { get; set; }
    Property Value
    Type Description
    System.String

    ParentLanguage

    Parent language

    Declaration
    public Language ParentLanguage { get; }
    Property Value
    Type Description
    Language

    ParentLanguageCode

    ISO code of the parent language

    Declaration
    public string ParentLanguageCode { get; }
    Property Value
    Type Description
    System.String

    RegionalVariants

    List of the regional variants of the language

    Declaration
    public IList<Language> RegionalVariants { get; set; }
    Property Value
    Type Description
    System.Collections.Generic.IList<Language>

    Script

    The language writing script (E.g.:Latn, Cyrl).

    Declaration
    public string Script { get; }
    Property Value
    Type Description
    System.String

    SupportedProducts

    Dictionary of supported products and their respective alternative language codes

    Declaration
    public Dictionary<Product, List<AlternativeLanguageCode>> SupportedProducts { get; }
    Property Value
    Type Description
    System.Collections.Generic.Dictionary<Product, System.Collections.Generic.List<AlternativeLanguageCode>>

    UseBlankAsSentenceSeparator

    Declaration
    public bool UseBlankAsSentenceSeparator { get; }
    Property Value
    Type Description
    System.Boolean
    Exceptions
    Type Condition
    System.ArgumentNullException

    UseBlankAsWordSeparator

    Declaration
    public bool UseBlankAsWordSeparator { get; }
    Property Value
    Type Description
    System.Boolean
    Exceptions
    Type Condition
    System.ArgumentNullException

    UsesCharacterCounts

    true if the language uses character counts rather than word counts.

    Declaration
    public bool UsesCharacterCounts { get; }
    Property Value
    Type Description
    System.Boolean

    Methods

    Clone()

    Create an identical clone of this object.

    Declaration
    public object Clone()
    Returns
    Type Description
    System.Object

    the cloned object

    Equals(Language, Language)

    true if both objects are null or if they represent the same language.

    Declaration
    public static bool Equals(Language language1, Language language2)
    Parameters
    Type Name Description
    Language language1

    the first Language to compare

    Language language2

    the second Language to compare

    Returns
    Type Description
    System.Boolean

    true if both objects are null or if they represent the same language.

    Equals(Object)

    true if the ISO abbreviation for the two languages correspond.

    Declaration
    public override bool Equals(object obj)
    Parameters
    Type Name Description
    System.Object obj

    the object to compare this language to

    Returns
    Type Description
    System.Boolean

    true if the ISO abbreviation for the two languages correspond.

    Overrides
    System.Object.Equals(System.Object)
    Remarks

    The comparison is not case sensitive.

    Equals(String, String)

    true if the two strings are the same, ignoring case.

    Declaration
    public static bool Equals(string isoAbbreviation1, string isoAbbreviation2)
    Parameters
    Type Name Description
    System.String isoAbbreviation1

    the string of the first isoAbbreviation to compare

    System.String isoAbbreviation2

    the string of the second isoAbbreviation to compare

    Returns
    Type Description
    System.Boolean

    true if the two strings are the same, ignoring case.

    GetAllLanguages()

    Returns all languages supported by the system.

    Declaration
    public static Language[] GetAllLanguages()
    Returns
    Type Description
    Language[]

    All languages supported by the system.

    GetAlternativeLanguageCodes(String)

    Gets an alternative language code for the language, based on the product ID

    Declaration
    [Obsolete("Obsolete, use  LanguageRegistryApi.GetAlternativeLanguageCodes")]
    public string[] GetAlternativeLanguageCodes(string productId)
    Parameters
    Type Name Description
    System.String productId
    Returns
    Type Description
    System.String[]

    string that represents the alternative language code for the language and the product given

    GetDisplayName(LanguageFormat, Boolean)

    Returns a name of the language that may be displayed to users.

    Declaration
    public string GetDisplayName(LanguageFormat languageFormat, bool includeCountry)
    Parameters
    Type Name Description
    LanguageFormat languageFormat

    the TeamWorks LanguageFormat

    System.Boolean includeCountry

    whether to include the country in the returned name

    Returns
    Type Description
    System.String

    A name of the language that may be displayed to users.

    GetFlagImage(Boolean, Single, Int32)

    Get an image associated with the language for use in user interfaces.

    Declaration
    public Image GetFlagImage(bool useFlag = true, float scaleFactor = 1F, int baseSize = 24)
    Parameters
    Type Name Description
    System.Boolean useFlag

    if false country flags will not be returned

    System.Single scaleFactor

    Default value of 1 means 96 DPI (100%). For example, 240 DPI (250%) means a scale factor of 2.5.

    System.Int32 baseSize

    The size of the image to be returned is calculated by applying the scale factor to the base size.

    Returns
    Type Description
    System.Drawing.Image

    An image associated with the language for use in user interfaces.

    GetHashCode()

    Hash code based on the ISO abbreviation for the language.

    Declaration
    public override int GetHashCode()
    Returns
    Type Description
    System.Int32

    Hash code based on the ISO abbreviation for the language.

    Overrides
    System.Object.GetHashCode()

    GetImage(Boolean)

    Get an image associated with the language for use in user interfaces.

    Declaration
    [Obsolete("Obsolete, use GetFlagImage")]
    public Image GetImage(bool useFlag)
    Parameters
    Type Name Description
    System.Boolean useFlag

    if false country flags will not be returned

    Returns
    Type Description
    System.Drawing.Image

    An image associated with the language for use in user interfaces.

    IsNullOrInvalid(Language)

    true if the language object is null or not initialized.

    Declaration
    public static bool IsNullOrInvalid(Language language)
    Parameters
    Type Name Description
    Language language

    the Language to test

    Returns
    Type Description
    System.Boolean

    true if the language object is null or not initialized.

    ToString()

    The ISO abbreviation for the language.

    Declaration
    public override string ToString()
    Returns
    Type Description
    System.String

    The ISO abbreviation for the language.

    Overrides
    System.Object.ToString()

    Implements

    System.ICloneable

    On this page

    Back to top Generated by DocFX