I’m trying to use a custom locale with Timex, so I can generate abbreviated time duration in words similar to Twitter:
Timex.from_now(Timex.to_date({2015, 6, 24}), "en_abbrev")
# => "7y"
# Instead of the default
Timex.from_now(Timex.to_date({2015, 6, 24}))
# => "7 years ago"
I’ve copied the relative_time.po translation file from Timex, made necessary modifications for my translation to work and placed the translation under my_app/priv/gettext/en_abbrev/LC_MESSAGES/relative_time.po
.
Gettext sees the new locale:
iex > Gettext.known_locales(MyAppWeb.Gettext)
# => ["en", "en_abbrev"]
However, timex doesn’t and falls back to en
:
Timex.from_now(Timex.to_date({2015, 6, 24}), "en_abbrev")
# => "7 years ago"
If anyone has experience with locales & Timex, any pointers appreciated!