Lack of consistent capitalization (English)
ryandt opened this issue · comments
Description
Capitalization of the "Just Now" time text is inconsistent with the other English words and phrases used in this library.
Version
1.3.2
Severity
Minor
Steps to Reproduce
- Set a time on the
RelativeTimeTextView
. - Observe the results as the time ages.
Actual behavior
The relative time text starts with "Just Now" and progresses to "1 min. ago", "Yesterday", "November 16", etc.
Expected behavior
The "Just Now" phrase is consistent with the other words/phrases used in this library. If the time text contains more than one word, I recommend capitalizing the first word and making the remaining words lowercase similar to today's "1 min. ago" format.
So "Just now" would become "Just now".
The problem is this library just blindly uses the output of DateUtils. getRelativeTimeSpanString
method and sets it to the TextView.
A probable solution is to provide a way for users of the library to manipulate the output of DateUtils. getRelativeTimeSpanString
before setting it to the TextView. This would allow various customizations like adding prefixes/suffixes, changing the styles of only certain parts of the text (like making just the number bold or a different color), capitalizing etc. I still haven't figured out an elegant way to achieve this.
In the meantime one could special case the capitalization for English alone based on what you describe should be the expected behavior, but I'm not convinced about this.
@curioustechizen Thanks for sharing that. I agree with allowing for text customizations before the text gets set on the TextView
.
What's your thoughts on allowing the client to pass in a "relative_time_formats.xml" file to the library that allows the client to override format values for the locales and time formats he wishes to customize? The XML file would contain specific identifiers that identify each relative time format, somewhat similar to the FORMAT_*
constants described in Android's DateUtils
class. An example ID might be format_yesterday
where the default would be "Yesterday" (from DateUtils.getRelativeTimeSpanString
). If the client provides a custom value such as That was so yesterday
, that value would be used instead. The client would also be able to pass in styling properties using CSS and format identifiers if necessary.
I'm not 100% sold on this yet. Just wanted to toss the thought out there for discussion. I'll think over this a bit more.
@ryandt v1.4.0 of this library has been released. This release has a solution to the problem you put forth: you can override a method which gives you a chance to process the text returned by DateUtils before it is set to the UI.
While it is not as elegant as I hoped to make it, at least it gives maximum flexibility with minimum effort for me as the library maintainer :)
Please try it out and let me know if it works well for you. I'm closing this issue for now.