Forums

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

How can I get the translated name of a system field in Groovy?

Stefan Stadler
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 12, 2025

Hi,

this might be a short question, but I did not find any help anywhere:

How can I get the translated name of System fields via Groovy scripts in ScriptRunner?

I know that I can get the translations using the TranslationManager and CustomFields but I did not find any documentation on using this for System fields (for example "summary").

In my example, I would like to get the name "Zusammenfassung" for the system field "summary".

Thanks!

Stefan

2 answers

1 accepted

1 vote
Answer accepted
Stefan Stadler
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 12, 2025

I have found an answer to the question, which is using the i18n functions.

The following script lists all the system fields and the custom fields each with its translations. It assumes to be executed with an english user profile and will display the German translation as well:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.fields.OrderableField
import com.atlassian.jira.issue.fields.layout.field.FieldLayoutItem
import com.atlassian.jira.util.I18nHelper
import com.atlassian.jira.web.action.admin.translation.TranslationManager

TranslationManager tm = ComponentAccessor.translationManager

List<FieldLayoutItem> items = ComponentAccessor.fieldLayoutManager.editableFieldLayouts.find{it.id == 10000}.fieldLayoutItems
List<OrderableField> systemFields = items.collect{it.orderableField}.findAll{!it.id.startsWith("customfield")}
List<OrderableField> customFields = items.collect{it.orderableField}.findAll{it.id.startsWith("customfield")}

I18nHelper i18n = ComponentAccessor.getI18nHelperFactory().getInstance(Locale.GERMANY)

log.debug(":::System Fields:::")
systemFields.each {cf ->
log.debug("${cf.name} : ${i18n.getText(cf.getNameKey())}" )
}

log.debug(":::Custom Fields:::")
customFields.each {cf ->
CustomField _cf = cf as CustomField
log.debug("${_cf.untranslatedName} : ${tm.getCustomFieldNameTranslation(_cf,Locale.GERMANY)}" )
}
0 votes
Dilip
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
May 12, 2025

If I understand your query correctly, you want to get translated  name (german to english) of system field using groovy script.

You can try below script in script runner:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.fields.CustomField

def issueManager = ComponentAccessor.getIssueManager()
def issue = issueManager.getIssueObject("ISSUE-KEY") // Replace with your issue key

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def nameField = customFieldManager.getCustomFieldObjectByName("Name Field") // Replace with your field name

def nameValue = issue.getCustomFieldValue(nameField)

// Implement your translation logic here
def translatedName = translateName(nameValue) // Define this function based on your translation logic

issue.setCustomFieldValue(nameField, translatedName)

// Save the changes
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
issueManager.updateIssue(user, issue, EventDispatchOption.DO_NOT_DISPATCH, false)

Stefan Stadler
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 12, 2025

Hi @Dilip 

this is not what I meant. 

I want to get the translated name of the system field "summary". I do not need the value, but instead the name of the field.

What I want to get is a complete list of available fields in the Jira instance and that would require to have the respective translations of the names of system fields (such as "summary" or "description") also being available.

 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
10.3.1
TAGS
AUG Leaders

Atlassian Community Events