Closed alxwrd closed 6 years ago
I see some problems when would use pendulums diff_from_humans()
for those simple slang methods, as it just gives as a plain datetime diff, but doesn't care if it's about the date or time.
Maybe we could instead use pendulums
format to provide an easy way to localize a MayaDT
instance given a specific format?
@timofurrer Sorry I hadn't done slang_date
yet as I was unsure of how to proceed.
I think humanize is not an option to use for localisation because it seems to have gone stale (last commit Dec 2016), and it's current release (2014) only has 3 localisations.
If we use pendulums format
for slang_date
, we lose 'yesterday', 'today', and 'tomorrow' as pendulum doesn't have support for this. I think that would be a shame.
The options I can see to fully have internationalisation:
date_for_humans()
for pendulum.@timofurrer I've added localisation for slang_date
if you could let me know what you think.
I've used a mix of pendulums .format()
and the translation data from dateparser. This has allowed both "today, tomorrow, yesterday", and dates like "25 Mai".
@alxwrd sorry for the delay. Looks good to me. Do you mind adding some tests for the i18n features?
@timofurrer no worries.
I've just pushed some tests. I think this now closes #84? I can't see anything else that would need internationalisation? All the other Maya methods are for iso.
Awesome! Thanks for the contribution! :tada:
This attempts to add internationalisation/localisation to the
slang_
methods to address #84.I originally attempted to use the localisation built into humanize. However, I had the issue that the last release for humanize was in 2014, and at the time it only supported 3 locales.
Because of this, I switched to using pendulum which has a much bigger locale selection.
However, pendulum only has
diff_for_humans()
which is for time. This leavesslang_date
without localisation.I think the questions that are left are:
slang_date
just get left for now?humanize
?