Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 3 I18: translation missing: da.datetime.distance_in_words.about_x_hours

I get this error in view:

translation missing:
da.datetime.distance_in_words.about_x_hours     

My da locale file: http://pastie.org/2944890

My view:

<%= distance_of_time_in_words(Time.new, konkurrancer.udtraekkes) %>

I have added this to my application.rb:

config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
config.i18n.default_locale = :da

If I remove the I18 config the helper does work on english.

UPDATE:

My configuration in my config/enviorments/devolpment.rb:

  config.i18n.load_path += Dir[Rails.root.join('locales', '*.{rb,yml}').to_s]
  config.i18n.default_locale = :da
  config.i18n.locale = :da

My translation file in config/locales/da.yml:

da:
   datetime:
      distance_in_words:
         x_days:
            one: '1 day'
            other: '{{count}} dage'

And I get this error view:

translation missing:  da.datetime.distance_in_words.x_days
like image 417
Rails beginner Avatar asked Nov 30 '11 17:11

Rails beginner


3 Answers

You are close - all you have to do is fix the indentation in your locale file. Starting at line #8 to the end of the file, increase the indentation by one unit. This will allow Rails to resolve da[:datetime][:distance_in_words][:about_x_hours] to the proper value.

like image 160
simianarmy Avatar answered Oct 05 '22 06:10

simianarmy


Try:

distance_in_words:
  x_days: "%{count} days"

or

distance_in_words:
  x_days:
    one: "1 day"
    other: "%{count} days"
like image 26
justi Avatar answered Oct 05 '22 05:10

justi


You can get all the samples here: https://github.com/svenfuchs/rails-i18n/tree/master/rails/locale

like image 26
Brian Avatar answered Oct 05 '22 05:10

Brian