brtraducao 0.0.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +8 -0
- data/Rakefile +12 -13
- data/lib/brtraducao/inflector_portuguese.rb +50 -53
- data/lib/brtraducao/version.rb +2 -2
- data/test/inflections.yaml +50 -0
- data/test/inflector_test.rb +60 -0
- metadata +7 -3
- data/TODO +0 -5
data/README
CHANGED
data/Rakefile
CHANGED
@@ -29,17 +29,16 @@ Rake::TestTask.new { |t|
|
|
29
29
|
}
|
30
30
|
|
31
31
|
|
32
|
-
#
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
# }
|
32
|
+
#Generate the RDoc documentation
|
33
|
+
Rake::RDocTask.new { |rdoc|
|
34
|
+
rdoc.rdoc_dir = 'doc'
|
35
|
+
rdoc.title = "Brazilian Rails -- Tradução"
|
36
|
+
rdoc.options << '--line-numbers' << '--inline-source' << '-A cattr_accessor=object'
|
37
|
+
rdoc.options << '--charset' << 'utf-8'
|
38
|
+
rdoc.template = "#{ENV['template']}.rb" if ENV['template']
|
39
|
+
rdoc.rdoc_files.include('README', 'CHANGELOG')
|
40
|
+
rdoc.rdoc_files.include('lib/**/*')
|
41
|
+
}
|
43
42
|
|
44
43
|
|
45
44
|
# Create compressed packages
|
@@ -50,7 +49,7 @@ spec = Gem::Specification.new do |s|
|
|
50
49
|
s.description = %q{brtraducao é uma das gems que compoem o Brazilian Rails}
|
51
50
|
s.version = PKG_VERSION
|
52
51
|
|
53
|
-
s.
|
52
|
+
s.authors = ["Marcos Tapajós", "Celestino Gomes", "Andre Kupkosvki", "Vinícius Teles"]
|
54
53
|
s.email = "tapajos@gmail.com"
|
55
54
|
s.rubyforge_project = "brtraducao"
|
56
55
|
s.homepage = "http://www.improveit.com.br/software_livre/brazilian_rails"
|
@@ -63,7 +62,7 @@ spec = Gem::Specification.new do |s|
|
|
63
62
|
s.requirements << 'none'
|
64
63
|
s.require_path = 'lib'
|
65
64
|
|
66
|
-
s.files = [ "Rakefile", "README", "CHANGELOG", "
|
65
|
+
s.files = [ "Rakefile", "README", "CHANGELOG", "MIT-LICENSE" ]
|
67
66
|
s.files = s.files + Dir.glob( "lib/**/*" ).delete_if { |item| item.include?( "\.svn" ) }
|
68
67
|
s.files = s.files + Dir.glob( "test/**/*" ).delete_if { |item| item.include?( "\.svn" ) }
|
69
68
|
end
|
@@ -1,63 +1,60 @@
|
|
1
|
+
# Infelizmente não é possível colocar todas as regras...
|
2
|
+
#
|
3
|
+
# http://pt.wikipedia.org/wiki/Plural e
|
4
|
+
# http://pt.wikipedia.org/wiki/Singular
|
1
5
|
module Inflector
|
2
6
|
Inflector.inflections do |inflect|
|
3
|
-
inflect.
|
4
|
-
inflect.singular(/^(.*)s$/i, '\1')
|
5
|
-
inflect.singular(/^(.*)s$/i, '\1')
|
6
|
-
inflect.singular(/^(.*)s$/i, '\1')
|
7
|
-
inflect.singular(/^(.*)s$/i, '\1')
|
8
|
-
|
9
|
-
inflect.plural(/^(.*[z|r])$/i, '\1es')
|
10
|
-
inflect.singular(/^(.*[r|z])es$/i, '\1')
|
7
|
+
inflect.clear
|
11
8
|
|
12
|
-
inflect.plural(
|
13
|
-
inflect.plural(
|
14
|
-
inflect.plural(/^(
|
15
|
-
inflect.plural(
|
16
|
-
inflect.
|
17
|
-
inflect.
|
18
|
-
inflect.
|
19
|
-
inflect.
|
20
|
-
|
21
|
-
inflect.plural(
|
9
|
+
inflect.plural(/$/, 's')
|
10
|
+
inflect.plural(/(s)$/i, '\1')
|
11
|
+
inflect.plural(/^(paí)s$/i, '\1ses')
|
12
|
+
inflect.plural(/(z|r)$/i, '\1es')
|
13
|
+
inflect.plural(/al$/i, 'ais')
|
14
|
+
inflect.plural(/el$/i, 'eis')
|
15
|
+
inflect.plural(/ol$/i, 'ois')
|
16
|
+
inflect.plural(/ul$/i, 'uis')
|
17
|
+
inflect.plural(/([^aeou])il$/i, '\1is')
|
18
|
+
inflect.plural(/m$/i, 'ns')
|
19
|
+
inflect.plural(/^(japon|escoc|ingl|dinamarqu|fregu|portugu)ês$/i, '\1eses')
|
20
|
+
inflect.plural(/^(|g)ás$/i, '\1ases')
|
21
|
+
inflect.plural(/ão$/i, 'ões')
|
22
|
+
inflect.plural(/^(irm|m)ão$/i, '\1ãos')
|
23
|
+
inflect.plural(/^(alem|c|p)ão$/i, '\1ães')
|
22
24
|
|
23
|
-
|
24
|
-
inflect.
|
25
|
-
|
26
|
-
inflect.plural(/^(
|
27
|
-
inflect.plural(/^(.*)ás$/i, '\1ases')
|
28
|
-
inflect.plural(/^(.*)ês$/i, '\1eses')
|
29
|
-
inflect.singular(/^(.*)sses$/i, '\1sse')
|
30
|
-
inflect.singular(/^(.*[^s]s)es$/i, '\1')
|
31
|
-
|
32
|
-
inflect.plural(/^(.*)ão$/i, '\1ões')
|
33
|
-
inflect.singular(/^(.*)ões$/i, '\1ão')
|
34
|
-
|
35
|
-
inflect.plural(/^(.*)ao$/i, '\1oes')
|
36
|
-
inflect.singular(/^(.*)aos$/i, '\1ao')
|
25
|
+
# Sem acentos...
|
26
|
+
inflect.plural(/ao$/i, 'oes')
|
27
|
+
inflect.plural(/^(irm|m)ao$/i, '\1aos')
|
28
|
+
inflect.plural(/^(alem|c|p)ao$/i, '\1aes')
|
37
29
|
|
38
|
-
inflect.singular(
|
39
|
-
inflect.singular(/^(
|
40
|
-
inflect.singular(
|
41
|
-
inflect.singular(
|
30
|
+
inflect.singular(/([^ê])s$/i, '\1')
|
31
|
+
inflect.singular(/^(á|gá|paí)s$/i, '\1s')
|
32
|
+
inflect.singular(/(r|z)es$/i, '\1')
|
33
|
+
inflect.singular(/([^p])ais$/i, '\1al')
|
34
|
+
inflect.singular(/eis$/i, 'el')
|
35
|
+
inflect.singular(/ois$/i, 'ol')
|
36
|
+
inflect.singular(/uis$/i, 'ul')
|
37
|
+
inflect.singular(/(r|t)is$/i, '\1il')
|
38
|
+
inflect.singular(/ns$/i, 'm')
|
39
|
+
inflect.singular(/sses$/i, 'sse')
|
40
|
+
inflect.singular(/^(.*[^s]s)es$/i, '\1')
|
41
|
+
inflect.singular(/ães$/i, 'ão')
|
42
|
+
inflect.singular(/aes$/i, 'ao')
|
43
|
+
inflect.singular(/ãos$/i, 'ão')
|
44
|
+
inflect.singular(/aos$/i, 'ao')
|
45
|
+
inflect.singular(/ões$/i, 'ão')
|
46
|
+
inflect.singular(/oes$/i, 'ao')
|
47
|
+
inflect.singular(/(japon|escoc|ingl|dinamarqu|fregu|portugu)eses$/i, '\1ês')
|
48
|
+
inflect.singular(/^(g|)ases$/i, '\1ás')
|
42
49
|
|
43
50
|
# #irregulares
|
44
|
-
irregulares = {
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
"alemao" => 'alemaes',
|
52
|
-
"mail" => 'mails',
|
53
|
-
"email" => 'emails'
|
54
|
-
}
|
55
|
-
|
56
|
-
|
57
|
-
irregulares.each do |key, value|
|
58
|
-
inflect.plural(/^#{key.to_s}$/, value)
|
59
|
-
inflect.singular(/^#{value}$/, key.to_s)
|
60
|
-
end
|
51
|
+
# irregulares = {'país' => 'paises'}
|
52
|
+
#
|
53
|
+
#
|
54
|
+
# irregulares.each do |key, value|
|
55
|
+
# inflect.plural(/^#{key.to_s}$/, value)
|
56
|
+
# inflect.singular(/^#{value}$/, key.to_s)
|
57
|
+
# end
|
61
58
|
|
62
59
|
inflect.uncountable %w( tórax tênis ônibus lápis fênix )
|
63
60
|
end
|
data/lib/brtraducao/version.rb
CHANGED
@@ -0,0 +1,50 @@
|
|
1
|
+
casa: casas
|
2
|
+
classe: classes
|
3
|
+
cotonete: cotonetes
|
4
|
+
cone: cones
|
5
|
+
pé: pés
|
6
|
+
saci: sacis
|
7
|
+
carro: carros
|
8
|
+
pneu: pneus
|
9
|
+
flor: flores
|
10
|
+
luz: luzes
|
11
|
+
hospital: hospitais
|
12
|
+
movel: moveis
|
13
|
+
farol: farois
|
14
|
+
azul: azuis
|
15
|
+
cantil: cantis
|
16
|
+
barril: barris
|
17
|
+
armazem: armazens
|
18
|
+
ás: ases
|
19
|
+
gás: gases
|
20
|
+
portão: portões
|
21
|
+
portao: portoes
|
22
|
+
localização: localizações
|
23
|
+
sessão: sessões
|
24
|
+
cão: cães
|
25
|
+
pão: pães
|
26
|
+
mão: mãos
|
27
|
+
pai: pais
|
28
|
+
tênis: tênis
|
29
|
+
tórax: tórax
|
30
|
+
fênix: fênix
|
31
|
+
lápis: lápis
|
32
|
+
ônibus: ônibus
|
33
|
+
inglês: ingleses
|
34
|
+
país: países
|
35
|
+
email: emails
|
36
|
+
papel: papeis
|
37
|
+
inglês: ingleses
|
38
|
+
dinamarquês: dinamarqueses
|
39
|
+
português: portugueses
|
40
|
+
freguês: fregueses
|
41
|
+
japonês: japoneses
|
42
|
+
alemão: alemães
|
43
|
+
irmão: irmãos
|
44
|
+
irmã: irmãs
|
45
|
+
limão: limões
|
46
|
+
sessao: sessoes
|
47
|
+
cao: caes
|
48
|
+
pao: paes
|
49
|
+
mao: maos
|
50
|
+
localizacao: localizacoes
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/test_helper'
|
2
|
+
require 'yaml'
|
3
|
+
|
4
|
+
$KCODE = 'utf8'
|
5
|
+
|
6
|
+
def verify_pluralize(words)
|
7
|
+
words.each do |key, value|
|
8
|
+
module_eval %[
|
9
|
+
def test_pluralize_#{key}_to_#{value}
|
10
|
+
assert_equal '#{value}', '#{key}'.pluralize
|
11
|
+
end
|
12
|
+
]
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def verify_singularize(words)
|
17
|
+
words.each do |key, value|
|
18
|
+
module_eval %[
|
19
|
+
def test_singularize_#{value}_to_#{key}
|
20
|
+
assert_equal '#{key}', '#{value}'.singularize
|
21
|
+
end
|
22
|
+
]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def verify_if_dont_pluralize(words)
|
27
|
+
words.each do |key, value|
|
28
|
+
module_eval %[
|
29
|
+
def test_if_dont_pluralize_#{value}
|
30
|
+
assert_equal '#{value}', '#{value}'.pluralize
|
31
|
+
end
|
32
|
+
]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def verify_if_dont_singularize(words)
|
37
|
+
words.each do |key, value|
|
38
|
+
module_eval %[
|
39
|
+
def test_if_dont_singularize_#{key}
|
40
|
+
assert_equal '#{key}', '#{key}'.singularize
|
41
|
+
end
|
42
|
+
]
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
class InflectorTest < Test::Unit::TestCase
|
47
|
+
@words = YAML.load_file(File.dirname(__FILE__)+'/inflections.yaml')
|
48
|
+
|
49
|
+
verify_pluralize(@words)
|
50
|
+
verify_singularize(@words)
|
51
|
+
verify_if_dont_pluralize(@words)
|
52
|
+
verify_if_dont_singularize(@words)
|
53
|
+
|
54
|
+
def test_if_dont_pluralize
|
55
|
+
%(sessoes).each do |value|
|
56
|
+
assert_equal value, value.pluralize
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
metadata
CHANGED
@@ -1,15 +1,18 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: brtraducao
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- "Marcos Tapaj\xC3\xB3s"
|
8
|
+
- Celestino Gomes
|
9
|
+
- Andre Kupkosvki
|
10
|
+
- "Vin\xC3\xADcius Teles"
|
8
11
|
autorequire:
|
9
12
|
bindir: bin
|
10
13
|
cert_chain: []
|
11
14
|
|
12
|
-
date: 2008-
|
15
|
+
date: 2008-08-31 00:00:00 -03:00
|
13
16
|
default_executable:
|
14
17
|
dependencies:
|
15
18
|
- !ruby/object:Gem::Dependency
|
@@ -54,7 +57,6 @@ files:
|
|
54
57
|
- Rakefile
|
55
58
|
- README
|
56
59
|
- CHANGELOG
|
57
|
-
- TODO
|
58
60
|
- MIT-LICENSE
|
59
61
|
- lib/brtraducao
|
60
62
|
- lib/brtraducao/action_view_portuguese.rb
|
@@ -64,6 +66,8 @@ files:
|
|
64
66
|
- lib/brtraducao.rb
|
65
67
|
- test/action_view_test.rb
|
66
68
|
- test/active_record_test.rb
|
69
|
+
- test/inflections.yaml
|
70
|
+
- test/inflector_test.rb
|
67
71
|
- test/test_helper.rb
|
68
72
|
has_rdoc: true
|
69
73
|
homepage: http://www.improveit.com.br/software_livre/brazilian_rails
|