Rails Mailer中的复数与Texthelper合作
我试图在铁轨邮递的主题中使一个单词相汇:
这两个行不通:
subject: "Réservation pour #{pluralize(@step.number_of_people.to_i, "personne")}"
subject: "Réservation pour #{pluralize(@step.number_of_people.to_i, "personne", locale: :fr)}"
但是这两个正在起作用:
subject: "Réservation pour #{pluralize(@step.number_of_people.to_i, "personne", plural: 'personnes')}"
subject: "Réservation pour #{@step.number_of_people.to_i} #{"personne".pluralize(@step.number_of_people.to_i)}"
fundections.rb:
module Inflections
ActiveSupport::Inflector.inflections(:fr) do |inflect|
inflect.plural(/$/, 's')
inflect.singular(/s$/, '')
inflect.plural(/(bijou|caillou|chou|genou|hibou|joujou|pou|au|eu|eau)$/, '\1x')
inflect.singular(/(bijou|caillou|chou|genou|hibou|joujou|pou|au|eu|eau)x$/, '\1')
inflect.plural(/(bleu|émeu|landau|lieu|pneu|sarrau)$/, '\1s')
inflect.plural(/al$/, 'aux')
inflect.plural(/ail$/, 'ails')
inflect.singular(/(journ|chev)aux$/, '\1al')
inflect.singular(/ails$/, 'ail')
inflect.plural(/(b|cor|ém|gemm|soupir|trav|vant|vitr)ail$/, '\1aux')
inflect.singular(/(b|cor|ém|gemm|soupir|trav|vant|vitr)aux$/, '\1ail')
inflect.plural(/(s|x|z)$/, '\1')
inflect.irregular('monsieur', 'messieurs')
inflect.irregular('madame', 'mesdames')
inflect.irregular('mademoiselle', 'mesdemoiselles')
end
end
I'm trying to pluralize a word in the subject of a rails mailer :
these two don't working :
subject: "Réservation pour #{pluralize(@step.number_of_people.to_i, "personne")}"
subject: "Réservation pour #{pluralize(@step.number_of_people.to_i, "personne", locale: :fr)}"
but these two are working :
subject: "Réservation pour #{pluralize(@step.number_of_people.to_i, "personne", plural: 'personnes')}"
subject: "Réservation pour #{@step.number_of_people.to_i} #{"personne".pluralize(@step.number_of_people.to_i)}"
inflections.rb :
module Inflections
ActiveSupport::Inflector.inflections(:fr) do |inflect|
inflect.plural(/$/, 's')
inflect.singular(/s$/, '')
inflect.plural(/(bijou|caillou|chou|genou|hibou|joujou|pou|au|eu|eau)$/, '\1x')
inflect.singular(/(bijou|caillou|chou|genou|hibou|joujou|pou|au|eu|eau)x$/, '\1')
inflect.plural(/(bleu|émeu|landau|lieu|pneu|sarrau)$/, '\1s')
inflect.plural(/al$/, 'aux')
inflect.plural(/ail$/, 'ails')
inflect.singular(/(journ|chev)aux$/, '\1al')
inflect.singular(/ails$/, 'ail')
inflect.plural(/(b|cor|ém|gemm|soupir|trav|vant|vitr)ail$/, '\1aux')
inflect.singular(/(b|cor|ém|gemm|soupir|trav|vant|vitr)aux$/, '\1ail')
inflect.plural(/(s|x|z)$/, '\1')
inflect.irregular('monsieur', 'messieurs')
inflect.irregular('madame', 'mesdames')
inflect.irregular('mademoiselle', 'mesdemoiselles')
end
end
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论