Skip to content

Review date/time localisation in editorial backend #9733

Closed
1 of 1 issue completed
Closed
@jardakotesovec

Description

@jardakotesovec

Update 2025-06-03

  • Given that we have configurable dates, that can be configured per journal and language I focused on applying these formats in the browser for client side rendering
Image
  • As described in original issue, per my testing I was not getting localised dates in 3.3/3.4 from moment library. Nor these would be consistent with date formats configured above. On the other hand there was not many use cases displaying dates in Vue.js.
  • Migrated to successor library - Luxon.
  • Luxon rely on the Intl capabilities of the browser. Therefore it does not include per locale configurations and rely on browser and OS to provide these. The coverage will vary per browser/platform. My hope would someone using certain language would be using platform that supports given language and will also have Intl configuration available, but don't have data to back it up. If we get feedback that Intl is not providing good enough support, we can look into some Intl polyfills for some specific languages. Or alternatively dateFns has decent locale support, but we would have to include these to the package.
  • Fallback is to english locale
  • PHP DateTime format is transformed to the Luxon compatible format. Can't guarantee 100% same results from php and JS date formatting, but should be very close.
  • At this point we leverage date short and datetime short formats on client side. We did not have need to use the longer ones yet.

PRs
ojs:pkp/ojs#4720
ui-library: pkp/ui-library#553
pkp-lib: #11043

Original Description

Describe the issue
While doing code review for PR I was looking for correct way how to adjust following date formatting statement to reflect current locale.

function formatShortDate(dateString) {
	return moment(dateString).format('DD-MM-YYYY');
}

Given that we have getMomentLocale function I assume that moment works with locale.

Tried things like

  return moment(dateString).locale('fr').format('l');

But the problem is that for moment.js to be able to format per locale - each individual locale needs to be explicitly loaded

import 'moment/dist/locale/fr'; // Import French locale

I did test it with 3.3 and 3.4 and main. And all of them had only 'en' locale which is always present.

Solution
Probably start relying on some modern library which is leveraging native browser functionality for formatting dates, so we don't have to include extensive locale specific data for so many languages.

Sub-issues

Metadata

Metadata

Labels

AccessibilityAny issue that impacts assistive technology or users with visual or physical impairments.Bug:1:MinorA bug found in uncommon paths, with low consequences, limited users or has an easy workaroundUI/UXIssues affecting the user interface/user experience

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions