【问题标题】:Rails i18n distance_of_time_in_words_to_nowRails i18n distance_of_time_in_words_to_now
【发布时间】:2013-10-03 11:42:12
【问题描述】:

我想将 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"

【问题讨论】:

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


    【解决方案1】:

    我相信您正在缩进那些应该缩进的内容?另外,应该是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"
    

    注意缩进是这里的关键。

    【讨论】:

    • 有没有机会粘贴整个语言环境文件?只是为了查看所有范围?
    • 最后一个问题:你能举一个未翻译日期的例子吗? (顺便说一句。葡萄牙语翻译应存储在单独的语言环境文件中)
    • 葡萄牙语区域​​设置与上面的英语相同。我把英文名字改成葡萄牙文,一切都被翻译了,减去了日期时间。
    猜你喜欢
    • 2013-05-11
    • 2012-05-12
    • 2015-09-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-06
    • 1970-01-01
    相关资源
    最近更新 更多