-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Site Settings: add date time format sub-page #11259
Conversation
|
||
return ( | ||
<div className="main main-column date-time-format" role="main"> | ||
<DocumentHead title={ translate( 'Manage Date and Time Format Configurations' ) } /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi! I've found a possible matching string that has already been translated 52 times:
translate( 'Date and time format:' )
ES Score: 13.14
See 1 additional suggestion in the PR translation status page
Help me improve these suggestions: react with 👎 if the suggestion doesn't make any sense, or with 👍 if it's a particularly good one (even if not implemented).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hrm, this comment should have been for the string below, line 26. (different case)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yoavf I guess you're here for the wrong comment, but please don't waste your time on this PR already, since it's still very WIP.
I'll likely move things around a bit in the next commits, and I'm sure when I'll get some design feedback the translation strings will change too.
Maybe it could make sense to limit the i18n bot to needs review PRs only?
(I'd say to "needs i18n review" only, but I know us devs, we always forget about that label 🙂 )
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, but I still find it useful to audit every pr for now, to make sure everything works as expected. Once we're more confident we'll probably activate on "needs review".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yup, I meant that, not "ready to merge". :)
href={ `/settings/date-time-format/${ site.slug }` } | ||
> | ||
<h2 className="site-settings__date-time-format-title"> | ||
{ translate( 'Date and time format configuration' ) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi! I've found a possible matching string that has already been translated 52 times:
translate( 'Date and time format:' )
ES Score: 6.74
See 1 additional suggestion in the PR translation status page
Help me improve these suggestions: react with 👎 if the suggestion doesn't make any sense, or with 👍 if it's a particularly good one (even if not implemented).
6d3b1e6
to
817c2b8
Compare
Hello! Here are a few items that need love, based on copy review -- thanks for the ping!
|
Thanks @kristastevens! (Then cue to i18n wrath for so many new translation strings 😄 ) |
<div className="site-settings__date-time-format-info"> | ||
{ date_format ? today.format( phpToMomentDatetimeFormat( date_format ) ) : '' } • | ||
{ time_format ? today.format( phpToMomentDatetimeFormat( time_format ) ) : '' } • | ||
{ translate( 'Week starts on' ) } { start_of_week ? daysOfWeek[ start_of_week ] : daysOfWeek[ 0 ] } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi! I've found a possible matching string that has already been translated 88 times:
translate( 'Week Starts On' )
ES Score: 13.93
Help me improve these suggestions: react with 👎 if the suggestion doesn't make any sense, or with 👍 if it's a particularly good one (even if not implemented).
</span> | ||
<FormSettingExplanation> | ||
<ExternalLink href="https://codex.wordpress.org/Formatting_Date_and_Time" icon> | ||
{ translate( 'Learn more about date and time formatting.' ) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi! I've found a possible matching string that has already been translated 5 times:
translate( 'Documentation on date and time formatting.' )
ES Score: 6.55
Help me improve these suggestions: react with 👎 if the suggestion doesn't make any sense, or with 👍 if it's a particularly good one (even if not implemented).
@yoavf about the latest commit, please refer to #11259 (comment) for the reason. |
@Copons sure, better copy is obviously important. I have some ideas about processes we could set up to copy all existing translations when a string with a different case is added (we already do this right now when we change a string - but it doesn't happen if the changed string also exists elsewhere). I'll take a look at some of the changes here: when possible (=not a core string), I'll apply the changes to the other instances too, so we don't have duplication. Edit: see (internal) r151058-wpcom for an example. |
export class DateTimeFormatOptions extends Component { | ||
dateFormatOption() { | ||
const { | ||
fields: { date_format, timezone_string }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if you destructured these to camelCase names?
{ date_format: dateFormat, timezone_string: timezoneString }
</span> | ||
</span> | ||
<FormSettingExplanation> | ||
<ExternalLink href="https://codex.wordpress.org/Formatting_Date_and_Time" icon> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can ExternalLink
open in a new tab/window? I think that'd be good for this link.
/> | ||
<FormSettingExplanation> | ||
{ isCustomFormat && dateFormat | ||
? translate( 'Preview: %s', { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi! I've found a possible matching string that has already been translated 67 times:
translate( 'Preview %s' )
ES Score: 18
Help me improve these suggestions: react with 👎 if the suggestion doesn't make any sense, or with 👍 if it's a particularly good one (even if not implemented).
.site-settings__date-time-format-custom-preview { | ||
white-space: nowrap; | ||
.site-settings__date-time-format-info { | ||
color: $gray; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change this to $gray-text-min so that it's dark enough!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done!
I've also replaced $gray-dark
with $gray-text
as, while they are the same color, it makes more sense to me to use -text
for a text color.
Other than my one comment, I think the design is good to go. |
ab9e54f
to
a9c601b
Compare
<div className="site-settings__date-time-format-info"> | ||
{ dateFormat ? now.format( phpToMomentDatetimeFormat( dateFormat ) ) : '' } • | ||
{ timeFormat ? now.format( phpToMomentDatetimeFormat( timeFormat ) ) : '' } • | ||
{ translate( 'Week starts on' ) } { startOfWeek |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi! I've found a possible matching string that has already been translated 88 times:
translate( 'Week Starts On' )
ES Score: 14
Help me improve these suggestions: react with 👎 if the suggestion doesn't make any sense, or with 👍 if it's a particularly good one (even if not implemented).
@dmsnell I've renamed all those
Just FYI, I didn't reuse that function because I would have needed an even more complicated function to handle timezone strings and UTC offset hours-minutes conversions. |
/> | ||
<FormSettingExplanation> | ||
{ isCustom && timeFormat | ||
? translate( 'Preview: %s', { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi! I've found a possible matching string that has already been translated 67 times:
translate( 'Preview %s' )
ES Score: 18
Help me improve these suggestions: react with 👎 if the suggestion doesn't make any sense, or with 👍 if it's a particularly good one (even if not implemented).
? localizedDate.format( phpToMomentDatetimeFormat( timeFormat ) ) | ||
: '' | ||
} • | ||
{ translate( 'Week starts on' ) } { startOfWeek |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi! I've found a possible matching string that has already been translated 88 times:
translate( 'Week Starts On' )
ES Score: 14
Help me improve these suggestions: react with 👎 if the suggestion doesn't make any sense, or with 👍 if it's a particularly good one (even if not implemented).
{ translate( 'Date Format' ) } | ||
</FormLabel> | ||
{ defaultDateFormats.map( ( format, index ) => | ||
<FormLabel key={ index }> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
danger, React key as loop index!
args: localizedDate.format( phpToMomentDatetimeFormat( dateFormat ) ), | ||
comment: 'Date/time format preview', | ||
} ) | ||
: '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused at the ternary here. Is the goal only to output a string when isCustom && dateFormat
? If so, we can just just another &&
{ isCustom && dateFormat && translate(
'Preview: %s',
{
args: …,
comment: …,
}
) }
primary={ true } | ||
type="submit" | ||
disabled={ isRequestingSettings || isSavingSettings }> | ||
{ isSavingSettings |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
small nitpick: this confused me here (also a big reason I prefer to keep the >
on the next line) because of the indentation. could we move that closing >
into alignment with <Button
?
<Button
compact={ true }
…
>
{ isSavingSettings
? …
: …
}
</Button>
start_of_week: settings.start_of_week, | ||
time_format: settings.time_format, | ||
timezone_string: settings.timezone_string, | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fun fact! we can use object assignment to provide defaults. I'm not sure if you want the default switch to be "either use all of the defaults or use none of them" but if you want to instead say "use any of the defaults if their corresponding value isn't set" then we can do this:
const settings = {
...defaultSettings,
...customSettings,
};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The thing here is that I don't need all the settings (there are currently 64 settings, some of them are arrays of objects), so I'd need at least a lodash.pick( ... )
anyway.
Then, the assumption is that, if settings
exist, it's already populated server-side.
defaultSettings
is pretty much there only for the first uncached load, and that's why it returns early and doesn't let the function proceed to the gmt_offset
logic.
So while I'd love to spread here, I'd say it would result in more code (and conditionals) for no real readability improvements.
value={ startOfWeek || 0 } | ||
> | ||
{ moment.weekdays().map( ( day, index ) => | ||
<option key={ index } value={ index }> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's no more difficult to just use day
as the key here but it's much more reliable and semantic
{ translate( 'Time Format' ) } | ||
</FormLabel> | ||
{ defaultTimeFormats.map( ( format, index ) => | ||
<FormLabel key={ index }> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
danger, React key as loop index!
args: localizedDate.format( phpToMomentDatetimeFormat( timeFormat ) ), | ||
comment: 'Date/time format preview' | ||
} ) | ||
: '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see my note above on the ternary
{ dateFormat | ||
? localizedDate.format( phpToMomentDatetimeFormat( dateFormat ) ) | ||
: '' | ||
} • |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm calling your bull on this one…
} • | ||
{ timeFormat | ||
? localizedDate.format( phpToMomentDatetimeFormat( timeFormat ) ) | ||
: '' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hrm…was this spitting out false
as a string without the ternary…?
@Copons really coming together with this. I'm a big fan of the idea to follow-up with the token input for date fields - that's so much better of a UI than needing to know date format identifiers. |
- Remove numeric `key={ index }`. - Remove unnecessary ternaries. - Use `lodash.pick()` to pick site settings. - Fix an i18n error on “Week starts on”.
/> | ||
<FormSettingExplanation> | ||
{ isCustom && timeFormat && | ||
translate( 'Preview: %s', { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi! I've found a possible matching string that has already been translated 67 times:
translate( 'Preview %s' )
ES Score: 18
Help me improve these suggestions: react with 👎 if the suggestion doesn't make any sense, or with 👍 if it's a particularly good one (even if not implemented).
} ) => | ||
<FormFieldset> | ||
<FormLabel> | ||
{ translate( 'Week starts on' ) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi! I've found a possible matching string that has already been translated 88 times:
translate( 'Week Starts On' )
ES Score: 14
Help me improve these suggestions: react with 👎 if the suggestion doesn't make any sense, or with 👍 if it's a particularly good one (even if not implemented).
start_of_week: 0, | ||
time_format: '', | ||
timezone_string: '', | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if these are always constant then we might consider moving them into the module-global scope
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. That whole part was basically brought over form-general.jsx
(which yes, could use a brush up).
@dmsnell Moved |
/> | ||
<FormSettingExplanation> | ||
{ isCustom && timeFormat && | ||
translate( 'Preview: %s', { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi! I've found a possible matching string that has already been translated 67 times:
translate( 'Preview %s' )
ES Score: 18
Help me improve these suggestions: react with 👎 if the suggestion doesn't make any sense, or with 👍 if it's a particularly good one (even if not implemented).
} ) => | ||
<FormFieldset> | ||
<FormLabel> | ||
{ translate( 'Week starts on' ) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi! I've found a possible matching string that has already been translated 88 times:
translate( 'Week Starts On' )
ES Score: 14
Help me improve these suggestions: react with 👎 if the suggestion doesn't make any sense, or with 👍 if it's a particularly good one (even if not implemented).
See relevant discussion at #10441 (specifically this comment and the following).
Add a General Settings sub-page for Date Format, Time Format, Week Starts On, and possibly even Timezone.
The actual code handling the settings is being developed in #10400, and will be ported over here after its merge.
Screenshots
GIF