Fout bij het laden van dashboardrapporten bij gebruik van moment-jalaali.js

AI-generated summary

The discussion revolves around an error in loading dashboard reports when using the moment-jalaali.js script in a Discourse installation. nildarar explains that while the script successfully displays Jalali dates, it causes a JavaScript error (Uncaught TypeError: Cannot read property 'split' of null) in the dashboard reports, specifically in admin-report.js. sam notes that using moment-jalaali is currently a hack, not an officially supported feature, and highlights that Discourse is moving away from Moment.js long-term. nildarar confirms the script version (0.9.2) and its dependencies, while sam suggests verifying compatibility with the exact version of Moment.js used in Discourse core. nildarar provides the script’s package.json to confirm its dependency on moment@^2.22.2.

Continuing the discussion from How to properly display jalali dates for Persian language:

As mentioned above, we added the moment-jalaali script to the theme and changed the date display formats in the site’s text settings.

    ...
    <script src="https://cdn.jsdelivr.net/npm/moment-jalaali@0.9.2/build/moment-jalaali.js"></script>
</body>

By doing this, the problem of displaying the date in Hijri Shamsi was solved. But after adding the script, the dashboard reports will fail and the following error will occur.

Uncaught TypeError: Cannot read property 'split' of null

And when we debug, this error is observed.

I guess I would class this either as Support or Contribute > Feature request.

You are looking for a supported way of adding jalaali, there is no official supported way. What we have is a hack.

It is unclear if you have a version match or not.

I do support making this some sort of proper official version or proper official component.

One complication is that we are looking to move off moment longer term.

Thanks Sam,
Yes, you are right, Support is right here. If this is officially supported, that’s great.
I just asked here because maybe the Discourse team would know better where the problem came from and guide me. Strange that this problem occurs! Apart from this and another case, this solution works correctly one-way (show only). We use the latest version of Discourse.

Step one is to make sure this script you are hacking in is from the exact same moment.js release we are using in core. Can you confirm that?

We are using version 0.9.2 of the script. This version works based on the following dependencies:

  "devDependencies": {
    "chai": "^4.2.0",
    "eslint": "^6.7.1",
    "mocha": "^5.2.0"
  },
  "dependencies": {
    "jalaali-js": "^1.1.0",
    "moment": "^2.22.2",
    "moment-timezone": "^0.5.21",
    "rimraf": "^2.6.2"
  }

moment-jalaali/package.json at v0.9.2 · jalaali/moment-jalaali · GitHub