Skip to Content
Author's profile photo Tobias Kuhn

An easy way to message translation

Problem

With the current possibilities in the SAP Cloud Applications Studio it is not possible to translate in BODL defined messages.

Example

message YOUR_MESSAGE text "some message text";

The content of the message can be raised to the UI and also in to the run logs but not directly translated with the translation mechanics build on the BO.

 

Solution

To solve the problem you can generate an generic message with no direct content but with an placeholder for every text you want to enter.

message TEXTMESSAGE text "&1" :LANGUAGEINDEPENDENT_EXTENDED_Text;

Than later in the ABSL code on the place where you want to raise the message you set the text you want.

raise TEXTMESSAGE.Create("E", "some message text");

But this version has the downside, that you have to control the message texts and the translation with your ABSL code.

The better way is to use an translatable object in the studio to be able to raise the message according to the content of this.

To achieve this, we use an Business Configuration Object (BCO) which is configured with only an ID and an Description field and based on that BCO an Business Configuration Set  (BCC) to store the messages or other texts as key value pairs in this.

In this texts you can place also placeholders which you want to replace during run time with dynamic data (e.g. IDs).

To translate the messages you can use the context menu on the BCC and download the source file (XLIFF) simply within the studio and also upload the translated file again via the context menu. For the translation I recommend to use an special translation software like Virtaal.

To raise this messages you can use this simple code.

var message :MESSAGESCode;
message.content = "10";
var messageText = message.GetDescription();
raise TEXTMESSAGE.Create("E", messageText);

 

To reduce the code for every message you can encapsulate this code you can put the code for the description loading in an reuse library, so that you have only inline code like the following.

raise TEXTMESSAGE.Create("E", YourReuse.GetMessage("10"));

 

 

 

 

 

Assigned Tags

      4 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Why use a BCO and not just a CodeList?

       

      Only Benefit I can think of is the end user could change messages. (which I typically do not what them to do)

      Author's profile photo Tobias Kuhn
      Tobias Kuhn
      Blog Post Author

      As you already mentioned one reason is that customers could change messages.

      The other reason is linked to this topic that the customer can change and add the translation for the messages.

       

      If this is not needed or planed in the future code lists would also work fine.

       

      Author's profile photo Dominik Gassl
      Dominik Gassl

      Well, we actually use the following code, since we usually need to support English and German:

       

      var messageText = "Please enter ...";
      
      if(Context.GetCurrentUserLanguage().ToString() == "DE") {
      
       messageText = "Bitte geben Sie...";
      
      } 
      
      raise MsgInfo.Create("E", msgText);
      Author's profile photo Tobias Kuhn
      Tobias Kuhn
      Blog Post Author

      This way is also working but has the downside of managing the translation for every message in the absl scripts where the Message is raised. Also one problem could be that every translation has to be implemented in the absl code and can not be added by uploading on translation file.