Wouldn't that work with a translation of your own, that receives the "time
ago" as an argument that you can interpolate, like this:


*translate :time_ago, time: time_ago_in_words(Time.current)*

*# locale*
*en:*
*  time_ago: "%{time} ago"*

*pt-BR:*
*  time_ago: "%{time} atrĂ¡s"*

*zomg:*
*  time_ago: "prefix %{time} suffix"*


That "just works", without adding any new extension to the method/framework.

Hope that helps.

On Mon, Jul 13, 2015 at 3:23 PM, Andrew Turgeon <[email protected]>
wrote:

> Hi all,
>
> I am working on internationalization topics, specifically time
> localization, and have ran into an issue that could be a possible feature
> inclusion in a future release that I wanted to get others' opinions on.
>
> One of the popular formats in English to say a space in time relative to
> the present time would be to use "10 minutes ago". Right now, DateHelper
> <http://api.rubyonrails.org/classes/ActionView/Helpers/DateHelper.html> allows
> you to correctly get the text "10 minutes" and then override any of that
> language by creating a yml file similar to the default en datetime
> translation
> <https://github.com/rails/rails/blob/master/actionview/lib/action_view/locale/en.yml>.
> The part that is missing is "ago" - so let's just add in "ago" into the
> override file right?
>
> The problem becomes this: If the someone uses the
> distance_of_time_in_words without one of the "to" or "from" specified as
> Time.now, it doesn't make sense anymore.
>
> I want to include "ago" for English but allow that relative time to be
> translated properly. I didn't want to include a separate translation key
> for "ago" because that could result in improper translation without
> context. In addition, other languages have prefixes instead of suffixes
> when specifying relative time.
>
> My proposal is to add some additional options for the
> distance_of_time_in_words method in DateHelper
> 1) :include_prefix (default: false)
> 2) :include_suffix (default: false)
>
> In the default yml file for datetime distance, there would be additional
> keys - :prefix and :suffix
>
> For English, suffix would be "ago" and prefix would be "" - this would
> allow users to customize not only the language used for the distance of
> time in words, but also any prefix or suffix used for the language.
>
> Now, if I want my "10 minutes ago", instead of specifying
>
> <%= time_ago_in_words(Time.now) %> ago
>
> we can now specify
>
> <%= time_ago_in_words(Time.now, :include_prefix => true) %>
>
> Thoughts?
>
> -Andrew
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Core" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/rubyonrails-core.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
At.
Carlos Antonio

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.

Reply via email to