ruby 变形PT-BR导轨

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ruby 变形PT-BR导轨相关的知识,希望对你有一定的参考价值。

# Be sure to restart your server when you modify this file.

# Add new inflection rules using the following format
# (all these examples are active by default):
# ActiveSupport::Inflector.inflections do |inflect|
#   inflect.plural /^(ox)$/i, '\1en'
#   inflect.singular /^(ox)en/i, '\1'
#   inflect.irregular 'person', 'people'
#   inflect.uncountable %w( fish sheep )
# end
#
# These inflection rules are supported but not enabled by default:
# ActiveSupport::Inflector.inflections do |inflect|
#   inflect.acronym 'RESTful'
# end

ActiveSupport::Inflector.inflections do |inflect|
	inflect.clear

	#general rule: add "s" to the end of the word
	#casa - casas
	inflect.plural /^([a-zA-z]*)a$/i, '\1as'
	#pe - pes
	inflect.plural /^([a-zA-z]*)e$/i, '\1es'
	#no example
	inflect.plural /^([a-zA-z]*)i$/i, '\1is'
	#carro - carros
	inflect.plural /^([a-zA-z]*)o$/i, '\1os'
	#pneu - pneus
	inflect.plural /^([a-zA-z]*)u$/i, '\1us'

	#if word ends in "r" or "z", add "es"
	#luz - luzes
	#flor - flores
	#arroz - arrozes
	inflect.plural /^([a-zA-z]*)r$/i, '\1res'
	inflect.plural /^([a-zA-z]*)z$/i, '\1zes'

	#if word ends in "al", "el", "ol", "ul": trade "l" with "is"
	#farol - farois
	#hospital - hospitais
	#telemovel - telemoveis
	#pincel - pinceis
	#anzol - anzois
	inflect.plural /^([a-zA-z]*)al$/i, '\1ais'
	inflect.plural /^([a-zA-z]*)el$/i, '\1eis'
	inflect.plural /^([a-zA-z]*)ol$/i, '\1ois'
	inflect.plural /^([a-zA-z]*)ul$/i, '\1uis'

	#if word ends in "il" and has tónic accent in last syllable, trade "il" with "is"
	#cantil - cantis
	inflect.plural /^([a-zA-z]*)il$/i, '\1is'

	#TODO
	#if word ends in "il" and has tónic accent in penultimate syllable, trade "il" with "eis"
	#no example

	#if word ends in "m", trade "m" with "ns"
	#armazem - armazens
	#portagem - portagens
	inflect.plural /^([a-zA-z]*)m$/i, '\1ns'

	#TODO
	#if word ends in "s" and has one silable, trade "s" with "es"
	#no example
	#inflect.plural /^([a-zA-z]*)e$/i, '\1es'

	#TODO
	#if word ends in "x" stays the same
	#no example... professor X, maybe?
	#inflect.plural /^([a-zA-z]*)x$/i, '\1xes'

	#if word ends in "ão", there are three ways of plural: ãos, ães, ões
	#NOTE: hard to detect, so I'll use the most common case
	#and then use irregular cases for the others.  if someone knows of
	#more cases please add to the list & mail me. thanks!
	#
	#cão - cães
	#colchão - colchões
	#portão - portões
	#pão - pães
	#alemão - alemães
	#chão - ?
	#pilhão - pilhões
	#canhão - canhões
	#bidão - bidões
	#mão - mãos
	inflect.plural /^([a-zA-z]*)ao$/i, '\1oes'
	# inflect.irregular 'cao', 'caes'
	# inflect.irregular 'pao', 'paes'
	#inflect.irregular 'mao', 'maos'
	#inflect.irregular 'alemao', 'alemaes'

	############################
	#singularize rules         #
	############################

	#pes - pe
	#carros - carro
	#pneus - pneu
	inflect.singular /^([a-zA-z]*)as$/i, '\1a'
	inflect.singular /^([a-zA-z]*)es$/i, '\1e'
	inflect.singular /^([a-zA-z]*)is$/i, '\1i'
	inflect.singular /^([a-zA-z]*)os$/i, '\1o'
	inflect.singular /^([a-zA-z]*)us$/i, '\1u'

	#luzes - luz
	#flores - flor
	#arrozes - arroz
	inflect.singular /^([a-zA-z]*)res$/i, '\1r'
	inflect.singular /^([a-zA-z]*)zes$/i, '\1z'

	#cantis - cantil
	inflect.singular /^([a-zA-z]*)is$/i, '\1il'

	#farois - farol
	#hospitais - hospital
	#telemoveis - telemovel
	#pinceis - pincel
	#anzois - anzol
	inflect.singular /^([a-zA-z]*)ais$/i, '\1al'
	inflect.singular /^([a-zA-z]*)eis$/i, '\1el'
	inflect.singular /^([a-zA-z]*)ois$/i, '\1ol'
	inflect.singular /^([a-zA-z]*)uis$/i, '\1ul'

	#armazens - armazem
	#portagens - portagem
	inflect.singular /^([a-zA-z]*)ns$/i, '\1m'

	#cães - cão
	#colchões - colchão
	#portões - portão
	#pães - pão
	#alemães - alemão
	inflect.singular /^([a-zA-z]*)oes$/i, '\1ao'
	inflect.singular /^([a-zA-z]*)aes$/i, '\1ao'
	inflect.singular /^([a-zA-z]*)aos$/i, '\1ao'
end

以上是关于ruby 变形PT-BR导轨的主要内容,如果未能解决你的问题,请参考以下文章

ruby 将:required_mark选项添加到标签。 (导轨4)

导轨服务器错误? (导轨 3)

导轨。 'Bundle install' 在 Ruby 版本升级 (Windows) 后给出了 'bad interpreter: No such file or directory' 错误

ruby on rails 在制作新应用程序时显示未知编码名称。在 Windows 7 上,导轨 4.2

导轨。 Dropdown1 使用 Ruby on Rails 启用 Drobdown2 选择

ruby 导轨のテスト用宝石リスト(デフォルトでインストールされているものを除く)