i18n_yaml_sorter_2 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.rdoc +3 -3
- data/Rakefile +2 -2
- data/VERSION +1 -1
- data/bin/sort_yaml +7 -7
- data/i18n_yaml_sorter.gemspec +4 -13
- data/lib/i18n_yaml_sorter/railtie.rb +2 -2
- data/lib/i18n_yaml_sorter/sorter.rb +37 -42
- data/lib/tasks/i18n_yaml_sorter.rake +6 -6
- data/textmate/YAML Sort.tmbundle/info.plist +6 -6
- metadata +1 -9
- data/test/helper.rb +0 -18
- data/test/in.yml +0 -66
- data/test/in_rails.yml +0 -239
- data/test/in_simple.yml +0 -28
- data/test/out.yml +0 -61
- data/test/out_rails.yml +0 -220
- data/test/out_simple.yml +0 -28
- data/test/test_i18n_yaml_sorter.rb +0 -48
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '019fae05b5138063422c4d02b70bb5a8edcba76e'
|
4
|
+
data.tar.gz: 90d5b1211d6e112b96552907676e569c9962a36c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4050d253a20f8b2cb0260ff4f143251218b090e2241c12cbdf841c6347829569ce835fee5e6a2fb7bb63066e0d577efb56b12ff815206917cb8dd03eda5dc902
|
7
|
+
data.tar.gz: 376e69e7010d5542ab3ef517e2854e6da8d91b8d7eb6349e65c0164f6d066735f8d3e0013c145c667e179f6953ca265aba7241d0184e1b598a77816f742ae28e
|
data/README.rdoc
CHANGED
@@ -211,10 +211,10 @@ Now run the rake task under your Rails' app to sort all the i18n files in your +
|
|
211
211
|
|
212
212
|
TODO: Add command line arguments parsing and options, so you can, for instance, sort a whole dir of yaml files.
|
213
213
|
|
214
|
-
==
|
214
|
+
== Development
|
215
215
|
|
216
|
-
|
217
|
-
|
216
|
+
$rake spec # run tests
|
217
|
+
$rake build
|
218
218
|
|
219
219
|
== Future improvements (Forks Welcome!)
|
220
220
|
|
data/Rakefile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.1
|
data/bin/sort_yaml
CHANGED
@@ -5,18 +5,18 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
|
5
5
|
require 'i18n_yaml_sorter'
|
6
6
|
|
7
7
|
options = {}
|
8
|
-
optparse = OptionParser.new do|opts|
|
9
|
-
opts.banner =
|
8
|
+
optparse = OptionParser.new do |opts|
|
9
|
+
opts.banner = 'Usage: sort_yaml < INPUT > OUTPUT | sort_yaml --install_bundle'
|
10
10
|
|
11
11
|
# Define the options, and what they do
|
12
12
|
options[:install_bundle] = false
|
13
|
-
opts.on(
|
13
|
+
opts.on('-i', '--install_bundle', 'Installs TextMate for MAC OS X bundle (named "YAML Sort") in the current user home dir.') do
|
14
14
|
options[:install_bundle] = true
|
15
15
|
end
|
16
16
|
|
17
17
|
# This displays the help screen, all programs are
|
18
18
|
# assumed to have this option.
|
19
|
-
opts.on(
|
19
|
+
opts.on('-h', '--help', 'Display this screen') do
|
20
20
|
puts opts
|
21
21
|
exit
|
22
22
|
end
|
@@ -25,14 +25,14 @@ end
|
|
25
25
|
optparse.parse!
|
26
26
|
|
27
27
|
if options[:install_bundle]
|
28
|
-
puts "Installing TextMate Bundle in your home dir (~/Library/Application\\ Support/TextMate/Bundles/)..."
|
28
|
+
puts "Installing TextMate Bundle in your home dir (~/Library/Application\\ Support/TextMate/Bundles/)..."
|
29
29
|
puts
|
30
30
|
system "mkdir -p ~/Library/Application\ Support/TextMate/Bundles"
|
31
31
|
system "cp -Rfv #{File.join(File.dirname(__FILE__), '..', 'textmate', 'YAML\ Sort.tmbundle')} ~/Library/Application\\ Support/TextMate/Bundles/ "
|
32
32
|
puts
|
33
|
-
puts "Reloading TextMate bundles..."
|
33
|
+
puts "Reloading TextMate bundles..."
|
34
34
|
system "osascript -e 'tell app \"TextMate\" to reload bundles'"
|
35
35
|
else
|
36
36
|
sorter = I18nYamlSorter::Sorter.new(STDIN)
|
37
37
|
puts sorter.sort
|
38
|
-
end
|
38
|
+
end
|
data/i18n_yaml_sorter.gemspec
CHANGED
@@ -1,11 +1,10 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
# -*- encoding: utf-8 -*-
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require 'i18n_yaml_sorter/version'
|
5
4
|
|
6
5
|
Gem::Specification.new do |s|
|
7
6
|
s.name = "i18n_yaml_sorter_2"
|
8
|
-
s.version =
|
7
|
+
s.version = I18nYamlSorter::VERSION
|
9
8
|
|
10
9
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
10
|
s.authors = ["Bernardo de P\u{e1}dua", 'compiledwrong']
|
@@ -31,14 +30,6 @@ Gem::Specification.new do |s|
|
|
31
30
|
"lib/i18n_yaml_sorter/railtie.rb",
|
32
31
|
"lib/i18n_yaml_sorter/sorter.rb",
|
33
32
|
"lib/tasks/i18n_yaml_sorter.rake",
|
34
|
-
"test/helper.rb",
|
35
|
-
"test/in.yml",
|
36
|
-
"test/in_rails.yml",
|
37
|
-
"test/in_simple.yml",
|
38
|
-
"test/out.yml",
|
39
|
-
"test/out_rails.yml",
|
40
|
-
"test/out_simple.yml",
|
41
|
-
"test/test_i18n_yaml_sorter.rb",
|
42
33
|
"textmate/YAML Sort.tmbundle/Commands/Sort YAML.tmCommand",
|
43
34
|
"textmate/YAML Sort.tmbundle/info.plist"
|
44
35
|
]
|
@@ -9,51 +9,51 @@ module I18nYamlSorter
|
|
9
9
|
@current_array_index = 0
|
10
10
|
sorted_yaml_from_blocks_array
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
private
|
14
|
-
|
14
|
+
|
15
15
|
def break_blocks_into_array
|
16
16
|
array = []
|
17
|
-
|
17
|
+
|
18
18
|
loop do
|
19
|
-
|
19
|
+
|
20
20
|
maybe_next_line = @read_line_again || @io_input.gets || break
|
21
21
|
@read_line_again = nil
|
22
22
|
maybe_next_line.chomp!
|
23
23
|
|
24
|
-
#Is it blank? Discard!
|
24
|
+
# Is it blank? Discard!
|
25
25
|
next if maybe_next_line.match(/^\s*$/)
|
26
26
|
|
27
|
-
#Does it look like a key: value line?
|
27
|
+
# Does it look like a key: value line?
|
28
28
|
key_value_parse = maybe_next_line.match(/^(\s*)(["']?[\w\-]+["']?)(: )(\s*)(\S.*\S)(\s*)$/)
|
29
|
-
if
|
30
|
-
array << maybe_next_line.concat("\n")
|
31
|
-
|
32
|
-
#Special cases when it should add extra lines to the array element (multi line quoted strings)
|
33
|
-
|
34
|
-
#Is the value surrounded by quotes?
|
29
|
+
if key_value_parse
|
30
|
+
array << maybe_next_line.concat("\n") #yes, it is the beginning of a key:value block
|
31
|
+
|
32
|
+
# Special cases when it should add extra lines to the array element (multi line quoted strings)
|
33
|
+
|
34
|
+
# Is the value surrounded by quotes?
|
35
35
|
starts_with_quote = key_value_parse[5].match(/^["']/)[0] rescue nil
|
36
36
|
ends_with_quote = key_value_parse[5].match(/[^\\](["'])$/)[1] rescue nil
|
37
|
-
if starts_with_quote and !(starts_with_quote == ends_with_quote)
|
38
|
-
|
37
|
+
if starts_with_quote and !(starts_with_quote == ends_with_quote)
|
38
|
+
|
39
39
|
loop do #Append next lines until we find the closing quote
|
40
40
|
content_line = @io_input.gets || break
|
41
41
|
content_line.chomp!
|
42
42
|
array.last << content_line.concat("\n")
|
43
43
|
break if content_line.match(/[^\\][#{starts_with_quote}]\s*$/)
|
44
44
|
end
|
45
|
-
|
46
|
-
end
|
47
|
-
|
45
|
+
|
46
|
+
end
|
47
|
+
|
48
48
|
next
|
49
|
-
end
|
50
|
-
|
51
|
-
# Is it a | or > string
|
49
|
+
end
|
50
|
+
|
51
|
+
# Is it a | or > string value?
|
52
52
|
is_special_string = maybe_next_line.match(/^(\s*)(["']?[\w\-]+["']?)(: )(\s*)([|>])(\s*)$/)
|
53
53
|
if is_special_string
|
54
|
-
array << maybe_next_line.concat("\n")
|
54
|
+
array << maybe_next_line.concat("\n") #yes, it is the beginning of a key block
|
55
55
|
indentation = is_special_string[1]
|
56
|
-
#Append the next lines until we find one that is not indented
|
56
|
+
# Append the next lines until we find one that is not indented
|
57
57
|
loop do
|
58
58
|
content_line = @io_input.gets || break
|
59
59
|
processed_line = content_line.chomp
|
@@ -65,53 +65,48 @@ module I18nYamlSorter
|
|
65
65
|
break
|
66
66
|
end
|
67
67
|
end
|
68
|
-
|
68
|
+
|
69
69
|
next
|
70
|
-
end
|
71
|
-
|
72
|
-
# Is it the
|
70
|
+
end
|
71
|
+
|
72
|
+
# Is it the beginning of a multi level hash?
|
73
73
|
is_start_of_hash = maybe_next_line.match(/^(\s*)(["']?[\w\-]+["']?)(:)(\s*)$/)
|
74
74
|
if is_start_of_hash
|
75
75
|
array << maybe_next_line.concat("\n")
|
76
76
|
next
|
77
|
-
end
|
78
|
-
|
79
|
-
#If we got here and nothing was done, this line
|
77
|
+
end
|
78
|
+
|
79
|
+
# If we got here and nothing was done, this line
|
80
80
|
# should probably be merged with the previous one.
|
81
81
|
if array.last
|
82
82
|
array.last << maybe_next_line.concat("\n")
|
83
83
|
else
|
84
84
|
array << maybe_next_line.concat("\n")
|
85
85
|
end
|
86
|
-
end
|
87
|
-
|
88
|
-
#debug:
|
89
|
-
#puts array.join("$$$$$$$$$$$$$$$$$$$$$$\n")
|
90
|
-
|
86
|
+
end
|
91
87
|
array
|
92
88
|
end
|
93
89
|
|
94
90
|
def sorted_yaml_from_blocks_array(current_block = nil)
|
95
|
-
|
96
91
|
unless current_block
|
97
92
|
current_block = @array[@current_array_index]
|
98
93
|
@current_array_index += 1
|
99
94
|
end
|
100
|
-
|
95
|
+
|
101
96
|
out_array = []
|
102
97
|
current_match = current_block.match(/^(\s*)(["']?[\w\-]+["']?)(:)/)
|
103
98
|
current_level = current_match[1] rescue ''
|
104
99
|
current_key = current_match[2].downcase.tr(%q{"'}, "") rescue ''
|
105
100
|
out_array << [current_key, current_block]
|
106
|
-
|
101
|
+
|
107
102
|
loop do
|
108
103
|
next_block = @array[@current_array_index] || break
|
109
104
|
@current_array_index += 1
|
110
|
-
|
105
|
+
|
111
106
|
current_match = next_block.match(/^(\s*)(["']?[\w\-]+["']?)(:)/) || next
|
112
107
|
current_key = current_match[2].downcase.tr(%q{"'}, "")
|
113
108
|
next_level = current_match[1]
|
114
|
-
|
109
|
+
|
115
110
|
if current_level.size < next_level.size
|
116
111
|
out_array.last.last << sorted_yaml_from_blocks_array(next_block)
|
117
112
|
elsif current_level.size == next_level.size
|
@@ -121,8 +116,8 @@ module I18nYamlSorter
|
|
121
116
|
break
|
122
117
|
end
|
123
118
|
end
|
124
|
-
|
125
|
-
|
119
|
+
|
120
|
+
out_array.sort.map(&:last).join
|
126
121
|
end
|
127
122
|
end
|
128
|
-
end
|
123
|
+
end
|
@@ -2,15 +2,15 @@ require 'i18n_yaml_sorter'
|
|
2
2
|
|
3
3
|
namespace :i18n do
|
4
4
|
|
5
|
-
desc
|
6
|
-
|
7
|
-
task :sort, [:path_to_file] => :environment do |t
|
5
|
+
desc 'Sort locales keys in alphabetic order. Sort all locales if no path parameter given'
|
6
|
+
|
7
|
+
task :sort, [:path_to_file] => :environment do |t, args|
|
8
8
|
locales = args[:path_to_file] || Dir.glob("#{Rails.root}/config/locales/**/*.yml")
|
9
9
|
|
10
10
|
locales.each do |locale_path|
|
11
11
|
sorted_contents = File.open(locale_path) { |f| I18nYamlSorter::Sorter.new(f).sort }
|
12
|
-
File.open(locale_path, 'w') { |f|
|
12
|
+
File.open(locale_path, 'w') { |f| f << sorted_contents }
|
13
13
|
end
|
14
14
|
end
|
15
|
-
|
16
|
-
end
|
15
|
+
|
16
|
+
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8"?>
|
2
2
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
3
3
|
<plist version="1.0">
|
4
|
-
<dict>
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
</dict>
|
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
10
|
</plist>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: i18n_yaml_sorter_2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bernardo de Pádua
|
@@ -80,14 +80,6 @@ files:
|
|
80
80
|
- lib/i18n_yaml_sorter/railtie.rb
|
81
81
|
- lib/i18n_yaml_sorter/sorter.rb
|
82
82
|
- lib/tasks/i18n_yaml_sorter.rake
|
83
|
-
- test/helper.rb
|
84
|
-
- test/in.yml
|
85
|
-
- test/in_rails.yml
|
86
|
-
- test/in_simple.yml
|
87
|
-
- test/out.yml
|
88
|
-
- test/out_rails.yml
|
89
|
-
- test/out_simple.yml
|
90
|
-
- test/test_i18n_yaml_sorter.rb
|
91
83
|
- textmate/YAML Sort.tmbundle/Commands/Sort YAML.tmCommand
|
92
84
|
- textmate/YAML Sort.tmbundle/info.plist
|
93
85
|
homepage: http://github.com/redealumni/i18n_yaml_sorter
|
data/test/helper.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'bundler'
|
3
|
-
begin
|
4
|
-
Bundler.setup(:default, :development)
|
5
|
-
rescue Bundler::BundlerError => e
|
6
|
-
$stderr.puts e.message
|
7
|
-
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
-
exit e.status_code
|
9
|
-
end
|
10
|
-
require 'test/unit'
|
11
|
-
require 'yaml'
|
12
|
-
|
13
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
14
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
15
|
-
require 'i18n_yaml_sorter'
|
16
|
-
|
17
|
-
class Test::Unit::TestCase
|
18
|
-
end
|
data/test/in.yml
DELETED
@@ -1,66 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
m_13: >
|
4
|
-
Não deve dar problema aqui!
|
5
|
-
Não deve dar problema aqui!
|
6
|
-
Não deve dar problema aqui!
|
7
|
-
Pois às vezes dá.
|
8
|
-
|
9
|
-
o_15: |
|
10
|
-
Não deve dar problema aqui!
|
11
|
-
Pois às vezes dá.
|
12
|
-
|
13
|
-
b_two:
|
14
|
-
a_1: Joãozinho
|
15
|
-
b_two: |
|
16
|
-
Nos somos legais, como
|
17
|
-
por exemplo: João,
|
18
|
-
que: gosta de nos dar milhões
|
19
|
-
em dinheiro todos os dias.
|
20
|
-
|
21
|
-
Linhas em Branco com tabulação
|
22
|
-
nos strings devem ser preservadas.
|
23
|
-
|
24
|
-
d_four: "Somos chatos
|
25
|
-
gostamos de várias linhas\"
|
26
|
-
e ainda usamos escaping
|
27
|
-
para fuder"
|
28
|
-
e_five: Prefirimos strings sem
|
29
|
-
nenhum tipo de especificação.
|
30
|
-
c_three:
|
31
|
-
a: "Marcelo"
|
32
|
-
d_4: Rafael
|
33
|
-
# Comentário de muitas
|
34
|
-
# linhas (goes with d_4)
|
35
|
-
"b": Bernardo
|
36
|
-
c_3:
|
37
|
-
unify: Luiz
|
38
|
-
klass: Lucas
|
39
|
-
f_six: Dalton
|
40
|
-
a_one: José # Comentado
|
41
|
-
c_three: Gustavo
|
42
|
-
# Comentário (goes with c_three)
|
43
|
-
f_six: Thiago
|
44
|
-
e_five:
|
45
|
-
b_two: Catarina
|
46
|
-
a_one: Rodrigo
|
47
|
-
# Comentário (goes with a_one)
|
48
|
-
"g-seven": Marcelo
|
49
|
-
d_four: Oliveira
|
50
|
-
k_eleven: Ronaldo
|
51
|
-
"l_other123123": Emilio
|
52
|
-
|
53
|
-
i_nine: Prestes
|
54
|
-
|
55
|
-
j_ten: >
|
56
|
-
Pior quando resolvemos escrever
|
57
|
-
assim, impossível aturar!
|
58
|
-
n_14: >
|
59
|
-
Não deve dar problema aqui!
|
60
|
-
Pois às vezes dá.
|
61
|
-
o_15: |
|
62
|
-
Não deve dar problema aqui!
|
63
|
-
Pois às vezes dá.
|
64
|
-
p_16: Não deve dar problema aqui!
|
65
|
-
Pois às vezes dá.
|
66
|
-
h_eight: "Jonivildo"
|
data/test/in_rails.yml
DELETED
@@ -1,239 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
# pt-BR translations for Ruby on Rails
|
3
|
-
"pt-BR":
|
4
|
-
date:
|
5
|
-
# formatos de data e hora
|
6
|
-
formats:
|
7
|
-
default: "%d/%m/%Y"
|
8
|
-
short: "%d de %B"
|
9
|
-
long: "%d de %B de %Y"
|
10
|
-
|
11
|
-
day_names:
|
12
|
-
- Domingo
|
13
|
-
- Segunda
|
14
|
-
- Terça
|
15
|
-
- Quarta
|
16
|
-
- Quinta
|
17
|
-
- Sexta
|
18
|
-
- Sábado
|
19
|
-
abbr_day_names:
|
20
|
-
- Dom
|
21
|
-
- Seg
|
22
|
-
- Ter
|
23
|
-
- Qua
|
24
|
-
- Qui
|
25
|
-
- Sex
|
26
|
-
- Sáb
|
27
|
-
|
28
|
-
month_names:
|
29
|
-
- ~
|
30
|
-
- Janeiro
|
31
|
-
- Fevereiro
|
32
|
-
- Março
|
33
|
-
- Abril
|
34
|
-
- Maio
|
35
|
-
- Junho
|
36
|
-
- Julho
|
37
|
-
- Agosto
|
38
|
-
- Setembro
|
39
|
-
- Outubro
|
40
|
-
- Novembro
|
41
|
-
- Dezembro
|
42
|
-
abbr_month_names:
|
43
|
-
- ~
|
44
|
-
- Jan
|
45
|
-
- Fev
|
46
|
-
- Mar
|
47
|
-
- Abr
|
48
|
-
- Mai
|
49
|
-
- Jun
|
50
|
-
- Jul
|
51
|
-
- Ago
|
52
|
-
- Set
|
53
|
-
- Out
|
54
|
-
- Nov
|
55
|
-
- Dez
|
56
|
-
order:
|
57
|
-
- :day
|
58
|
-
- :month
|
59
|
-
- :year
|
60
|
-
|
61
|
-
time:
|
62
|
-
formats:
|
63
|
-
default: "%A, %d de %B de %Y, %H:%M h"
|
64
|
-
short: "%d/%m, %H:%M h"
|
65
|
-
long: "%A, %d de %B de %Y, %H:%M h"
|
66
|
-
am: ''
|
67
|
-
pm: ''
|
68
|
-
|
69
|
-
support:
|
70
|
-
array:
|
71
|
-
# Usado no Array.to_sentence
|
72
|
-
words_connector: ", "
|
73
|
-
two_words_connector: " e "
|
74
|
-
last_word_connector: " e "
|
75
|
-
|
76
|
-
select:
|
77
|
-
prompt: "Por favor selecione"
|
78
|
-
|
79
|
-
number:
|
80
|
-
format:
|
81
|
-
separator: ','
|
82
|
-
delimiter: '.'
|
83
|
-
precision: 3
|
84
|
-
significant: false
|
85
|
-
strip_insignificant_zeros: false
|
86
|
-
|
87
|
-
currency:
|
88
|
-
format:
|
89
|
-
format: '%u %n'
|
90
|
-
unit: 'R$'
|
91
|
-
separator: ','
|
92
|
-
delimiter: '.'
|
93
|
-
precision: 2
|
94
|
-
significant: false
|
95
|
-
strip_insignificant_zeros: false
|
96
|
-
|
97
|
-
percentage:
|
98
|
-
format:
|
99
|
-
delimiter: '.'
|
100
|
-
|
101
|
-
precision:
|
102
|
-
format:
|
103
|
-
delimiter: '.'
|
104
|
-
|
105
|
-
human:
|
106
|
-
format:
|
107
|
-
delimiter: '.'
|
108
|
-
precision: 2
|
109
|
-
significant: true
|
110
|
-
strip_insignificant_zeros: true
|
111
|
-
storage_units:
|
112
|
-
format: "%n %u"
|
113
|
-
units:
|
114
|
-
byte:
|
115
|
-
one: "Byte"
|
116
|
-
other: "Bytes"
|
117
|
-
kb: "KB"
|
118
|
-
mb: "MB"
|
119
|
-
gb: "GB"
|
120
|
-
tb: "TB"
|
121
|
-
decimal_units:
|
122
|
-
# number_to_human()
|
123
|
-
# new in rails 3: please add to other locales
|
124
|
-
format: "%n %u"
|
125
|
-
units:
|
126
|
-
unit: ""
|
127
|
-
thousand: "mil"
|
128
|
-
million:
|
129
|
-
one: milhão
|
130
|
-
other: milhões
|
131
|
-
billion:
|
132
|
-
one: bilhão
|
133
|
-
other: bilhões
|
134
|
-
trillion:
|
135
|
-
one: trilhão
|
136
|
-
other: trilhões
|
137
|
-
quadrillion:
|
138
|
-
one: quatrilhão
|
139
|
-
other: quatrilhões
|
140
|
-
|
141
|
-
datetime:
|
142
|
-
distance_in_words:
|
143
|
-
# distancia do tempo em palavras
|
144
|
-
half_a_minute: 'meio minuto'
|
145
|
-
less_than_x_seconds:
|
146
|
-
one: 'menos de 1 segundo'
|
147
|
-
other: 'menos de %{count} segundos'
|
148
|
-
x_seconds:
|
149
|
-
one: '1 segundo'
|
150
|
-
other: '%{count} segundos'
|
151
|
-
less_than_x_minutes:
|
152
|
-
one: 'menos de um minuto'
|
153
|
-
other: 'menos de %{count} minutos'
|
154
|
-
x_minutes:
|
155
|
-
one: '1 minuto'
|
156
|
-
other: '%{count} minutos'
|
157
|
-
about_x_hours:
|
158
|
-
one: 'aproximadamente 1 hora'
|
159
|
-
other: 'aproximadamente %{count} horas'
|
160
|
-
x_days:
|
161
|
-
one: '1 dia'
|
162
|
-
other: '%{count} dias'
|
163
|
-
about_x_months:
|
164
|
-
one: 'aproximadamente 1 mês'
|
165
|
-
other: 'aproximadamente %{count} meses'
|
166
|
-
x_months:
|
167
|
-
one: '1 mês'
|
168
|
-
other: '%{count} meses'
|
169
|
-
about_x_years:
|
170
|
-
one: 'aproximadamente 1 ano'
|
171
|
-
other: 'aproximadamente %{count} anos'
|
172
|
-
over_x_years:
|
173
|
-
one: 'mais de 1 ano'
|
174
|
-
other: 'mais de %{count} anos'
|
175
|
-
almost_x_years:
|
176
|
-
one: 'quase 1 ano'
|
177
|
-
other: 'quase %{count} anos'
|
178
|
-
prompts:
|
179
|
-
year: "Ano"
|
180
|
-
month: "Mês"
|
181
|
-
day: "Dia"
|
182
|
-
hour: "Hora"
|
183
|
-
minute: "Minuto"
|
184
|
-
second: "Segundo"
|
185
|
-
|
186
|
-
helpers:
|
187
|
-
select:
|
188
|
-
prompt: "Por favor selecione"
|
189
|
-
|
190
|
-
submit:
|
191
|
-
create: 'Criar %{model}'
|
192
|
-
update: 'Atualizar %{model}'
|
193
|
-
submit: 'Salvar %{model}'
|
194
|
-
|
195
|
-
errors:
|
196
|
-
format: "%{attribute} %{message}"
|
197
|
-
|
198
|
-
template:
|
199
|
-
header:
|
200
|
-
one: "Não foi possível gravar %{model}: 1 erro"
|
201
|
-
other: "Não foi possível gravar %{model}: %{count} erros."
|
202
|
-
body: "Por favor, verifique o(s) seguinte(s) campo(s):"
|
203
|
-
|
204
|
-
messages: &errors_messages
|
205
|
-
inclusion: "não está incluído na lista"
|
206
|
-
exclusion: "não está disponível"
|
207
|
-
invalid: "não é válido"
|
208
|
-
confirmation: "não está de acordo com a confirmação"
|
209
|
-
accepted: "deve ser aceito"
|
210
|
-
empty: "não pode ficar vazio"
|
211
|
-
blank: "não pode ficar em branco"
|
212
|
-
too_long: "é muito longo (máximo: %{count} caracteres)"
|
213
|
-
too_short: "é muito curto (mínimo: %{count} caracteres)"
|
214
|
-
wrong_length: "não possui o tamanho esperado (%{count} caracteres)"
|
215
|
-
not_a_number: "não é um número"
|
216
|
-
not_an_integer: "não é um número inteiro"
|
217
|
-
greater_than: "deve ser maior que %{count}"
|
218
|
-
greater_than_or_equal_to: "deve ser maior ou igual a %{count}"
|
219
|
-
equal_to: "deve ser igual a %{count}"
|
220
|
-
less_than: "deve ser menor que %{count}"
|
221
|
-
less_than_or_equal_to: "deve ser menor ou igual a %{count}"
|
222
|
-
odd: "deve ser ímpar"
|
223
|
-
even: "deve ser par"
|
224
|
-
|
225
|
-
activerecord:
|
226
|
-
errors:
|
227
|
-
template:
|
228
|
-
header:
|
229
|
-
one: "Não foi possível gravar %{model}: 1 erro"
|
230
|
-
other: "Não foi possível gravar %{model}: %{count} erros."
|
231
|
-
body: "Por favor, verifique o(s) seguinte(s) campo(s):"
|
232
|
-
|
233
|
-
messages:
|
234
|
-
taken: "já está em uso"
|
235
|
-
record_invalid: "A validação falhou: %{errors}"
|
236
|
-
<<: *errors_messages
|
237
|
-
|
238
|
-
full_messages:
|
239
|
-
format: "%{attribute} %{message}"
|
data/test/in_simple.yml
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
pt-BR:
|
2
|
-
# Note how this is a nice way of inputing
|
3
|
-
# paragraphs of text in YAML.
|
4
|
-
apples: >
|
5
|
-
Maçãs são boas,
|
6
|
-
só não coma
|
7
|
-
seus iPods!
|
8
|
-
grapes: Não comemos elas.
|
9
|
-
bananas: |
|
10
|
-
Bananas são "legais":
|
11
|
-
- Elas são <b> doces </b>.
|
12
|
-
isto: não é chave
|
13
|
-
|
14
|
-
Por isto todos gostam de bananas!
|
15
|
-
en-US:
|
16
|
-
# Note that our comments are important:
|
17
|
-
# Don't let your yaml sorter delete them!
|
18
|
-
grapes: We dont' eat them.
|
19
|
-
bananas: |
|
20
|
-
Bananas are "nice":
|
21
|
-
- They are <b> sweet </b>.
|
22
|
-
this: not a key
|
23
|
-
|
24
|
-
That is why everyone like bananas!
|
25
|
-
apples: >
|
26
|
-
Apples are fine,
|
27
|
-
just don't eat your
|
28
|
-
iPods!
|
data/test/out.yml
DELETED
@@ -1,61 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
a_one: José # Comentado
|
3
|
-
b_two:
|
4
|
-
a_1: Joãozinho
|
5
|
-
b_two: |
|
6
|
-
Nos somos legais, como
|
7
|
-
por exemplo: João,
|
8
|
-
que: gosta de nos dar milhões
|
9
|
-
em dinheiro todos os dias.
|
10
|
-
|
11
|
-
Linhas em Branco com tabulação
|
12
|
-
nos strings devem ser preservadas.
|
13
|
-
|
14
|
-
c_three:
|
15
|
-
a: "Marcelo"
|
16
|
-
"b": Bernardo
|
17
|
-
c_3:
|
18
|
-
klass: Lucas
|
19
|
-
unify: Luiz
|
20
|
-
d_4: Rafael
|
21
|
-
# Comentário de muitas
|
22
|
-
# linhas (goes with d_4)
|
23
|
-
d_four: "Somos chatos
|
24
|
-
gostamos de várias linhas\"
|
25
|
-
e ainda usamos escaping
|
26
|
-
para fuder"
|
27
|
-
e_five: Prefirimos strings sem
|
28
|
-
nenhum tipo de especificação.
|
29
|
-
f_six: Dalton
|
30
|
-
c_three: Gustavo
|
31
|
-
# Comentário (goes with c_three)
|
32
|
-
d_four: Oliveira
|
33
|
-
e_five:
|
34
|
-
a_one: Rodrigo
|
35
|
-
# Comentário (goes with a_one)
|
36
|
-
b_two: Catarina
|
37
|
-
f_six: Thiago
|
38
|
-
"g-seven": Marcelo
|
39
|
-
h_eight: "Jonivildo"
|
40
|
-
i_nine: Prestes
|
41
|
-
j_ten: >
|
42
|
-
Pior quando resolvemos escrever
|
43
|
-
assim, impossível aturar!
|
44
|
-
k_eleven: Ronaldo
|
45
|
-
"l_other123123": Emilio
|
46
|
-
m_13: >
|
47
|
-
Não deve dar problema aqui!
|
48
|
-
Não deve dar problema aqui!
|
49
|
-
Não deve dar problema aqui!
|
50
|
-
Pois às vezes dá.
|
51
|
-
n_14: >
|
52
|
-
Não deve dar problema aqui!
|
53
|
-
Pois às vezes dá.
|
54
|
-
o_15: |
|
55
|
-
Não deve dar problema aqui!
|
56
|
-
Pois às vezes dá.
|
57
|
-
o_15: |
|
58
|
-
Não deve dar problema aqui!
|
59
|
-
Pois às vezes dá.
|
60
|
-
p_16: Não deve dar problema aqui!
|
61
|
-
Pois às vezes dá.
|
data/test/out_rails.yml
DELETED
@@ -1,220 +0,0 @@
|
|
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
DELETED
@@ -1,28 +0,0 @@
|
|
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,48 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/helper'
|
2
|
-
|
3
|
-
class TestI18nYamlSorter < Test::Unit::TestCase
|
4
|
-
def test_should_sort_complex_sample_file
|
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
|
-
end
|
10
|
-
end
|
11
|
-
end
|
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
|
-
|
31
|
-
def test_should_not_alter_the_serialized_yaml
|
32
|
-
#ordering should'n t change a thing, since hashes don't have order in Ruby
|
33
|
-
open(File.dirname(__FILE__) + '/in.yml') do |file|
|
34
|
-
sorter = I18nYamlSorter::Sorter.new(file)
|
35
|
-
present = YAML::load(file.read)
|
36
|
-
file.rewind
|
37
|
-
future = YAML::load(sorter.sort)
|
38
|
-
assert_equal present, future
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def test_command_line_should_work_in_stdin
|
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
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|