Official Content

Searches in the Language object sent as parameter (or in the current Language object if that parameter is omitted) for a given text and returns the corresponding translation.

Syntax

GetMessageText(MessageCode, [LanguageObjectName)

Where:

MessageCode
    Is the text for which you want to find its translation.

LanguageObjectName
    Is the name of the Language object in which you want to look for a translation.

Scope

Objects: ProcedureTransactionWeb PanelPanelData Provider
Generators: .NET, .NET Framework, JavaApple, Android, Angular

Sample

Consider a Web Panel object that contains the Text control in its Web Layout.

The Web Panel Start event contains a code line as follows:

Event Start
   Text.Caption = GetMessageText('Test about the GetMessageText function', 'Spanish')
Endevent

Look at the Spanish Language object

GetMessageText function translation sample

The Localized text for the phrase is entered.

So, when pressing F5 and executing the Web Panel, the Text Caption is shown as follows:

GetMessageText function translation in runtime
 

Note: No errors are returned by this function. If the MessageCode is not found in the current Language, the MessageCode is returned. It is, therefore, a good design method to use full text message codes that can be used as message texts.

Runtime translation considerations

Make sure to place an exclamation mark (!) in the GetMessageText function for both parameters when the Translation type property is set to run-time.

Text.Caption = GetMessageText(!'Test about the GetMessageText function', !'Spanish')

You will need to reference the desired texts in the code too, so the application metadata will include the desired translations. The correct code with run-time translation is:

&sample = 'Test about the GetMessageText function' // needed so the text is added to the application metadata
Text.Caption = GetMessageText(!'Test about the GetMessageText function', !'Spanish')

 

Note that at specification-time, the GetMessageText function is used (injected by the specifier) so that in run-time literals with no exclamation mark appear translated. This may lead to performance issues because GetMessageText cannot be evaluated by the DBMS or to specification warnings or errors like the following:

spc0075 Operand getmessagetext( "M") does not match the data type of &var in the IN comparison. (Events, Line: 2)

Last update: February 2024 | © GeneXus. All rights reserved. GeneXus Powered by Globant