-
Notifications
You must be signed in to change notification settings - Fork 99
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
JSON of locale need no-periods attribute #82
Comments
ideal solution is to add a flag `prefer-no-periods: true`.
The My guess here is that you’re using some other non-localized code that specifies https://github.com/d3/d3-scale/blob/732ed4b1cd5c643700571d1089c7deb8472242a6/src/time.js#L31-L32 The recommended solution is to provide your own time format definition, replacing the one in the README as desired. Maybe: var formatMillisecond = d3.timeFormat(".%L"),
formatSecond = d3.timeFormat(":%S"),
formatMinute = d3.timeFormat("%H:%M"),
formatHour = d3.timeFormat("%H"),
formatDay = d3.timeFormat("%a %d"),
formatWeek = d3.timeFormat("%b %d"),
formatMonth = d3.timeFormat("%B"),
formatYear = d3.timeFormat("%Y");
function multiFormat(date) {
return (d3.timeSecond(date) < date ? formatMillisecond
: d3.timeMinute(date) < date ? formatSecond
: d3.timeHour(date) < date ? formatMinute
: d3.timeDay(date) < date ? formatHour
: d3.timeMonth(date) < date ? (d3.timeWeek(date) < date ? formatDay : formatWeek)
: d3.timeYear(date) < date ? formatMonth
: formatYear)(date);
} Alternatively, we could perhaps move this definition (that is, the list of format strings |
Thanks @mbostock to the solution (!), it is a good alternative for programmers, and for my chart. And thanks to discuss! I am looking for wide and long-term use of the locale specification.... Can we extend the discussion? Anticipating my apologies if so: I will try using my Bad-English, and long explanations, perhaps redundant. Before, answering your question:
Yes, it is VEGA-lite (its inner axis "temporal" tickFormat when zoomed), it delegates to D3js. When user is non-English the VEGA locale is a copy/paste of D3js locale, like locale/pt-BR.json. VEGA and similar ones, and its users, we need high-level locale specification. Them, the solution must be originated in the JSON locale interpretation. |
Suggestion descriptionThe aim is the locale folder, and the JSON schema used there. My suggestion is to add a flag, a new locale JSON schema property: PS: it is not to change Rationale and example. Is ugly for any non-English language that use 24hs and not "PM/AM" (no use or very rare use of periods)... We need "plug and play" 24h standard (high-level locale specification) for it. We can suppose that the property {
"dateTime": "%A, %e de %B de %Y. %X",
"date": "...",
"time": "%H:%M:%S",
"periods": ["AM", "PM"],
"periodsPrefer": false,
"days": ["..."],
} It is for all locale users, not only this library. Of course, it will be useful also here, at for example formatMinute = userLocale.periodsPrefer? format("%I:%M"): format("%H:%M"),
formatHour = userLocale.periodsPrefer? format("%I %p"): format("%H"), We can suppose some locale normalization before use above, at copy or initialization: if (userLocale.periodsPrefer===undefined)
userLocale.periodsPrefer = (userLocale.periods && userLocale.periods.length>0); |
Some countries, like Brazil, using pt-BR locale, need a boolean flag to express "we only use 24hs, please never use periods"... Or at least "please avoid periods".
NOTES
Some softwares like VEGA-lite are accepting
"periods": []
but without use 24hs, that is also wrong. Another way to create a new convention is to accept explicit null as this kind of convention... But it is not perfect, because the "periods" translation can be useful for interface where user must to use it. So, a flag asprefer-no-periods: true
is the better convention.The text was updated successfully, but these errors were encountered: