Search Results for

    Show / Hide Table of Contents

    Class CultureInfoExtensions

    Utilities related to CultureInfo objects.

    Inheritance
    object
    CultureInfoExtensions
    Inherited Members
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    Namespace: Sdl.LanguagePlatform.Core
    Assembly: Sdl.LanguagePlatform.Core.dll
    Syntax
    public static class CultureInfoExtensions

    Properties

    LegacyLanguageCodeMapping

    Gets a mapping from legacy language codes to .Net language codes. The mapping maps from legacy language codes as they are used by SDLX and Trados Translator's Workbench and related applications to the closest language code used by .Net.

    This is an internal data structure which should not be directly used and not be modified. To look up a legacy code, use GetMappedCultureCodeForLegacyCode(string).

    Declaration
    public static Dictionary<string, string> LegacyLanguageCodeMapping { get; }
    Property Value
    Type Description
    Dictionary<string, string>

    Methods

    AreCompatible(CultureInfo, CultureInfo)

    Checks whether two cultures (languages) are compatible. Two cultures are compatible if they denote the same language which means they have to be identical or their closest region-neutral parents are identical.

    Declaration
    [Obsolete("Use AreCompatibleCodesAsync")]
    public static bool AreCompatible(CultureInfo c1, CultureInfo c2)
    Parameters
    Type Name Description
    CultureInfo c1
    CultureInfo c2
    Returns
    Type Description
    bool

    AreCompatibleCodesAsync(CultureCode, CultureCode, ICultureMetadataManager)

    Checks whether two cultures (languages) are compatible. Two cultures are compatible if they denote the same language which means they have to be identical or their closest region-neutral parents are identical.

    Declaration
    public static Task<bool> AreCompatibleCodesAsync(CultureCode c1, CultureCode c2, ICultureMetadataManager cultureMetadataManager)
    Parameters
    Type Name Description
    CultureCode c1
    CultureCode c2
    ICultureMetadataManager cultureMetadataManager
    Returns
    Type Description
    Task<bool>

    GetCultureInfo(int)

    Returns the culture which corresponds to the specified LCID. If the LCID is unknown or invalid, an exception is thrown. Note that this will also be the case for custom cultures, which seem to always get the same LCID (4096).

    Declaration
    [Obsolete("Use GetRegistryCultureInfoAsync")]
    public static CultureInfo GetCultureInfo(int lcid)
    Parameters
    Type Name Description
    int lcid

    The locale identifier (lcid)

    Returns
    Type Description
    CultureInfo

    A CultureInfo object, or throws for unknown LCIDs.

    GetCultureInfo(int, bool)

    Returns the culture which corresponds to the specified locale, which may be a legacy LCID used internally by SDLX or Trados Translator's Workbench.

    Declaration
    [Obsolete("Use GetRegistryCultureInfoAsync")]
    public static CultureInfo GetCultureInfo(int lcid, bool returnNullForUnknowns)
    Parameters
    Type Name Description
    int lcid

    The locale identifier (lcid)

    bool returnNullForUnknowns

    If true, null is returned for unknown languages. Otherwise, an exception is thrown. This will also be the case if the lcid represets a custom culture (in most cases, the lcid will be 4096 in this case).

    Returns
    Type Description
    CultureInfo

    A CultureInfo object, or null if returnNullForUnknowns is true.

    GetCultureInfo(string)

    Similar to GetCultureInfo(string), but covers culture names (<language-code>-<region-code>) which are used by SDLX and Trados Translator's Workbench, but have a different code in .Net.

    Use this method to transparently map language codes (current and legacy ones) to cultures, for example when processing TTX, ITD, or TMX.

    Declaration
    [Obsolete("Use GetRegistryCultureInfoAsync")]
    public static CultureInfo GetCultureInfo(string name)
    Parameters
    Type Name Description
    string name

    The culture code

    Returns
    Type Description
    CultureInfo

    A CultureInfo object, using appropriate fallbacks for backwards compatibility. Throws an exeption if neither the fallback heuristics nor .Net can resolve the culture name.

    Remarks

    To avoid an exception to be thrown, and to get null for unknown culture codes, use GetCultureInfo(string, bool).

    GetCultureInfo(string, bool)

    Similar to GetCultureInfo(string), but covers culture names (<language-code>-<region-code>) which are used by SDLX and Trados Translator's Workbench, but have a different code in .Net.

    Use this method to transparently map language codes (current and legacy ones) to cultures, for example when processing TTX, ITD, or TMX.

    Declaration
    [Obsolete("Use GetRegistryCultureInfoAsync")]
    public static CultureInfo GetCultureInfo(string name, bool returnNullForUnknowns)
    Parameters
    Type Name Description
    string name

    The culture code

    bool returnNullForUnknowns

    If true, null is returned for unknown culture codes. If false, an exception is thrown if the culture code cannot be resolved.

    Returns
    Type Description
    CultureInfo

    A CultureInfo object, using appropriate fallbacks for backwards compatibility, or null if the culture code cannot be resolved and returnNullForUnknowns is true.

    GetLanguageGroupID(CultureInfo)

    Returns the LanguageGroupID associated with the specified culture.

    Declaration
    [Obsolete("Use GetLanguageGroupNameAsync")]
    public static CultureInfoExtensions.LanguageGroupID GetLanguageGroupID(CultureInfo culture)
    Parameters
    Type Name Description
    CultureInfo culture
    Returns
    Type Description
    CultureInfoExtensions.LanguageGroupID

    GetLanguageGroupName(CultureInfo)

    Returns the name of the language group for the specified culture as a string.

    Declaration
    [Obsolete("Use GetLanguageGroupNameAsync")]
    public static string GetLanguageGroupName(CultureInfo culture)
    Parameters
    Type Name Description
    CultureInfo culture

    The culture (may not be null)

    Returns
    Type Description
    string

    The name of the language group the culture belongs to, or null if the group is unknown.

    GetLanguageGroupNameAsync(string, ICultureMetadataManager)

    Returns the name of the language group for the specified culture, or for a parent culture if not defined for this culture, or null if unknown

    Declaration
    public static Task<string> GetLanguageGroupNameAsync(string cultureName, ICultureMetadataManager cultureMetadataManager)
    Parameters
    Type Name Description
    string cultureName
    ICultureMetadataManager cultureMetadataManager
    Returns
    Type Description
    Task<string>

    GetLeadingClitics(CultureCode)

    Returns a case-sensitive string hash set containing the leading separable clitics for the provided culture, or null if none are defined.

    Declaration
    public static HashSet<string> GetLeadingClitics(CultureCode culture)
    Parameters
    Type Name Description
    CultureCode culture
    Returns
    Type Description
    HashSet<string>

    GetMappedCultureCodeForLegacyCode(string)

    Assumes the passed culture code is a legacy code and returns the mapped equivalent. null is returned if no mapping exists (which means that the code is not a legacy code or no mapping is required or yet specified).

    Declaration
    public static string GetMappedCultureCodeForLegacyCode(string legacyCode)
    Parameters
    Type Name Description
    string legacyCode
    Returns
    Type Description
    string

    GetRegionNeutralCulture(CultureInfo)

    Computes and returns the region-neutral parent culture of the input culture. If the input culture is already neutral, it is returned. Otherwise, the parent culture hierarchy is traversed until a region-neutral culture is found.

    Declaration
    [Obsolete("Use GetRegionNeutralCultureCodeAsync")]
    public static CultureInfo GetRegionNeutralCulture(CultureInfo culture)
    Parameters
    Type Name Description
    CultureInfo culture

    The input culture

    Returns
    Type Description
    CultureInfo

    The region-neutral parent culture of the input culture

    Remarks

    A region-neutral culture is not necessarily one "without dashes". For example, the region-neutral parent culture of zh-CN (Chinese, PRC) is zh-CHS or zh-Hans (Simplified Chinese). The exact result may depend on the operating system version and the .Net version.

    GetRegionNeutralCultureCodeAsync(CultureCode, ICultureMetadataManager)

    Returns the region-neutral parent culture of the input culture. If the input culture is already neutral, it is returned. Otherwise, the parent culture hierarchy is traversed until a region-neutral culture is found.

    Declaration
    public static Task<CultureCode> GetRegionNeutralCultureCodeAsync(CultureCode culture, ICultureMetadataManager cultureMetadataManager)
    Parameters
    Type Name Description
    CultureCode culture

    The input culture

    ICultureMetadataManager cultureMetadataManager
    Returns
    Type Description
    Task<CultureCode>

    The region-neutral parent culture of the input culture

    Remarks

    A region-neutral culture is not necessarily one "without dashes". For example, the region-neutral parent culture of zh-CN (Chinese, PRC) is zh-CHS or zh-Hans (Simplified Chinese).

    GetRegionQualifiedCulture(CultureInfo)

    Heuristically computes and returns the region-specified ("default") culture for a given language. If the input culture is not neutral (i.e. it is region-specific), it is returned. Otherwise the method will find the region-qualified culture which most likely represents the culture's default/major region.

    Declaration
    [Obsolete("Use GetRegionQualifiedCultureAsync")]
    public static CultureInfo GetRegionQualifiedCulture(CultureInfo culture)
    Parameters
    Type Name Description
    CultureInfo culture

    The input culture

    Returns
    Type Description
    CultureInfo

    The input parameter, if it's a region-qualified/non-neutral culture, or the default region-qualified culture otheriwise.

    GetRegionQualifiedCulture(string)

    Heuristically computes and returns the region-specified ("default") culture code for a given language code. If the input culture is not neutral or does not have a region-qualified equivalent, null is returned.

    Declaration
    [Obsolete("Use GetRegionQualifiedCultureAsync")]
    public static string GetRegionQualifiedCulture(string cultureCode)
    Parameters
    Type Name Description
    string cultureCode
    Returns
    Type Description
    string

    GetRegionQualifiedCultureAsync(CultureCode, ICultureMetadataManager)

    Rturns the region-specified ("default") culture code for a given language code. If the input culture is not neutral, null is returned.

    Declaration
    public static Task<CultureCode> GetRegionQualifiedCultureAsync(CultureCode cultureCode, ICultureMetadataManager cultureMetadataManager)
    Parameters
    Type Name Description
    CultureCode cultureCode
    ICultureMetadataManager cultureMetadataManager
    Returns
    Type Description
    Task<CultureCode>

    GetRegistryCultureInfoAsync(CultureCode, bool, ICultureMetadataManager)

    Declaration
    public static Task<CultureInfo> GetRegistryCultureInfoAsync(CultureCode cultureCode, bool returnNullForUnknowns, ICultureMetadataManager cultureMetadataManager)
    Parameters
    Type Name Description
    CultureCode cultureCode
    bool returnNullForUnknowns
    ICultureMetadataManager cultureMetadataManager
    Returns
    Type Description
    Task<CultureInfo>

    GetTrailingClitics(CultureInfo)

    Returns a case-sensitive string hash set containing the trailing separable clitics for the provided culture, or null if none are defined.

    Declaration
    public static HashSet<string> GetTrailingClitics(CultureInfo culture)
    Parameters
    Type Name Description
    CultureInfo culture
    Returns
    Type Description
    HashSet<string>

    IsRomanceLanguage(CultureCode)

    Determines whether the specified culture info is any of the romance languages: French, Spanish, Portuguese, Italian, Romanian, Galician or Catalan.

    Declaration
    public static bool IsRomanceLanguage(CultureCode culture)
    Parameters
    Type Name Description
    CultureCode culture

    The culture info.

    Returns
    Type Description
    bool

    true if culture is any of the romance languages, otherwise false.

    UseBlankAsSentenceSeparator(CultureCode)

    Determines whether the specified culture uses blanks as sentence separators. This is currently only true for Thai.

    Declaration
    public static bool UseBlankAsSentenceSeparator(CultureCode culture)
    Parameters
    Type Name Description
    CultureCode culture

    The culture to test.

    Returns
    Type Description
    bool

    true iff the language associated with the culture uses blanks as sentence separators.

    UseBlankAsWordSeparator(CultureCode)

    Determines whether the specified culture uses blanks as word separators. This is true for all cultures except those based on Japanese, Thai, or Chinese.

    Declaration
    public static bool UseBlankAsWordSeparator(CultureCode culture)
    Parameters
    Type Name Description
    CultureCode culture

    The culture to test.

    Returns
    Type Description
    bool

    true iff the language associated with the culture uses blanks as word separators.

    UseFullWidth(CultureCode)

    returns true for CJK cultures

    Declaration
    public static bool UseFullWidth(CultureCode culture)
    Parameters
    Type Name Description
    CultureCode culture
    Returns
    Type Description
    bool

    UsesClitics(CultureCode)

    Determines whether the specified culture uses clitics (English and the romance languages).

    Declaration
    public static bool UsesClitics(CultureCode culture)
    Parameters
    Type Name Description
    CultureCode culture

    The culture.

    Returns
    Type Description
    bool

    true if culture contains clitics, otherwise false.

    UsesDefaultDigits(CultureInfo)

    Determines whether the specified culture uses the standard default digits.

    Declaration
    public static bool UsesDefaultDigits(CultureInfo culture)
    Parameters
    Type Name Description
    CultureInfo culture

    The culture, which must not be null or a neutral culture

    Returns
    Type Description
    bool

    true if the culture uses the default digits (0-9), and false otherwise.

    UsesStandardNumberGrouping(CultureInfo)

    Determines whether the provided culture uses standard three-digit grouping for number formatting.

    Declaration
    public static bool UsesStandardNumberGrouping(CultureInfo culture)
    Parameters
    Type Name Description
    CultureInfo culture

    The culture, which must not be null or a neutral culture

    Returns
    Type Description
    bool

    true if the culture uses standard three-digit grouping, and false otherwise

    In this article
    • Properties
      • LegacyLanguageCodeMapping
    • Methods
      • AreCompatible(CultureInfo, CultureInfo)
      • AreCompatibleCodesAsync(CultureCode, CultureCode, ICultureMetadataManager)
      • GetCultureInfo(int)
      • GetCultureInfo(int, bool)
      • GetCultureInfo(string)
      • GetCultureInfo(string, bool)
      • GetLanguageGroupID(CultureInfo)
      • GetLanguageGroupName(CultureInfo)
      • GetLanguageGroupNameAsync(string, ICultureMetadataManager)
      • GetLeadingClitics(CultureCode)
      • GetMappedCultureCodeForLegacyCode(string)
      • GetRegionNeutralCulture(CultureInfo)
      • GetRegionNeutralCultureCodeAsync(CultureCode, ICultureMetadataManager)
      • GetRegionQualifiedCulture(CultureInfo)
      • GetRegionQualifiedCulture(string)
      • GetRegionQualifiedCultureAsync(CultureCode, ICultureMetadataManager)
      • GetRegistryCultureInfoAsync(CultureCode, bool, ICultureMetadataManager)
      • GetTrailingClitics(CultureInfo)
      • IsRomanceLanguage(CultureCode)
      • UseBlankAsSentenceSeparator(CultureCode)
      • UseBlankAsWordSeparator(CultureCode)
      • UseFullWidth(CultureCode)
      • UsesClitics(CultureCode)
      • UsesDefaultDigits(CultureInfo)
      • UsesStandardNumberGrouping(CultureInfo)
    Back to top Generated by DocFX