This topic is locked

Custom Button language

8/6/2024 11:03:42 AM
PHPRunner General questions
C
chrisp author

Hello,

Is there a way to access the current language or get a Custom Label in a custom button to show one text or another in the confirmation?

msg = "Esta seguro?"; // Spanish
msg = "Are you sure?"; // English

var msg =GetCustomLabel("WORK_ORDER_CONFIRMATION");

var r = confirm(msg);
if (r == true) {
return true;;
} else {
return false;
};

D
Denes 8/6/2024

Dear @Chrips!

If you set your application to support multiple language, then you can make custom labels for every language. (Misc Tab-> Multiple Languages, Label Editor)

After that you have to call Runner.getCustomLabel("CUSTOM_LABEL_NAME") what is get the value of the custom label of the selected language.

Br

C
cristi 8/6/2024

In order to acces the current language there is: mlang_getcurrentlang()
Populate a $result based on condition for detected language on the button server code and in the client after user that value with a conditional to display the message based on detected language.

something like this:

server:

$result["language"]=mlang_getcurrentlang();

client after:

var language= result["language"];
if (language=='english')
{
alert('English detected!');
}
else if (language=='spanish')
{
alert('Spanish detected!');
}

I don't know if those are the exact names for languages but you can do an alert on language var and find out.

Read this for more examples.