Correcting moment.locale() language parameter on Relative Time Converter Plugin

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.

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 on https://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 Server 8.20.8
Web Browser: Edge & Chrome

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:

    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 


Last modified on Jun 12, 2023

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.