Comments (10)
That's something I've been meaning to add for a while. Hopefully will get around to do it soon. I do accept and appreciate Pull Requests too :)
from humanizer.
I can do the English part, but how do you deal with the localization? I have no idea how to translate "from now" :)
from humanizer.
You do the English part using resources like I've done for the past dates. I will take care of translations and buy you a beer if I meet you :)
from humanizer.
k, lemme see what I can do. I have a three hour flight tomorrow, so I'll fork, check into a branch and send you a PR when I can.
from humanizer.
So looking at the code, to promote code/string reuse, I would split the x days ago into three resources -- "x days", then "ago" and "from now".
As to not break the other language translations, I'll create new resources for all, DateHumanize_SingleDay, DateHumanize_MultipleDays, etc. and then DateHumanize_Past and DateHumanize_Future (and perhaps a DateHumanize_Now).
I'll have my code use those new ones and then the other language resources can be adapted. Does that make sense?
from humanizer.
I am a bit confused to be honest. Could you explain a bit more please?
I haven't thought about this much; but I was thinking we could rename the existing resources to include a _Past
and then create new _Future
ones (e.g. DateHumanize_Past_SingleDay
and DateHumanize_Future_SingleDay
). I have once renamed the resource names and it's a simple find and replace.
from humanizer.
That could work, but I was going for reducing duplication of the single/multi combos multiplied by past/future. I was gonna just have a _SingleDay string, and then a _Past and a _Future.
So the string format would look like this pseudo-code:
var isFuture = date > DateTime.UtcNow;
if(...) //single day
{
return string.Format("{0} {1}", formatter.GetSingleDay, isFuture ? formatter.Future : formatter.Past);
}
from humanizer.
Ahhhh, gotcha. Thanks for explaining. That will work for English but it's going to make it rather difficult for localization. Redundancy in resources turned out to be the simplest solution to the localisation requirements of the library; so I'd say lets just add in new resources. I just realized that we don't actually need to rename the old resources (like I said above) for the dates in the past as resources already have an Ago
postfix. So we just have to add DateHumanize_
resources ending with FromNow
for future dates.
Thoughts?
from humanizer.
Okay, works for me. No need to deal with language craziness :)
from humanizer.
Implemented in #68
from humanizer.
Related Issues (20)
- Titlize removes decimal point HOT 3
- TimeUnit.ToSymbol() don't take culture into account HOT 2
- Request: Collection.Humanize(Culture culture) instead of defaulting
- Missing DateHumanize_Never for Resources.zh-CN.resx
- Humanize size, e.g. 1280x720 => "HD", 850x480 => "SD" HOT 1
- Pascalize a kebab-cased string returns a Kebab-Cased string. HOT 2
- string.Humanize(LetterCasing.Title) Has Different Behavior Than To.TitleCase Extension (Symbols)
- error NU1202: Package Humanizer.Core.ar 2.14.1 is not compatible wit h net7.0 (.NETCoreApp,Version=v7.0). Package Humanizer.Core.ar 2.14.1 does not support any target frameworks. HOT 5
- Humanize Enum key and DescriptionAttribute HOT 1
- ToMetric with decimal places?
- Dehumanize() doesn't get rid of forward slash in input string.
- Add time of day-based greetings
- Is there a way to ignore & symbol HOT 1
- Pluralize with LetterCasing.AllCaps returns plural with lower case "s" HOT 1
- Humanizing dates in time zones other than system and UTC HOT 2
- decimal to percentage string HOT 3
- Localisation "ToWords" pt-PT for European portuguese no longer available HOT 1
- [Bug] `Camelize()` does not respect acronyms
- Is this library still maintained? HOT 29
- How do I specify a culture? HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from humanizer.