i18n_yaml_sorter 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +13 -0
- data/Gemfile.lock +18 -0
- data/LICENSE +1 -1
- data/README.rdoc +126 -23
- data/Rakefile +17 -13
- data/VERSION +1 -1
- data/bin/sort_yaml +34 -2
- data/i18n_yaml_sorter.gemspec +44 -34
- data/lib/i18n_yaml_sorter.rb +2 -128
- data/lib/i18n_yaml_sorter/railtie.rb +10 -0
- data/lib/i18n_yaml_sorter/sorter.rb +128 -0
- data/lib/tasks/i18n_yaml_sorter.rake +16 -0
- data/test/helper.rb +10 -1
- data/test/in.yml +1 -1
- data/test/in_rails.yml +239 -0
- data/test/in_simple.yml +28 -0
- data/test/out.yml +1 -0
- data/test/out_rails.yml +220 -0
- data/test/out_simple.yml +28 -0
- data/test/test_i18n_yaml_sorter.rb +29 -11
- data/textmate/YAML Sort.tmbundle/Commands/Sort YAML.tmCommand +22 -0
- data/textmate/YAML Sort.tmbundle/info.plist +10 -0
- metadata +81 -46
- data/.gitignore +0 -21
data/test/out.yml
CHANGED
data/test/out_rails.yml
ADDED
@@ -0,0 +1,220 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
# pt-BR translations for Ruby on Rails
|
3
|
+
"pt-BR":
|
4
|
+
activerecord:
|
5
|
+
errors:
|
6
|
+
full_messages:
|
7
|
+
format: "%{attribute} %{message}"
|
8
|
+
messages:
|
9
|
+
record_invalid: "A validação falhou: %{errors}"
|
10
|
+
<<: *errors_messages
|
11
|
+
taken: "já está em uso"
|
12
|
+
template:
|
13
|
+
body: "Por favor, verifique o(s) seguinte(s) campo(s):"
|
14
|
+
header:
|
15
|
+
one: "Não foi possível gravar %{model}: 1 erro"
|
16
|
+
other: "Não foi possível gravar %{model}: %{count} erros."
|
17
|
+
date:
|
18
|
+
# formatos de data e hora
|
19
|
+
abbr_day_names:
|
20
|
+
- Dom
|
21
|
+
- Seg
|
22
|
+
- Ter
|
23
|
+
- Qua
|
24
|
+
- Qui
|
25
|
+
- Sex
|
26
|
+
- Sáb
|
27
|
+
abbr_month_names:
|
28
|
+
- ~
|
29
|
+
- Jan
|
30
|
+
- Fev
|
31
|
+
- Mar
|
32
|
+
- Abr
|
33
|
+
- Mai
|
34
|
+
- Jun
|
35
|
+
- Jul
|
36
|
+
- Ago
|
37
|
+
- Set
|
38
|
+
- Out
|
39
|
+
- Nov
|
40
|
+
- Dez
|
41
|
+
day_names:
|
42
|
+
- Domingo
|
43
|
+
- Segunda
|
44
|
+
- Terça
|
45
|
+
- Quarta
|
46
|
+
- Quinta
|
47
|
+
- Sexta
|
48
|
+
- Sábado
|
49
|
+
formats:
|
50
|
+
default: "%d/%m/%Y"
|
51
|
+
long: "%d de %B de %Y"
|
52
|
+
short: "%d de %B"
|
53
|
+
month_names:
|
54
|
+
- ~
|
55
|
+
- Janeiro
|
56
|
+
- Fevereiro
|
57
|
+
- Março
|
58
|
+
- Abril
|
59
|
+
- Maio
|
60
|
+
- Junho
|
61
|
+
- Julho
|
62
|
+
- Agosto
|
63
|
+
- Setembro
|
64
|
+
- Outubro
|
65
|
+
- Novembro
|
66
|
+
- Dezembro
|
67
|
+
order:
|
68
|
+
- :day
|
69
|
+
- :month
|
70
|
+
- :year
|
71
|
+
datetime:
|
72
|
+
distance_in_words:
|
73
|
+
# distancia do tempo em palavras
|
74
|
+
about_x_hours:
|
75
|
+
one: 'aproximadamente 1 hora'
|
76
|
+
other: 'aproximadamente %{count} horas'
|
77
|
+
about_x_months:
|
78
|
+
one: 'aproximadamente 1 mês'
|
79
|
+
other: 'aproximadamente %{count} meses'
|
80
|
+
about_x_years:
|
81
|
+
one: 'aproximadamente 1 ano'
|
82
|
+
other: 'aproximadamente %{count} anos'
|
83
|
+
almost_x_years:
|
84
|
+
one: 'quase 1 ano'
|
85
|
+
other: 'quase %{count} anos'
|
86
|
+
half_a_minute: 'meio minuto'
|
87
|
+
less_than_x_minutes:
|
88
|
+
one: 'menos de um minuto'
|
89
|
+
other: 'menos de %{count} minutos'
|
90
|
+
less_than_x_seconds:
|
91
|
+
one: 'menos de 1 segundo'
|
92
|
+
other: 'menos de %{count} segundos'
|
93
|
+
over_x_years:
|
94
|
+
one: 'mais de 1 ano'
|
95
|
+
other: 'mais de %{count} anos'
|
96
|
+
x_days:
|
97
|
+
one: '1 dia'
|
98
|
+
other: '%{count} dias'
|
99
|
+
x_minutes:
|
100
|
+
one: '1 minuto'
|
101
|
+
other: '%{count} minutos'
|
102
|
+
x_months:
|
103
|
+
one: '1 mês'
|
104
|
+
other: '%{count} meses'
|
105
|
+
x_seconds:
|
106
|
+
one: '1 segundo'
|
107
|
+
other: '%{count} segundos'
|
108
|
+
prompts:
|
109
|
+
day: "Dia"
|
110
|
+
hour: "Hora"
|
111
|
+
minute: "Minuto"
|
112
|
+
month: "Mês"
|
113
|
+
second: "Segundo"
|
114
|
+
year: "Ano"
|
115
|
+
errors:
|
116
|
+
format: "%{attribute} %{message}"
|
117
|
+
messages: &errors_messages
|
118
|
+
accepted: "deve ser aceito"
|
119
|
+
blank: "não pode ficar em branco"
|
120
|
+
confirmation: "não está de acordo com a confirmação"
|
121
|
+
empty: "não pode ficar vazio"
|
122
|
+
equal_to: "deve ser igual a %{count}"
|
123
|
+
even: "deve ser par"
|
124
|
+
exclusion: "não está disponível"
|
125
|
+
greater_than: "deve ser maior que %{count}"
|
126
|
+
greater_than_or_equal_to: "deve ser maior ou igual a %{count}"
|
127
|
+
inclusion: "não está incluído na lista"
|
128
|
+
invalid: "não é válido"
|
129
|
+
less_than: "deve ser menor que %{count}"
|
130
|
+
less_than_or_equal_to: "deve ser menor ou igual a %{count}"
|
131
|
+
not_a_number: "não é um número"
|
132
|
+
not_an_integer: "não é um número inteiro"
|
133
|
+
odd: "deve ser ímpar"
|
134
|
+
too_long: "é muito longo (máximo: %{count} caracteres)"
|
135
|
+
too_short: "é muito curto (mínimo: %{count} caracteres)"
|
136
|
+
wrong_length: "não possui o tamanho esperado (%{count} caracteres)"
|
137
|
+
template:
|
138
|
+
body: "Por favor, verifique o(s) seguinte(s) campo(s):"
|
139
|
+
header:
|
140
|
+
one: "Não foi possível gravar %{model}: 1 erro"
|
141
|
+
other: "Não foi possível gravar %{model}: %{count} erros."
|
142
|
+
helpers:
|
143
|
+
select:
|
144
|
+
prompt: "Por favor selecione"
|
145
|
+
submit:
|
146
|
+
create: 'Criar %{model}'
|
147
|
+
submit: 'Salvar %{model}'
|
148
|
+
update: 'Atualizar %{model}'
|
149
|
+
number:
|
150
|
+
currency:
|
151
|
+
format:
|
152
|
+
delimiter: '.'
|
153
|
+
precision: 2
|
154
|
+
format: '%u %n'
|
155
|
+
separator: ','
|
156
|
+
significant: false
|
157
|
+
strip_insignificant_zeros: false
|
158
|
+
unit: 'R$'
|
159
|
+
format:
|
160
|
+
delimiter: '.'
|
161
|
+
precision: 3
|
162
|
+
separator: ','
|
163
|
+
significant: false
|
164
|
+
strip_insignificant_zeros: false
|
165
|
+
human:
|
166
|
+
decimal_units:
|
167
|
+
# number_to_human()
|
168
|
+
# new in rails 3: please add to other locales
|
169
|
+
format: "%n %u"
|
170
|
+
units:
|
171
|
+
billion:
|
172
|
+
one: bilhão
|
173
|
+
other: bilhões
|
174
|
+
million:
|
175
|
+
one: milhão
|
176
|
+
other: milhões
|
177
|
+
quadrillion:
|
178
|
+
one: quatrilhão
|
179
|
+
other: quatrilhões
|
180
|
+
thousand: "mil"
|
181
|
+
trillion:
|
182
|
+
one: trilhão
|
183
|
+
other: trilhões
|
184
|
+
unit: ""
|
185
|
+
format:
|
186
|
+
delimiter: '.'
|
187
|
+
precision: 2
|
188
|
+
significant: true
|
189
|
+
strip_insignificant_zeros: true
|
190
|
+
storage_units:
|
191
|
+
format: "%n %u"
|
192
|
+
units:
|
193
|
+
byte:
|
194
|
+
one: "Byte"
|
195
|
+
other: "Bytes"
|
196
|
+
gb: "GB"
|
197
|
+
kb: "KB"
|
198
|
+
mb: "MB"
|
199
|
+
tb: "TB"
|
200
|
+
percentage:
|
201
|
+
format:
|
202
|
+
delimiter: '.'
|
203
|
+
precision:
|
204
|
+
format:
|
205
|
+
delimiter: '.'
|
206
|
+
support:
|
207
|
+
array:
|
208
|
+
# Usado no Array.to_sentence
|
209
|
+
last_word_connector: " e "
|
210
|
+
two_words_connector: " e "
|
211
|
+
words_connector: ", "
|
212
|
+
select:
|
213
|
+
prompt: "Por favor selecione"
|
214
|
+
time:
|
215
|
+
am: ''
|
216
|
+
formats:
|
217
|
+
default: "%A, %d de %B de %Y, %H:%M h"
|
218
|
+
long: "%A, %d de %B de %Y, %H:%M h"
|
219
|
+
short: "%d/%m, %H:%M h"
|
220
|
+
pm: ''
|
data/test/out_simple.yml
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
en-US:
|
2
|
+
# Note that our comments are important:
|
3
|
+
# Don't let your yaml sorter delete them!
|
4
|
+
apples: >
|
5
|
+
Apples are fine,
|
6
|
+
just don't eat your
|
7
|
+
iPods!
|
8
|
+
bananas: |
|
9
|
+
Bananas are "nice":
|
10
|
+
- They are <b> sweet </b>.
|
11
|
+
this: not a key
|
12
|
+
|
13
|
+
That is why everyone like bananas!
|
14
|
+
grapes: We dont' eat them.
|
15
|
+
pt-BR:
|
16
|
+
# Note how this is a nice way of inputing
|
17
|
+
# paragraphs of text in YAML.
|
18
|
+
apples: >
|
19
|
+
Maçãs são boas,
|
20
|
+
só não coma
|
21
|
+
seus iPods!
|
22
|
+
bananas: |
|
23
|
+
Bananas são "legais":
|
24
|
+
- Elas são <b> doces </b>.
|
25
|
+
isto: não é chave
|
26
|
+
|
27
|
+
Por isto todos gostam de bananas!
|
28
|
+
grapes: Não comemos elas.
|
@@ -1,19 +1,37 @@
|
|
1
|
-
require 'helper'
|
1
|
+
require File.dirname(__FILE__) + '/helper'
|
2
2
|
|
3
3
|
class TestI18nYamlSorter < Test::Unit::TestCase
|
4
4
|
def test_should_sort_complex_sample_file
|
5
|
-
open('in.yml') do |file|
|
6
|
-
sorter = I18nYamlSorter.new(file)
|
7
|
-
open('out.yml') do |expected_out|
|
8
|
-
assert_equal
|
5
|
+
open(File.dirname(__FILE__) + '/in.yml') do |file|
|
6
|
+
sorter = I18nYamlSorter::Sorter.new(file)
|
7
|
+
open(File.dirname(__FILE__) + '/out.yml') do |expected_out|
|
8
|
+
assert_equal expected_out.read, sorter.sort
|
9
9
|
end
|
10
10
|
end
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
|
+
def test_should_rails_i18n_default_file
|
14
|
+
open(File.dirname(__FILE__) + '/in_rails.yml') do |file|
|
15
|
+
sorter = I18nYamlSorter::Sorter.new(file)
|
16
|
+
open(File.dirname(__FILE__) + '/out_rails.yml') do |expected_out|
|
17
|
+
assert_equal expected_out.read, sorter.sort
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_should_sort_simple_text_file
|
23
|
+
open(File.dirname(__FILE__) + '/in_simple.yml') do |file|
|
24
|
+
sorter = I18nYamlSorter::Sorter.new(file)
|
25
|
+
open(File.dirname(__FILE__) + '/out_simple.yml') do |expected_out|
|
26
|
+
assert_equal expected_out.read, sorter.sort
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
13
31
|
def test_should_not_alter_the_serialized_yaml
|
14
32
|
#ordering should'n t change a thing, since hashes don't have order in Ruby
|
15
|
-
open('in.yml') do |file|
|
16
|
-
sorter = I18nYamlSorter.new(file)
|
33
|
+
open(File.dirname(__FILE__) + '/in.yml') do |file|
|
34
|
+
sorter = I18nYamlSorter::Sorter.new(file)
|
17
35
|
present = YAML::load(file.read)
|
18
36
|
file.rewind
|
19
37
|
future = YAML::load(sorter.sort)
|
@@ -22,9 +40,9 @@ class TestI18nYamlSorter < Test::Unit::TestCase
|
|
22
40
|
end
|
23
41
|
|
24
42
|
def test_command_line_should_work_in_stdin
|
25
|
-
output =
|
26
|
-
open('out.yml') do |expected_out|
|
27
|
-
assert_equal
|
43
|
+
output = `#{File.dirname(__FILE__)}/../bin/sort_yaml < #{File.dirname(__FILE__)}/in.yml`
|
44
|
+
open(File.dirname(__FILE__) + '/out.yml') do |expected_out|
|
45
|
+
assert_equal expected_out.read, output
|
28
46
|
end
|
29
47
|
end
|
30
48
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
3
|
+
<plist version="1.0">
|
4
|
+
<dict>
|
5
|
+
<key>beforeRunningCommand</key>
|
6
|
+
<string>nop</string>
|
7
|
+
<key>command</key>
|
8
|
+
<string>sort_yaml</string>
|
9
|
+
<key>input</key>
|
10
|
+
<string>selection</string>
|
11
|
+
<key>keyEquivalent</key>
|
12
|
+
<string>@S</string>
|
13
|
+
<key>name</key>
|
14
|
+
<string>Sort YAML</string>
|
15
|
+
<key>output</key>
|
16
|
+
<string>replaceSelectedText</string>
|
17
|
+
<key>scope</key>
|
18
|
+
<string>source.yaml</string>
|
19
|
+
<key>uuid</key>
|
20
|
+
<string>190B37B2-9070-4F27-97DA-10ABC11EEF2D</string>
|
21
|
+
</dict>
|
22
|
+
</plist>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
3
|
+
<plist version="1.0">
|
4
|
+
<dict>
|
5
|
+
<key>name</key>
|
6
|
+
<string>YAML Sort</string>
|
7
|
+
<key>uuid</key>
|
8
|
+
<string>9C66740A-912D-4940-92C7-60B6D5984871</string>
|
9
|
+
</dict>
|
10
|
+
</plist>
|
metadata
CHANGED
@@ -1,35 +1,64 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: i18n_yaml_sorter
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 1
|
8
|
-
- 1
|
9
|
-
version: 0.1.1
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
prerelease:
|
10
6
|
platform: ruby
|
11
|
-
authors:
|
12
|
-
-
|
7
|
+
authors:
|
8
|
+
- Bernardo de Pádua
|
13
9
|
autorequire:
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
12
|
+
date: 2011-11-29 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: &70210724213700 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.0.0
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70210724213700
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: jeweler
|
27
|
+
requirement: &70210724212700 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.6.4
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70210724212700
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rcov
|
38
|
+
requirement: &70210724210840 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :development
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70210724210840
|
47
|
+
description: ! " Allows you to deep sort YAML files that are mainly composed of \n
|
48
|
+
\ nested hashes and string values. Great to sort your rails I18n YAML files.
|
49
|
+
You can easily\n add it to a textmate bundle, rake task, or just use the included
|
50
|
+
regular comand line tool. \n "
|
22
51
|
email: berpasan@gmail.com
|
23
|
-
executables:
|
52
|
+
executables:
|
24
53
|
- sort_yaml
|
25
54
|
extensions: []
|
26
|
-
|
27
|
-
extra_rdoc_files:
|
55
|
+
extra_rdoc_files:
|
28
56
|
- LICENSE
|
29
57
|
- README.rdoc
|
30
|
-
files:
|
58
|
+
files:
|
31
59
|
- .document
|
32
|
-
-
|
60
|
+
- Gemfile
|
61
|
+
- Gemfile.lock
|
33
62
|
- LICENSE
|
34
63
|
- README.rdoc
|
35
64
|
- Rakefile
|
@@ -37,40 +66,46 @@ files:
|
|
37
66
|
- bin/sort_yaml
|
38
67
|
- i18n_yaml_sorter.gemspec
|
39
68
|
- lib/i18n_yaml_sorter.rb
|
69
|
+
- lib/i18n_yaml_sorter/railtie.rb
|
70
|
+
- lib/i18n_yaml_sorter/sorter.rb
|
71
|
+
- lib/tasks/i18n_yaml_sorter.rake
|
40
72
|
- test/helper.rb
|
41
73
|
- test/in.yml
|
74
|
+
- test/in_rails.yml
|
75
|
+
- test/in_simple.yml
|
42
76
|
- test/out.yml
|
77
|
+
- test/out_rails.yml
|
78
|
+
- test/out_simple.yml
|
43
79
|
- test/test_i18n_yaml_sorter.rb
|
44
|
-
|
80
|
+
- textmate/YAML Sort.tmbundle/Commands/Sort YAML.tmCommand
|
81
|
+
- textmate/YAML Sort.tmbundle/info.plist
|
45
82
|
homepage: http://github.com/redealumni/i18n_yaml_sorter
|
46
|
-
licenses:
|
47
|
-
|
83
|
+
licenses:
|
84
|
+
- MIT
|
48
85
|
post_install_message:
|
49
|
-
rdoc_options:
|
50
|
-
|
51
|
-
require_paths:
|
86
|
+
rdoc_options: []
|
87
|
+
require_paths:
|
52
88
|
- lib
|
53
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
89
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
90
|
+
none: false
|
91
|
+
requirements:
|
92
|
+
- - ! '>='
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
segments:
|
58
96
|
- 0
|
59
|
-
|
60
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
version: "0"
|
97
|
+
hash: -2618840270023600225
|
98
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
|
+
none: false
|
100
|
+
requirements:
|
101
|
+
- - ! '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
67
104
|
requirements: []
|
68
|
-
|
69
105
|
rubyforge_project:
|
70
|
-
rubygems_version: 1.
|
106
|
+
rubygems_version: 1.8.10
|
71
107
|
signing_key:
|
72
108
|
specification_version: 3
|
73
|
-
summary: A I18n YAML deep sorter that will keep your locales organized and not screw
|
74
|
-
|
75
|
-
|
76
|
-
- test/test_i18n_yaml_sorter.rb
|
109
|
+
summary: A I18n YAML deep sorter that will keep your locales organized and not screw
|
110
|
+
up your text formating
|
111
|
+
test_files: []
|