Search Results for

    Show / Hide Table of Contents

    Class CultureInfoExtensions

    Utilities related to System.Globalization.CultureInfo objects.

    Inheritance
    System.Object
    CultureInfoExtensions
    Inherited Members
    System.Object.ToString()
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.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
    System.Collections.Generic.Dictionary<System.String, System.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
    public static bool AreCompatible(CultureInfo c1, CultureInfo c2)
    Parameters
    Type Name Description
    System.Globalization.CultureInfo c1
    System.Globalization.CultureInfo c2
    Returns
    Type Description
    System.Boolean

    GetCultureInfo(Int32)

    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
    public static CultureInfo GetCultureInfo(int lcid)
    Parameters
    Type Name Description
    System.Int32 lcid

    The locale identifier (lcid)

    Returns
    Type Description
    System.Globalization.CultureInfo

    A CultureInfo object, or throws for unknown LCIDs.

    GetCultureInfo(Int32, Boolean)

    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
    public static CultureInfo GetCultureInfo(int lcid, bool returnNullForUnknowns)
    Parameters
    Type Name Description
    System.Int32 lcid

    The locale identifier (lcid)

    System.Boolean 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
    System.Globalization.CultureInfo

    A System.Globalization.CultureInfo object, or null if returnNullForUnknowns is true.

    GetCultureInfo(String)

    Similar to System.Globalization.CultureInfo.GetCultureInfo(System.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
    public static CultureInfo GetCultureInfo(string name)
    Parameters
    Type Name Description
    System.String name

    The culture code

    Returns
    Type Description
    System.Globalization.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, Boolean).

    GetCultureInfo(String, Boolean)

    Similar to System.Globalization.CultureInfo.GetCultureInfo(System.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
    public static CultureInfo GetCultureInfo(string name, bool returnNullForUnknowns)
    Parameters
    Type Name Description
    System.String name

    The culture code

    System.Boolean 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
    System.Globalization.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 CultureInfoExtensions.LanguageGroupID associated with the specified culture.

    Declaration
    public static CultureInfoExtensions.LanguageGroupID GetLanguageGroupID(CultureInfo culture)
    Parameters
    Type Name Description
    System.Globalization.CultureInfo culture
    Returns
    Type Description
    CultureInfoExtensions.LanguageGroupID

    GetLanguageGroupName(CultureInfo)

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

    Declaration
    public static string GetLanguageGroupName(CultureInfo culture)
    Parameters
    Type Name Description
    System.Globalization.CultureInfo culture

    The culture (may not be null)

    Returns
    Type Description
    System.String

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

    GetLeadingClitics(CultureInfo)

    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(CultureInfo culture)
    Parameters
    Type Name Description
    System.Globalization.CultureInfo culture
    Returns
    Type Description
    System.Collections.Generic.HashSet<System.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
    System.String legacyCode
    Returns
    Type Description
    System.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
    public static CultureInfo GetRegionNeutralCulture(CultureInfo culture)
    Parameters
    Type Name Description
    System.Globalization.CultureInfo culture

    The input culture

    Returns
    Type Description
    System.Globalization.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.

    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
    public static CultureInfo GetRegionQualifiedCulture(CultureInfo culture)
    Parameters
    Type Name Description
    System.Globalization.CultureInfo culture

    The input culture

    Returns
    Type Description
    System.Globalization.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
    public static string GetRegionQualifiedCulture(string cultureCode)
    Parameters
    Type Name Description
    System.String cultureCode
    Returns
    Type Description
    System.String

    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
    System.Globalization.CultureInfo culture
    Returns
    Type Description
    System.Collections.Generic.HashSet<System.String>

    IsRomanceLanguage(CultureInfo)

    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(CultureInfo culture)
    Parameters
    Type Name Description
    System.Globalization.CultureInfo culture

    The culture info.

    Returns
    Type Description
    System.Boolean

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

    UseBlankAsSentenceSeparator(CultureInfo)

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

    Declaration
    public static bool UseBlankAsSentenceSeparator(CultureInfo culture)
    Parameters
    Type Name Description
    System.Globalization.CultureInfo culture

    The culture to test.

    Returns
    Type Description
    System.Boolean

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

    UseBlankAsWordSeparator(CultureInfo)

    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(CultureInfo culture)
    Parameters
    Type Name Description
    System.Globalization.CultureInfo culture

    The culture to test.

    Returns
    Type Description
    System.Boolean

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

    UseFullWidth(CultureInfo)

    returns true for CJK cultures

    Declaration
    public static bool UseFullWidth(CultureInfo culture)
    Parameters
    Type Name Description
    System.Globalization.CultureInfo culture
    Returns
    Type Description
    System.Boolean

    UsesClitics(CultureInfo)

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

    Declaration
    public static bool UsesClitics(CultureInfo culture)
    Parameters
    Type Name Description
    System.Globalization.CultureInfo culture

    The culture.

    Returns
    Type Description
    System.Boolean

    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
    System.Globalization.CultureInfo culture

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

    Returns
    Type Description
    System.Boolean

    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
    System.Globalization.CultureInfo culture

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

    Returns
    Type Description
    System.Boolean

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

    On this page

    • Properties
      • LegacyLanguageCodeMapping
    • Methods
      • AreCompatible(CultureInfo, CultureInfo)
      • GetCultureInfo(Int32)
      • GetCultureInfo(Int32, Boolean)
      • GetCultureInfo(String)
      • GetCultureInfo(String, Boolean)
      • GetLanguageGroupID(CultureInfo)
      • GetLanguageGroupName(CultureInfo)
      • GetLeadingClitics(CultureInfo)
      • GetMappedCultureCodeForLegacyCode(String)
      • GetRegionNeutralCulture(CultureInfo)
      • GetRegionQualifiedCulture(CultureInfo)
      • GetRegionQualifiedCulture(String)
      • GetTrailingClitics(CultureInfo)
      • IsRomanceLanguage(CultureInfo)
      • UseBlankAsSentenceSeparator(CultureInfo)
      • UseBlankAsWordSeparator(CultureInfo)
      • UseFullWidth(CultureInfo)
      • UsesClitics(CultureInfo)
      • UsesDefaultDigits(CultureInfo)
      • UsesStandardNumberGrouping(CultureInfo)
    Back to top Generated by DocFX