i18n-js 0.1.0 → 0.1.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.
- data/README.rdoc +10 -0
- data/lib/i18n-js.rb +2 -2
- data/lib/i18n-js/version.rb +1 -1
- data/test/i18n_js_test.rb +3 -3
- data/test/test_helper.rb +1 -0
- metadata +9 -4
data/README.rdoc
CHANGED
@@ -11,6 +11,16 @@ This library has been tested on:
|
|
11
11
|
|
12
12
|
== Usage
|
13
13
|
|
14
|
+
=== Installation
|
15
|
+
|
16
|
+
You can use I18n-JS as plugin and gem. Choose what's best for you!
|
17
|
+
|
18
|
+
script/plugin install git://github.com/fnando/i18n-js.git
|
19
|
+
|
20
|
+
or
|
21
|
+
|
22
|
+
gem install i18n-js
|
23
|
+
|
14
24
|
=== Setting up
|
15
25
|
|
16
26
|
Run <tt>rake i18n:setup</tt> to copy <tt>i18n.js</tt> to your javascript directory and <tt>i18n-js.yml</tt> to your config folder (if not already present). Then you're ready to go!
|
data/lib/i18n-js.rb
CHANGED
@@ -69,7 +69,7 @@ module SimplesIdeias
|
|
69
69
|
File.open(file, "w+") do |f|
|
70
70
|
f << %(var I18n = I18n || {};\n)
|
71
71
|
f << %(I18n.translations = );
|
72
|
-
f << sorted_hash(translations).to_json
|
72
|
+
f << sorted_hash(translations, true).to_json
|
73
73
|
f << %(;)
|
74
74
|
end
|
75
75
|
end
|
@@ -122,7 +122,7 @@ module SimplesIdeias
|
|
122
122
|
# Taken from http://seb.box.re/2010/1/15/deep-hash-ordering-with-ruby-1-8/
|
123
123
|
def sorted_hash(object, deep = false) # :nodoc:
|
124
124
|
if object.is_a?(Hash)
|
125
|
-
res =
|
125
|
+
res = ActiveSupport::OrderedHash.new.tap do |map|
|
126
126
|
object.each {|k, v| map[k] = deep ? sorted_hash(v, deep) : v }
|
127
127
|
end
|
128
128
|
return res.class[res.sort {|a, b| a[0].to_s <=> b[0].to_s } ]
|
data/lib/i18n-js/version.rb
CHANGED
data/test/i18n_js_test.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "test_helper"
|
2
2
|
|
3
3
|
class I18nJSTest < ActiveSupport::TestCase
|
4
4
|
setup do
|
@@ -132,7 +132,7 @@ class I18nJSTest < ActiveSupport::TestCase
|
|
132
132
|
end
|
133
133
|
|
134
134
|
test "sorted hash" do
|
135
|
-
|
135
|
+
assert_not_equal [:a, :b, :c], {:b => 1, :a => 2, :c => 3}.keys
|
136
136
|
assert_equal [:a, :b, :c], SimplesIdeias::I18n.sorted_hash(:b => 1, :a => 2, :c => 3).keys
|
137
137
|
end
|
138
138
|
|
@@ -141,7 +141,7 @@ class I18nJSTest < ActiveSupport::TestCase
|
|
141
141
|
:foo => {:b => 1, :a => 2, :c => 3}
|
142
142
|
}
|
143
143
|
|
144
|
-
|
144
|
+
assert_not_equal [:a, :b, :c], hash[:foo].keys
|
145
145
|
assert_equal [:a, :b, :c], SimplesIdeias::I18n.sorted_hash(hash[:foo]).keys
|
146
146
|
end
|
147
147
|
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: i18n-js
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 25
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 0
|
7
8
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Nando Vieira
|
@@ -14,7 +15,7 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2010-07-
|
18
|
+
date: 2010-07-27 00:00:00 -03:00
|
18
19
|
default_executable:
|
19
20
|
dependencies: []
|
20
21
|
|
@@ -59,23 +60,27 @@ rdoc_options:
|
|
59
60
|
require_paths:
|
60
61
|
- lib
|
61
62
|
required_ruby_version: !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
62
64
|
requirements:
|
63
65
|
- - ">="
|
64
66
|
- !ruby/object:Gem::Version
|
67
|
+
hash: 3
|
65
68
|
segments:
|
66
69
|
- 0
|
67
70
|
version: "0"
|
68
71
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
69
73
|
requirements:
|
70
74
|
- - ">="
|
71
75
|
- !ruby/object:Gem::Version
|
76
|
+
hash: 3
|
72
77
|
segments:
|
73
78
|
- 0
|
74
79
|
version: "0"
|
75
80
|
requirements: []
|
76
81
|
|
77
82
|
rubyforge_project:
|
78
|
-
rubygems_version: 1.3.
|
83
|
+
rubygems_version: 1.3.7
|
79
84
|
signing_key:
|
80
85
|
specification_version: 3
|
81
86
|
summary: It's a small library to provide the Rails I18n translations on the Javascript.
|