-
Notifications
You must be signed in to change notification settings - Fork 92
gw-format-date-merge-tags.php: Added i18n date format support.
#919
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
Conversation
| if ( $locale ) { | ||
| $formatter = datefmt_create( | ||
| $locale, | ||
| IntlDateFormatter::FULL, | ||
| IntlDateFormatter::FULL, | ||
| null, | ||
| null, | ||
| $modifier | ||
| ); | ||
| $replace = $formatter->format( $timestamp ); | ||
| } else { | ||
| // phpcs:ignore WordPress.DateTime.RestrictedFunctions.date_date | ||
| $replace = date( $modifier, $timestamp ); | ||
| } |
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.
Curious, if you use https://developer.wordpress.org/reference/functions/wp_date/, does that solve the issue?
|
|
||
| new GW_Format_Date_Merge_Tag( array( | ||
| 'form_id' => 123, | ||
| 'locale' => 'fr_FR', // When this option is enabled, use the ISO date format codes instead. See https://framework.zend.com/manual/1.12/en/zend.date.constants.html#zend.date.constants.selfdefinedformats |
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'd comment this line out, as most people likely won't want French formatted dates 😃
4502624 to
cce75d6
Compare
claygriffiths
left a comment
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.
One final bit of feedback, otherwise LGTM!
| if ( $locale ) { | ||
| switch_to_locale( $locale ); | ||
| } |
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'd put a switch back to the other locale right before the return of this function, just to be safe.
$current_locale = determine_locale();
claygriffiths
left a comment
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.
Perfect! Nice work. S&M
3861381 to
e4d5747
Compare
Context
⛑️ https://secure.helpscout.net/conversation/2763010990/73925?folderId=8114575
Summary
Added
i18nsupport for date format using theIntlDateFormatterThisIntlDateFormatteruses the ISO date format codes instead of PHP date format.