Rails i18n distance_of_time_in_words_to_now

时间:2013-10-03 11:42:12

标签: ruby-on-rails internationalization rails-i18n

我想将distance_of_time_in_words_to_now函数的结果翻译成葡萄牙语,但我的档案.yml并没有翻译这个函数。

如何解决此问题?我试过这种方式,但任何改变都不会影响视图:

en:
by: 'por'

cause:
 comments: 'Comentários'
 about: 'Sobre a causa:'

helpers:
 page-header:
  new: 'Novo %{resource}'
  edit: 'Editando %{resource}'
  list: 'Listando %{collection}'
  cause:
    list: 'Causas'

actions:
  new: 'Novo %{resource}'
  edit: 'Editar'
  show: 'Mostrar'
  destroy: 'Apagar'
  confirm_destroy: 'Você tem certeza?'

  cause:
    login: 'Entrar'
    new: 'Faça algo acontecer'
    show: 'Ver Causa'
    like: 'Apoiar esta causa'
    dislike: 'Não apoiar esta causa'
    undo: 'Retirar meu voto'
    commenting: 'Enviando comentário...'

submit:
  comment:
    create: 'Comentar'

    submit:
      cause:
        create: 'Criar Causa'

activerecord:
  models:
    cause: 'Causa'

attributes:
  cause:
    title: 'Título'

datetime:
  distance_in_words:
    less_than_x_seconds:
        one:  "less than 1 second"
        other: "less than {{count}} seconds"

    x_seconds:
        one:  "1 second"
        other: "{{count}} seconds"

    less_than_x_minutes:
        one:  "less than a minute"
        other: "less than {{count}} minutes"

    x_minutes:
        one:  "1 minuto"
        other: "{{count}} minutos"

    about_x_hours:
        one:  "cerca de 1 hora"
        other: "cerca {{count}} horas"

    x_days:
        one:  "1 dia"
        other: "%{count} dias"

    about_x_months:
        one:  "about 1 month"
        other: "about {{count}} months"

    x_months:
        one:  "1 month"
        other: "{{count}} meses"

    about_x_years:
        one:  "about 1 year"
        other: "about {{count}} years"

    over_x_years:
        one:  "over 1 year"
        other: "over {{count}} years"

1 个答案:

答案 0 :(得分:0)

我相信你是缩进的,因为它们应该缩进?此外,它应该是one:other:,而不是many:

x_days:
  one:  "1 dias"
  other: "%{count} dias"

更新:

以下适用于我:

en:
  hello: "Hello world"              # irrelevant
  datetime:
    distance_in_words:
      x_days:
        one: "1 dias"
        other: "%{count} dias"

请注意,缩进是此处的关键。