Closed soroushm closed 4 years ago
Seems fine in code sand box https://codesandbox.io/s/5y6qn0xwnx
is that any tip or trick ?
@behrang dude issues coming because require('moment/locale/fa')
is removed as see in below link and humanize function is not exist humanize
will be calculate x time ago
https://github.com/jalaali/moment-jalaali/commit/3ed634c3b7dff16d4eb3845edf14b70c247762f2
jMoment.loadPersian = function (args) {
var usePersianDigits = args !== undefined && args.hasOwnProperty('usePersianDigits') ? args.usePersianDigits : false
var dialect = args !== undefined && args.hasOwnProperty('dialect') ? args.dialect : 'persian'
require('moment/locale/fa')
i just add require('moment/locale/fa')
into 782 line and problem getting fix
@alitaheri can you take a look and take care/accept the pull request? I'm a bit rushed
This will break some other module system. we've added and removed this line so many time now.
This was a bad design decision made by the moment
developers. I suggest you use your own fork for this library. as merging this will upset others. and not doing so will keep breaking your code.
you can easily use your own modified fork from package.json
"dependencies": {
...
"moment-jalaali": "soroushm/moment-jalaali",
...
}
for more info: https://docs.npmjs.com/cli/install.html
Hey @alitaheri, There are many issues related to this: #131, #138, #142, #143, and #160.
I'm not very familiar with the problem. I was just thinking maybe adding the require
line inside loadPersian
method, while also changing the builder
scripts in the builder
directory (adding a middle2.js
file for registering moment/locale/fa
or ./locale/fa
) might fix the problem.
Or am I missing another thing?
@alitaheri even add in function scope ? can you test when required inside function scope or loadPersian ?
@behrang temporary i update the document and send a pull request
I saw it, but let's wait for Ali on this.
P.S: In your pull request, require
has a typo in it.
whats is mistake same work for me ?
Added a comment on your pull request. We better wait for Ali for a few days first.
This is a lot better 👍
We better leave it to the end user to solve this for their specific case. I agree with your solution
So we can close all those issue ?
"moment-jalaali": "^0.8.3", this version still not work in react-native Requiring unknown module "./locale/fa" makes the app crashed Any idea? @soroushm @alitaheri @behrang
Hi @mohamadsdg ,
you need to import this two things
import moment from "moment-jalaali";
import fa from "moment/src/locale/fa";
moment.locale("fa", fa);
moment.loadPersian();
as seen on this link fa is exist
Dear when i add
dialect: 'persian-modern
and usemoment(date).fromNow()
i getting error 'humanize' of undefined but without loadPersian working as wellversion
"react":"16.6.0" "moment": "^2.22.2", "moment-jalaali": "^0.8.1",
Code
moment(date).fromNow()
F.from node_modules/moment/moment.js:3430 3427 | return createDuration({ 3428 | to: this, 3429 | from: time
npm test
first time getting error about chai is not found
after install chai