Yes that works and that is what I am doing now, but it feels like it could 
follow the same conventions as the time_ago jquery plugin that was based of 
the rails verbiage (while extending it with the suggestion I made 
above): https://github.com/rmm5t/jquery-timeago

It is good that we can work around it without too much extra code, but it 
seems to force extensions that naturally should flow in with the rest of 
the phrases being constructed.

For example, the Spanish translation for "1 minute ago" would be "hace 1 
minuto" - it has a prefix rather than a suffix to indicate a time in the 
past.

for past times, each language pack would have the two keys

en:
  datetime:
    distance_in_words:
      prefix_ago: ""
      suffix_ago: "ago"

es:
  datetime:
    distance_in_words:
      prefix_ago: "hace"
      suffix_ago: ""

if we wanted future times, we could do

en:
  datetime:
    distance_in_words:
      prefix_from_now: "from now"
      suffix_from_now: ""

es:
  datetime:
    distance_in_words:
      prefix_from_now: ""
      suffix_from_now: "a partir de ahora"

On Monday, July 13, 2015 at 6:43:57 PM UTC-4, Carlos Antonio da Silva wrote:
>
> 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 <andrew.p...@gmail.com 
> <javascript:>> 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 rubyonrails-co...@googlegroups.com <javascript:>.
>> To post to this group, send email to rubyonra...@googlegroups.com 
>> <javascript:>.
>> 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 rubyonrails-core+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
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