Thanks to visit codestin.com
Credit goes to GitHub.com

Skip to content

Incorrect locale names for Chinese when loading Moment.js #9199

@u10313335

Description

@u10313335

CKAN version

2.10, 2.11, and master

Describe the bug

In the ckan/public/base/javascript/main.js and the ckan/public-midnight-blue/base/javascript/main.js (2.11), when loading the Moment.js, the names of Chinese locales should be zh-tw and zh-cn (rather than zh_Hant_TW and zh_Hans_CN from the locale variable), or they will not be loaded successfully under the corresponding locales:

// Convert all datetimes to the users timezone
jQuery('.automatic-local-datetime').each(function() {
    moment.locale(locale);
    var date = moment(jQuery(this).data('datetime'));
    if (date.isValid()) {
        jQuery(this).html(date.format("LL, LT ([UTC]Z)"));
    }
    jQuery(this).show();
})

Steps to reproduce

This issue affects:

  1. The timestamp fields in the DataTables view.
  2. The local_friendly_datetime snippet.

Expected behavior

The Chinese locales should be loaded without problems.

Additional details

The Additional Info section on the dataset page provides a quick way to confirm the results of the fix.

Before the fix:
Image

After the fix:
Image

A fix similar to #8432 should be able to resolve this bug. I will submit a PR later.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions