Correcting moment.locale() language parameter on Relative Time Converter Plugin
Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.
Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
By default Relative Time Converter addon returns 'moment.locale()' as 'english' or local language, which can be for all pages except "View Issue". Reference onhttps://momentjs.com/docs/#/i18n/changing-locale/page.
When using Jira with the German language everything works as accepted but when the addon runs it is not able to pick the correct language translation as it is checking moment.locale set in the browser and in the issue page it is set to "en" value.
Environment
Jira 8.20.8
Diagnosis

Cause
Sometimes, momentVariable.locale(currentLocale).format(...) might not be called at the places where moment() is used. The problem is that date text is shown always in English, for any locale/user. Examples of such places in code:
1 2 3 4 5
incident-management/postmortems/issue-panel/services/create-page-draft/template/body/custom-nodes/index.js`-> return text(moment(date).format('DD MMM Y HH:mm (UTC ZZ)')); incident-management/reports/incident-response-report/view/content/report/chart/view.js -> ```matchPeriodDuration(periodDuration, { week: () => moment(date).format(‘D MMM’), month: () => moment(date).format(‘MMM’), } );``` software-reports/burnup-report/view/grid/view.js -> return moment.utc(timestamp).format('ddd, MMM DD YYYY, h:mma');
This causes not to use global functions which depend on locale and for which using local .locale() call is not possible. E.g. moment.weekdays() and moment.months(), to display text for week or month names. The current workaround is to add these texts to messages.js file and translate them ourselves.
Solution
Upgrade Relative Time Converter plugin to 2.3.0
Was this helpful?