Render dates in locale-aware fashion #190
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Recent changes (bef524b) rendered the
date
filter less friendly to locales by enforcing format strings rather than using built-in locale-aware formats for dates / times. Using the named, built-in formats allows for proper expression of localized dates / times, which may not naturally follow the same component order as (e.g.) a format string that is natural for English.A salient example would be rendering 2014-03-01 into Chinese (
"{{d|date:longDate:zh}}"
); prior to this code change, the result is三月 01, 2014
(which is super odd if, arguably, comprehensible) rather than the much more natural2014年3月1日
yielded after the patch.In the interests of not assuming the reader is familiar with Chinese, it's likely enough to explain that Chinese dates are always written from the largest unit (in this case the year) to the smallest (the day), which is not possible when the format is hardcoded to be
"MMMM dd, yyyy"
.