8000 Support for two-letter days-of-week by eternicode · Pull Request #262 · moment/moment · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Support for two-letter days-of-week #262

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

Merged
merged 8 commits into from
May 24, 2012
Merged

Support for two-letter days-of-week #262

merged 8 commits into from
May 24, 2012

Conversation

eternicode
Copy link
Contributor

This would be useful for a datepicker or other calendar implementation, for example, where the convention is two-letter day column headers.

@rockymeza
Copy link
Contributor

@eternicode, you could overwrite the language definition for weekdaysShort. If you are not planning on using any other languages that English, you could overwrite the weekdaysShort value directly, for example:

moment.weekdaysShort = ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'];

If you are planning on internationalization, you could write your own custom language definition. For more see http://momentjs.com/docs/#/i18n/adding-language/.

@eternicode
Copy link
Contributor Author

@rockymeza That's fine for one-off uses, but I'm planning moment.js support for bootstrap-datepicker. The idea is to take advantage of moment's existing translations, for users who are already using it. Currently, I'm simply taking the first two letters of the three-letter translations ('ddd'), but there are some locales (like French) that use representations that are not two letters, and others (like Spanish) whose minimal representation is different than the first two letters of the short representation (Sáb vs Sa).

@rockymeza
Copy link
Contributor

@eternicode It appears that the format string dd is not currently in use. We could possibly use dd for the daysMin that bootstrap-datepicker has. What worries me though is getting all of the languages that moment currently supports to support the new format.

Perhaps we could do a weekdaysMin that falls back onto the weekdaysShort if it is unavailable.

@eternicode
Copy link
Contributor Author

@rockymeza , yeah, I saw the dd format as a good candidate, too. I wouldn't mind you guys copying the daysMin translations, along with appropriate attributions to the authors (available in the locale files), that bootstrap-datepicker currently has for a start. And a fallback to weekdaysShort seems like an acceptable compromise to me (just tested the ddd format on a datepicker, and it doesn't look horrible).

@rockymeza
Copy link
Contributor

@timrwood, what do you think about adding a weekdaysMin that falls back onto the weekdaysShort?

@timrwood
Copy link
Member
timrwood commented Apr 8, 2012

If we're going to support it, we should probably go all the way and make sure each lang has a weekdaysMin value. I'm sure we can find them somewhere on another date i18n library (even non js libs).

What if we allowed langs to not declare a weekdaysMin value though, and defaulted to the first two letters of each weekdays value. When the lang is loaded in, we check for a weekdaysMin, and if we don't find one, we copy the weekdays array and then chop off all the characters past 2.

Then, if a language needs special handling for the weekdaysMin values, they just add that object to the config file.

If we do it this way, we should also do this for weekdaysShort.

@rockymeza
Copy link
Contributor

@eternicode, do you think you would willing to write a pull request for this enhancement?

@eternicode
Copy link
Contributor Author

@rockymeza sure, I'll take a stab at it this weekend.

How do you guys want to source the translations? I'm thinking we can copy from jQuery UI datepicker's dayNamesMin translations. It's MIT license (which it looks like momentjs is, as well?), though I doubt this qualifies as "substantial portions of code".

@rockymeza
Copy link
Contributor

@timrwood, license stuff?

@timrwood
Copy link
Member

Yeah, it's data, not code, so I don't think there is a problem. We can tag all the original lang contributors in the pull request and ask them to verify the accuracy. I'm working on adding the lang authors to the comments of each lang file for future reference.

@rockymeza
Copy link
Contributor

I like the idea of having those author names in there. Also, it is a little difficult to know what the language is based on the shortcut name. Would it be possible to add the language name inside the comments too?

@timrwood
Copy link
Member

Here's the format I was thinking of using.

// moment.js language configuration
// language : catalan (ca)
// author : Juan G. Hurtado : https://github.com/juanghurtado
(function () {
    var lang = {

@timrwood
Copy link
Member

and done... 01618d4

@eternicode
Copy link
Contributor Author

Added a commit that I believe covers it. For the most part, I normalized the minimal versions to title-case without periods. There were a few that don't use romanic letters (cv, jp, zh-*, and ru being the ones that stood out) that I left as-is.

Choices for chuvash (cv) were base on the attachment to this glibc issue

@timrwood
Copy link
Member

Excellent work!

I know working with all the lang files is a pain in the ass, so much thanks for working on this! I'll tag all the authors of the original language files in the morning and once they put in their 2 cents I'll merge the pull request.

Thanks @eternicode!

@timrwood
Copy link
Member

@juanghurtado @mirontoli @mrbase @lluchs @chrisgedrim

We're adding even shorter weekday name translations to moment.js. Each of you contributed a language translation, so could you look over the translation you provided and let us know if the weekdaysMin values look good?

Sorry for the mass post...

@timrwood
Copy link
Member

@julionc @eillarra @bleadof @jfroffice @hinrik @aliem @baryon @kyungw00k @rexxars @jjupiter

Looks like theres a limit on how many people you can tag in a comment. See above.

@timrwood
Copy link
Member

@juanghurtado
Copy link
Contributor

They look right for "gl" and "ca" locales. Not usual form of the abbr., of course (the usual one is located under weekdaysShort), but can be understood.

@zenlor
Copy link
Contributor
zenlor commented May 14, 2012

I think that the italian translations can be a little shorter D_L_Ma_Me_G_V_S but i will have to look into it since I'm not sure it is correct

@timrwood
Copy link
Member

Yeah, this is intended for things like date pickers where space is limited.

@zenlor
Copy link
Contributor
zenlor commented May 14, 2012

Oh I see, for date pickers the right one is indeed D_L_Ma_Me_G_V_S in italian. I'll send a pull request if you need

@lluchs
Copy link
Contributor
lluchs commented May 14, 2012

Looks fine for de.

@@ -51,6 +51,7 @@
monthsShort : "tam_hel_maa_huh_tou_kes_hei_elo_syy_lok_mar_jou".split("_"),
weekdays : "sunnuntai_maanantai_tiistai_keskiviikko_torstai_perjantai_lauantai".split("_"),
weekdaysShort : "su_ma_ti_ke_to_pe_la".split("_"),
weekdaysMin : "Su_Ma_Ti_Ke_To_Pe_La".split("_"),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be changed. In Finnish we don't use capital letter in the default shortening of the week days.

They should still be su_ma_ti_ke_to_pe_la .

See references:
http://webcgi.oulu.fi/oykk/abc/kielenhuolto/oikeinkirjoitus/lyhenteet/lyhenteiden_lajit/
http://koulut.tampere.fi/materiaalit/kieli/3_2_3.html
http://fi.wikipedia.org/wiki/Lyhenne

@julionc
Copy link
Contributor
julionc commented May 14, 2012

You can see the jQuery UI localization for locales references.
Also, Spanish locale is fine.

@ben-lin
Copy link
Contributor
ben-lin commented May 14, 2012

both zh-tw and zh-cn are good in pull request https://github.com/eternicode/moment/commit/f47cb47a8990ccd731faa4d9b22413d1db995069#commitcomment-1328986, nice works :)

@evoL
Copy link
Contributor
evoL commented May 14, 2012

pl is alright, great work!

@@ -7,6 +7,7 @@
monthsShort : "urt._ots._mar._api._mai._eka._uzt._abu._ira._urr._aza._abe.".split("_"),
weekdays : "igandea_astelehena_asteartea_asteazkena_osteguna_ostirala_larunbata".split("_"),
weekdaysShort : "ig._al._ar._az._og._ol._lr.".split("_"),
weekdaysMin : "Ig_Al_Ar_Az_Og_Ol_Lr".split("_"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idem for Basque: the default shortening of the week days should stay in lowercase. (view Finnish comment by @bleadof )

@eillarra
Copy link
Contributor

@julionc Don't know for the other languages, but at least for Basque the jQuery UI localization is not right.

@@ -7,6 +7,7 @@
monthsShort : "jan_feb_mar_apr_maj_jun_jul_aug_sep_okt_nov_dec".split("_"),
weekdays : "söndag_måndag_tisdag_onsdag_torsdag_fredag_lördag".split("_"),
weekdaysShort : "sön_mån_tis_ons_tor_fre_lör".split("_"),
weekdaysMin : "Sö_Må_Ti_On_To_Fr_Lö".split("_"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per the finnish weekdays, the days should not be capitalized in Swedish, even when abbreviated. The correct string is

weekdaysMin : "sö_må_ti_on_to_fr_lö".split("_"),

@mrbase
Copy link
Contributor
mrbase commented May 14, 2012

looks fine for da

@jfroffice
Copy link
Contributor
Di_Lu_Ma_Me_Je_Ve_Sa

will be better for fr.

@hinrik
Copy link
Contributor
hinrik commented May 14, 2012

The Icelandic ones look fine.

@@ -7,6 +7,7 @@
monthsShort : "jan_feb_mar_apr_mai_jun_jul_aug_sep_okt_nov_des".split("_"),
weekdays : "søndag_mandag_tirsdag_onsdag_torsdag_fredag_lørdag".split("_"),
weekdaysShort : "søn_man_tir_ons_tor_fre_lør".split("_"),
weekdaysMin : "Sø_Ma_Ti_On_To_Fr_Lø".split("_"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per the finnish and swedish weekdays, the days should not be capitalized in Norwegian, even when abbreviated. The correct string is

weekdaysMin : "sø_ma_ti_on_to_fr_lø".split("_"),

@ulmus phrased it so well, I thought I would steal it directly ;-)

@@ -7,6 +7,7 @@
monthsShort : "кăр_нар_пуш_ака_май_çĕр_утă_çур_ав_юпа_чӳк_раш".split("_"),
weekdays : "вырсарникун_тунтикун_ытларикун_юнкун_кĕçнерникун_эрнекун_шăматкун".split("_"),
weekdaysShort : "выр_тун_ытл_юн_кĕç_эрн_шăм".split("_"),
weekdaysMin : "вр_тн_ыт_юн_кç_эр_шм".split("_"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! It is correct for Chuvash language, it is also according to a month template in Chuvash Wikipedia with short weekdays names

@andrewdeandrade
Copy link

@timrwood Yes, those Portuguese short names are correct, and you are correct that there is no short two-character version for Saturday and Sunday.

@timrwood
Copy link
Member

This seems to have settled. Pulling it in.

timrwood added a commit that referenced this pull request May 24, 2012
Support for two-letter days-of-week
@timrwood timrwood merged commit 405b9b3 into moment:develop May 24, 2012
@timrwood timrwood mentioned this pull request Jul 15, 2012
@mattjohnsonpint mattjohnsonpint mentioned this pull request Oct 21, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

0