Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Announcement banner depending on users language

Tido_Lorenz February 14, 2024

Hi,

we have some users who are not using Jira Software (Data Center) in English.

We want them to receive a different announcement banner (Admin > System > User Interface > Announcement Banner),
without having to install another plugin.
Sadly I don't know JavaScript well enough.
We know that the Field we are testing for should be named "jira.user.locale".

In Pseudocode, we want to do something like this:
IF "jira.user.locale" = "nl_NL"
THEN "Hoi, User"
ELSE "Hi, User"
END

Could you help me how to implement this logic?

Cheers,
Tido

1 answer

0 votes
Aswin Raj D
Community Champion
February 15, 2024

Dear @Tido_Lorenz ,

Here's a basic example of how you might implement this with JavaScript. This script checks the browser's language, not the jira.user.locale directly, due to the limitations mentioned. You can place this script in your Announcement Banner field in Jira's administration settings:

<script type="text/javascript">
document.addEventListener('DOMContentLoaded', function() {
var userLang = navigator.language || navigator.userLanguage;
var message = "Hi, User"; // Default message in English

if (userLang.startsWith("nl")) {
message = "Hoi, User"; // Dutch greeting
}


var banner = document.createElement("div");
banner.innerHTML = "<p>" + message + "</p>";
banner.style.padding = "10px";
banner.style.backgroundColor = "yellow";
banner.style.textAlign = "center";

document.body.insertBefore(banner, document.body.firstChild);
});
</script>

 

Please make sure you properly open and close the script tags. 

Remember, this approach uses the browser's language setting, which might not match the user's set language preference in Jira. Unfortunately, without a plugin or direct access to Jira's server-side data in the Announcement Banner, options to precisely target jira.user.locale are limited.

TidoL February 15, 2024

Thank you, that looks like a great script, but sadly (for reasons I'll spare you...), looking for the browsers language won't suffice...

Another possible path to victory came to my mind:
Is it possible to "read" the menue bar ("Dashboards, Projects, Issues, Boards, Plans...")?

From the way "Projects" is spelled, we can determine the language good enough.
So IF MenueField2 = "Projects" Then "Hello", else if MenueField2 = "Projecten" Then "Hoi"...
And so on?

Suggest an answer

Log in or Sign up to answer