Skip to content
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

Add ability to set custom units for ->getRelativeDate #3

Open
Anahkiasen opened this issue Feb 14, 2013 · 8 comments
Open

Add ability to set custom units for ->getRelativeDate #3

Anahkiasen opened this issue Feb 14, 2013 · 8 comments

Comments

@Anahkiasen
Copy link

Currently the getRelativeDate method only ouputs in english, it would be nice to be able to set a custom $units array and the ago string to allow manual translation of the date.

@jasonlewis
Copy link
Owner

Yeah nice one mate, will get onto it when I'm home.
On Feb 14, 2013 11:25 AM, "Maxime Fabre" [email protected] wrote:

Currently the getRelativeDate method only ouputs in english, it would be
nice to be able to set a custom $units array and the ago string to allow
manual translation of the date.


Reply to this email directly or view it on GitHubhttps://github.com//issues/3.

@jasonlewis jasonlewis mentioned this issue Mar 9, 2013
@jasonlewis
Copy link
Owner

I know this is an old issue but I really want to implement something for i18n. The problem is working with dates and especially with relative dates like Expressive Date it becomes quite complex. It's okay for some languages, but others, like Russian, can have 3 plural forms. Russian also requires that the "from now" suffix be placed in front of the date as a prefix, not a suffix.

I'm thinking of using the Symfony translator for this but that does add a dependency to what is currently a lightweight package.

For anyone that's using this I'd be interested to hear your thoughts.

@TomClarkson
Copy link

+1 localization would be awesome although it seems quite complex to do.

@kalenjordan
Copy link

What if for i18n support, you return back an array or something:

array(
    "number": "4",
    "unit": "day",
    "direction": "future"
}

So "4 days ago" would be

array(
    "number": "4",
    "unit": "day",
    "direction": "past"
}

And "3 weeks from now" would be

array(
    "number": "3",
    "unit": "week",
    "direction": "future"
}

Then leave it up to the implementer to translate that to actual language?

@ludo237
Copy link

ludo237 commented Nov 28, 2013

👍 For localization, any update?

@punkeel
Copy link

punkeel commented Dec 4, 2013

+1

@zeropingheroes
Copy link

It would also read better in some situations to change future dates to use a prefix instead, e.g. on an event page:

echo 'Event starting ' . $dt->getRelativeDate();

Would become:

Event starting in 4 hours

Rather than

Event starting 4 hours from now

@kalenjordan's suggestion would allow for this, though passing in a custom message format would be good too, e.g.

echo $dt->getRelativeDate('in %s', '%s ago');

@denvers
Copy link

denvers commented May 13, 2014

I have added Laravel Localization support and added a pull-request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants