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
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.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.