i18n_sort_keys 0.0.1

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.
@@ -0,0 +1,10 @@
1
+ Rake Task for sorting locales keys.
2
+
3
+ Put the task under lib/tasks
4
+
5
+ Without parameter, recursively sort all yaml locales under RAILS_ROOT/config/locales
6
+ rake i18n:sort_keys
7
+
8
+ With parameter, sort only one locale
9
+ rake i18n:sort_keys[path_to_locale]
10
+
@@ -0,0 +1,30 @@
1
+ require 'rake'
2
+ require 'yaml'
3
+
4
+ class Hash
5
+
6
+ def to_yaml( opts = {} )
7
+ YAML::quick_emit( object_id, opts ) do |out|
8
+ out.map( taguri, to_yaml_style ) do |map|
9
+ sort.each do |k, v|
10
+ map.add( k, v )
11
+ end
12
+ end
13
+ end
14
+ end
15
+
16
+ end
17
+
18
+ namespace :i18n do
19
+
20
+ desc "Sort locales keys in alphabetic order. Sort all locales if no path parameter given"
21
+
22
+ task :sort_keys, [:path_to_file] => :environment do |t , args|
23
+ locales = args[:path_to_file] || Dir.glob("#{RAILS_ROOT}/config/locales/**/*.yml")
24
+
25
+ locales.each do |locale_path|
26
+ yaml = File.open(locale_path) { |f| YAML::load(f) }
27
+ File.open(locale_path, 'w') { |f| YAML.dump(yaml, f)}
28
+ end
29
+ end
30
+ end
@@ -0,0 +1 @@
1
+ import File.join(File.dirname(__FILE__), "i18n_sort_keys.rake")
@@ -0,0 +1,3 @@
1
+ module I18nSortKeys
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,84 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: i18n_sort_keys
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Philippe Cantin
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-03-11 00:00:00 +01:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: rake
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ description: Sort locales keys in alphabetic order. Sort all locales if no path parameter given
36
+ email:
37
+ - anoiaque@gmail.com
38
+ executables: []
39
+
40
+ extensions: []
41
+
42
+ extra_rdoc_files:
43
+ - README.rdoc
44
+ files:
45
+ - lib/i18n_sort_keys/version.rb
46
+ - lib/i18n_sort_keys.rb
47
+ - lib/i18n_sort_keys.rake
48
+ - README.rdoc
49
+ has_rdoc: true
50
+ homepage: ""
51
+ licenses: []
52
+
53
+ post_install_message:
54
+ rdoc_options: []
55
+
56
+ require_paths:
57
+ - lib
58
+ required_ruby_version: !ruby/object:Gem::Requirement
59
+ none: false
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ hash: 3
64
+ segments:
65
+ - 0
66
+ version: "0"
67
+ required_rubygems_version: !ruby/object:Gem::Requirement
68
+ none: false
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ hash: 3
73
+ segments:
74
+ - 0
75
+ version: "0"
76
+ requirements: []
77
+
78
+ rubyforge_project: i18n_sort_keys
79
+ rubygems_version: 1.3.7
80
+ signing_key:
81
+ specification_version: 3
82
+ summary: Sort rails locales files in lexical order
83
+ test_files: []
84
+