Giter Club home page Giter Club logo

Comments (10)

MehdiK avatar MehdiK commented on May 12, 2024

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.

clairernovotny avatar clairernovotny commented on May 12, 2024

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.

MehdiK avatar MehdiK commented on May 12, 2024

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.

clairernovotny avatar clairernovotny commented on May 12, 2024

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.

clairernovotny avatar clairernovotny commented on May 12, 2024

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.

MehdiK avatar MehdiK commented on May 12, 2024

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.

clairernovotny avatar clairernovotny commented on May 12, 2024

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.

MehdiK avatar MehdiK commented on May 12, 2024

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.

clairernovotny avatar clairernovotny commented on May 12, 2024

Okay, works for me. No need to deal with language craziness :)

from humanizer.

MehdiK avatar MehdiK commented on May 12, 2024

Implemented in #68

from humanizer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.