Table of Contents

Codeunit Language

ID 43
Namespace: System.Globalization

Management codeunit that exposes various functions to work with languages.

Properties

Name Value
Access Public
SingleInstance True
InherentEntitlements X
InherentPermissions X

Methods

GetUserLanguageCode

Gets the current user's language code. The function emits the event. To change the language code returned from this function, subscribe for this event and change the passed language code.

procedure GetUserLanguageCode(): Code[10]

Returns

Type Description
Code[10]

The language code of the user's language, for example 'ENU' for 'English (United States)'

GetUserLanguageTag

Gets the current user's language tag.

procedure GetUserLanguageTag(): Text[80]

Returns

Type Description
Text[80]

The language tag of the user's language, for example 'en-US' for 'English (United States)'

GetLanguageIdOrDefault

Gets the language ID based on its code. Or defaults to the current user language.

procedure GetLanguageIdOrDefault(LanguageCode: Code[10]): Integer

Parameters

Name Type Description
LanguageCode Code[10]

The code of the language

Returns

Type Description
Integer

The ID for the language code that was provided for this function. If no ID is found for the language code, then it returns the ID of the current user's language.

GetFormatRegionOrDefault

Returns format region for a given language. If format region is provided it itself will be returned. If format region is empty the region is taken from UserSessionSettings. If no valid tag is found, the default 'en-US' tag is returned.

procedure GetFormatRegionOrDefault(FormatRegion: Text[80]): Text[80]

Parameters

Name Type Description
FormatRegion Text[80]

The variable for the format region id.

Returns

Type Description
Text[80]

The ID for the format region that was found.

GetLanguageId

Gets the language ID based on its code.

procedure GetLanguageId(LanguageCode: Code[10]): Integer

Parameters

Name Type Description
LanguageCode Code[10]

The code of the language

Returns

Type Description
Integer

The ID for the language code that was provided for this function. If no ID is found for the language code, then it returns 0.

SetOverrideLanguageId

Overrides the language ID returned by the GetLanguageIdOrDefault function.

procedure SetOverrideLanguageId(LanguageId: Integer)

Parameters

Name Type Description
LanguageId Integer

The ID of the language to use. This must be a valid language ID.

Remarks

This override will be reset after it's used once in the GetLanguageIdOrDefault function. To keep the override throughout the application, use SetOverrideLanguageId(LanguageId: Integer; ResetOverride: Boolean) method.

SetOverrideLanguageId

Overrides the language ID returned by the GetLanguageIdOrDefault function.

procedure SetOverrideLanguageId(LanguageId: Integer, ResetOverride: Boolean)

Parameters

Name Type Description
LanguageId Integer

The ID of the language to use. This must be a valid language ID.

ResetOverride Boolean

A boolean value indicating whether the override should be reset after use in the GetLanguageIdOrDefault function. If set to true, the override is reset after it's used once. If set to false, the override remains until it's manually reset or the session is restarted.

SetOverrideFormatRegion

Overrides the format region returned by the GetFormatRegionOrDefault function.

procedure SetOverrideFormatRegion(FormatRegion: Text[80])

Parameters

Name Type Description
FormatRegion Text[80]

The region to use for formatting purposes. This must be a valid region code.

Remarks

This override will be reset after it's used once in the GetFormatRegionOrDefault function. To keep the override throughout the session, use SetOverrideFormatRegion(FormatRegion: Text[80]; ResetOverride: Boolean) method.

SetOverrideFormatRegion

Overrides the format region returned by the GetFormatRegionOrDefault function.

procedure SetOverrideFormatRegion(FormatRegion: Text[80], ResetOverride: Boolean)

Parameters

Name Type Description
FormatRegion Text[80]

The region to use for formatting purposes. This must be a valid region code.

ResetOverride Boolean

A boolean value indicating whether the override should be reset after use in the GetFormatRegionOrDefault function. If set to true, the override is reset after it's used once. If set to false, the override remains until it's manually reset or the session is restarted.

GetLanguageCode

Gets the code for a language based on its ID.

procedure GetLanguageCode(LanguageId: Integer): Code[10]

Parameters

Name Type Description
LanguageId Integer

The ID of the language.

Returns

Type Description
Code[10]

The code of the language that corresponds to the ID, or an empty code if the language with the specified ID does not exist.

GetWindowsLanguageName

Gets the name of a language based on the language code.

procedure GetWindowsLanguageName(LanguageCode: Code[10]): Text

Parameters

Name Type Description
LanguageCode Code[10]

The code of the language.

Returns

Type Description
Text

The name of the language corresponding to the code or empty string, if language with the specified code does not exist

GetWindowsLanguageName

Gets the name of a windows language based on its ID.

procedure GetWindowsLanguageName(LanguageId: Integer): Text

Parameters

Name Type Description
LanguageId Integer

The ID of the language.

Returns

Type Description
Text

The name of the language that corresponds to the ID, or an empty string if a language with the specified ID does not exist.

GetApplicationLanguages

procedure GetApplicationLanguages(TempLanguage: __MissingTypeSymbol__)

Parameters

Name Type Description
TempLanguage __MissingTypeSymbol__

GetDefaultApplicationLanguageId

Gets the default application language ID.

procedure GetDefaultApplicationLanguageId(): Integer

Returns

Type Description
Integer

The ID of the default language for the application.

ToDefaultLanguage

Formats the provided value in default language.

procedure ToDefaultLanguage(ValueVariant: Variant): Text

Parameters

Name Type Description
ValueVariant Variant

The provided value to be returned in default language.

Returns

Type Description
Text

The value in default language.

ValidateApplicationLanguageId

Checks whether the provided language is a valid application language. If it isn't, the function displays an error.

procedure ValidateApplicationLanguageId(LanguageId: Integer)

Parameters

Name Type Description
LanguageId Integer

The ID of the language to validate.

ValidateWindowsLanguageId

Checks whether the provided language exists. If it doesn't, the function displays an error.

procedure ValidateWindowsLanguageId(LanguageId: Integer)

Parameters

Name Type Description
LanguageId Integer

The ID of the language to validate.

LookupApplicationLanguageId

Opens a list of the languages that are available for the application so that the user can choose a language.

procedure LookupApplicationLanguageId(var LanguageId: Integer)

Parameters

Name Type Description
LanguageId Integer

Exit parameter that holds the chosen language ID.

LookupWindowsLanguageId

Opens a list of languages that are available for the Windows version.

procedure LookupWindowsLanguageId(var LanguageId: Integer)

Parameters

Name Type Description
LanguageId Integer

Exit parameter that holds the chosen language ID.

LookupLanguageCode

Opens a list of the languages that are available for the application so that the user can choose a language.

procedure LookupLanguageCode(var LanguageCode: Code[10])

Parameters

Name Type Description
LanguageCode Code[10]

Exit parameter that holds the chosen language code.

GetParentLanguageId

Gets the parent language ID based on Windows Culture Info.

procedure GetParentLanguageId(LanguageId: Integer): Integer

Parameters

Name Type Description
LanguageId Integer

Exit parameter that holds the chosen language ID.

Returns

Type Description
Integer

The ID of the parent language

SetPreferredLanguageID

Sets the preferred language for the provided user.

procedure SetPreferredLanguageID(UserSecID: Guid, NewLanguageID: Integer)

Parameters

Name Type Description
UserSecID Guid

The user security ID for the user for whom the preferred language is changed.

NewLanguageID Integer

The new preferred language for the user.

GetTwoLetterISOLanguageName

Retrieves the two-letter ISO language name for the specified language ID.

procedure GetTwoLetterISOLanguageName(LanguageID: Integer): Text[2]

Parameters

Name Type Description
LanguageID Integer

The language ID.

Returns

Type Description
Text[2]

The two-letter ISO language name. For example, "en" or "es"

GetLanguageIdFromCultureName

Retrieves the language ID for the specified culture name.

procedure GetLanguageIdFromCultureName(CultureName: Text): Integer

Parameters

Name Type Description
CultureName Text

The Culture name.

Returns

Type Description
Integer

The language ID. See https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/a29e5c28-9fb9-4c49-8e43-4b9b8e733a05.

Examples

Language.GetLanguageIdFromLanguageName('en-US');
Language.GetLanguageIdFromLanguageName('en');

GetCultureName

Retrieves the culture name for the specified language ID.

procedure GetCultureName(LanguageID: Integer): Text

Parameters

Name Type Description
LanguageID Integer

The language ID. See https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-adts/a29e5c28-9fb9-4c49-8e43-4b9b8e733a05.

Returns

Type Description
Text

The culture name. For example, 'en-US'.

GetCurrentCultureName

Retrieves the current culture name for the session.

procedure GetCurrentCultureName(): Text

Returns

Type Description
Text

The culture name. For example, 'en-US'.

Events

OnGetUserLanguageCode

Integration event, emitted from . Subscribe to this event to change the default behavior by changing the provided parameter(s).

[IntegrationEvent(False,False)]
internal procedure OnGetUserLanguageCode(var UserLanguageCode: Code[10], var Handled: Boolean)

Parameters

Name Type Description
UserLanguageCode Code[10]

Exit parameter that holds the user language code.

Handled Boolean

To change the default behavior of the function that emits the event, set this parameter to true.

See also