how can i translate English error message into Korean?

BoHyun Jung
Mega Sage

BoHyunJung_0-1693913375775.png

 

This Error Message is

-> gs.addErrorMessage('Check \'Design File\' and \'Design File Recipients\'');

 

I want to translate 'Design File', 'Design File Recipients' into Korean words(설계서, 설계서 수신자).

 

1 ACCEPTED SOLUTION

Hello @BoHyun Jung 

 

To dynamically change the error message based on the language preference in ServiceNow, you can use translation messages and localization features provided by the platform. Here's how you can do it:

  1. Create Translation Messages:

    In ServiceNow, you can create translation messages for different languages. These messages will contain the translated versions of your error message.

    • Go to System Definition > Messages in the application navigator.
    • Create a new message for your error message, for example, "error.design_file_recipients".
    • Enter the English text as "Check 'Design File' and 'Design File Recipients'" and the Korean translation as "설계서와 설계서 수신자를 확인하세요."
  2. Use GlideUser to Get Language Preference:

    You can use the GlideUser object to retrieve the user's language preference

      3. Display the Error Message Based on Language Preference:

          Depending on the user's language preference, you can retrieve the appropriate translation                        message and use it in your error message

 

Write BR: 

(function executeRule(current, previous /* previous */) {
    // Get the user's language preference
    var user = gs.getUser();
    var userLanguage = user.getPreference('glide.sys.language', 'en'); // Default to English if preference not set

    // Define the base error message key
    var errorMessageKey = 'error.design_file_recipients';

    // Append '_ko' to the key for Korean translation if user's language is Korean
    if (userLanguage === 'ko') {
        errorMessageKey += '_ko';
    }

    // Get the translated error message
    var translatedErrorMessage = gs.getMessage(errorMessageKey);

    // Set the translated error message
    current.setAbortAction(true); // Prevent the default error message
    current.setReturn(translatedErrorMessage);

})(current, previous);

 4.Configure Supported Languages:

Ensure that you have configured the supported languages in your ServiceNow instance. You can do this in System Properties > System by adding languages to the "Supported Languages" list.

By following these steps, your error message will be dynamically translated based on the user's language preference, and it will display the correct translation (English or Korean) accordingly. Make sure you have created translation messages for all the languages you want to support in your instance.

 

Please Mark my Solution as Accept and Give me thumbs up, if you find it Helpful.

 

Thanks & Regards,

Kartik Magadum

View solution in original post

4 REPLIES 4

Shruti Khaire
Kilo Sage

Hello @BoHyun Jung,

 

I'm not clear on your requirement can you please explain in breif do you want 'Design File', 'Design File Recipients' only this text to be translated or the whole error message so likewise i'll be able to help.

Thank you!

Kartik Magadum
Kilo Sage

Hello @BoHyun Jung 

 

To translate the text 'Design File' and 'Design File Recipients' into Korean within a ServiceNow script, you can use the following code:

var gs = gs || {};
gs.addErrorMessage('Check \'설계서\', \'설계서 수신자\'');

This code sets the error message with the translated Korean text '설계서' for 'Design File' and '설계서 수신자' for 'Design File Recipients'. Make sure to include this code in the appropriate place within your ServiceNow script where you want the error message to be displayed in Korean. 

 

Please Mark my Solution as Accept and Give me thumbs up, if you find it Helpful.

 

Thanks & Regards,

Kartik Magadum

My question is that it should come out differently when the language of Preferences is English and Korean.

 

It must be dynamically changed for each language you set.

Hello @BoHyun Jung 

 

To dynamically change the error message based on the language preference in ServiceNow, you can use translation messages and localization features provided by the platform. Here's how you can do it:

  1. Create Translation Messages:

    In ServiceNow, you can create translation messages for different languages. These messages will contain the translated versions of your error message.

    • Go to System Definition > Messages in the application navigator.
    • Create a new message for your error message, for example, "error.design_file_recipients".
    • Enter the English text as "Check 'Design File' and 'Design File Recipients'" and the Korean translation as "설계서와 설계서 수신자를 확인하세요."
  2. Use GlideUser to Get Language Preference:

    You can use the GlideUser object to retrieve the user's language preference

      3. Display the Error Message Based on Language Preference:

          Depending on the user's language preference, you can retrieve the appropriate translation                        message and use it in your error message

 

Write BR: 

(function executeRule(current, previous /* previous */) {
    // Get the user's language preference
    var user = gs.getUser();
    var userLanguage = user.getPreference('glide.sys.language', 'en'); // Default to English if preference not set

    // Define the base error message key
    var errorMessageKey = 'error.design_file_recipients';

    // Append '_ko' to the key for Korean translation if user's language is Korean
    if (userLanguage === 'ko') {
        errorMessageKey += '_ko';
    }

    // Get the translated error message
    var translatedErrorMessage = gs.getMessage(errorMessageKey);

    // Set the translated error message
    current.setAbortAction(true); // Prevent the default error message
    current.setReturn(translatedErrorMessage);

})(current, previous);

 4.Configure Supported Languages:

Ensure that you have configured the supported languages in your ServiceNow instance. You can do this in System Properties > System by adding languages to the "Supported Languages" list.

By following these steps, your error message will be dynamically translated based on the user's language preference, and it will display the correct translation (English or Korean) accordingly. Make sure you have created translation messages for all the languages you want to support in your instance.

 

Please Mark my Solution as Accept and Give me thumbs up, if you find it Helpful.

 

Thanks & Regards,

Kartik Magadum