Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Locale - Korean(ko) formats Month seems not right #688

Closed
whtFlower opened this issue Oct 8, 2019 · 9 comments
Closed

Locale - Korean(ko) formats Month seems not right #688

whtFlower opened this issue Oct 8, 2019 · 9 comments

Comments

@whtFlower
Copy link

I am not too familiar with i18n. However just looking at Korean/Japanese/Chinese, it seems like Korean format should be something like this(Notice the Month):
LL: 'YYYY년 MMMM D일', ==> 'YYYY년 M월 D일'

@iamkun
Copy link
Owner

iamkun commented Oct 8, 2019

@whtFlower Can you offer some more detail, please? (code console.log ...)

@whtFlower
Copy link
Author

On our application we use dayjs and I am trying to implement i18n. While I was going through formats I have noticed that Korean version (ko) has the following format:
LL: 'YYYY년 MMMM D일',
I see year & date in korean but not month. Out of curiosity I looked up Chinese & Japanese and see
the following (ja.js)
LL: 'YYYY年M月D日'

It happen to be that I am very familiar with Japanese and also can read some Chinese characters. After looking up those two locales I am wondering if Korean need to be 'YYYY년 M월 D일' like those two other locales.

Also it seems like the space seems inconsistent to me. I might be wrong -as I said I am not too familiar with i18n and lots of these are just guessing.
However seems like some locales has space between year/month/date including korean but some don't like Japanese and Chinese.

-by the way, is there easy way to extract YYYY only with locale? Trying to add locale for input field with placeholder of 'YYYY'. I am using formats.LL and extract month/year/date with substring. Not sure if that is the best way to do get them.

@iamkun
Copy link
Owner

iamkun commented Oct 8, 2019

We just keep the same with https://github.com/moment/moment/blob/develop/locale/ko.js

you can use dayjs().format('YYYY')

@whtFlower
Copy link
Author

I see.
One more question.
this is how I get months
dayjs.Ls.ko.months

I see months, weekdays, weekdaysShort, weekdaysMin.
However I don't see previousMonth & nextMonth in the object. How can get them?
Thanks for your help in advance!

@iamkun
Copy link
Owner

iamkun commented Oct 8, 2019

Seems we don't have a key named previousMonth , how did you find it?

@whtFlower
Copy link
Author

@iamkun moment().format("YYYY") returns current year. What I need is
YYYY年 or YYYY년

@iamkun
Copy link
Owner

iamkun commented Oct 8, 2019

dayjs.format('YYYY년') is what you are looking for 😬

@whtFlower
Copy link
Author

whtFlower commented Oct 8, 2019

@iamkun I am trying to add correct i18n for the place of 'YYYY' (en) which should be 'YYYY년'. since you guys have locale set up already, I am wondering if there is easy way for me to get YYYY in different language.
I am manually extracting it from but wonder if there is way.
const _formatLL = dayjs.Ls.ko.formats.LL,
_year = _formatLL.slice(0, _formatLL.indexOf("M"))

@iamkun
Copy link
Owner

iamkun commented Oct 8, 2019

you can import 'dayjs/locale/ko' as an object and update it to the value you want.

Then set as a custom locale dayjs.locale(customObject, null, true)

check here https://github.com/iamkun/dayjs/blob/dev/docs/en/I18n.md#customize

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants