bai-rubyglot 0.1.0 → 0.1.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.
- data/libraries/rubyglot/i18n.rb +2 -1
- data/rakefile +36 -4
- data/rubyglot.gemspec +2 -2
- data/specifications/i18n_spec.rb +4 -4
- metadata +1 -3
- data/templates/dictionary.erb +0 -17
data/libraries/rubyglot/i18n.rb
CHANGED
@@ -23,7 +23,8 @@ module RubyGlot #:nodoc:
|
|
23
23
|
@@dictionary
|
24
24
|
end
|
25
25
|
|
26
|
-
def lookup(string_to_lookup,
|
26
|
+
def lookup(string_to_lookup, *args)
|
27
|
+
context = args.first.is_a?(Symbol) ? args.delete_at(0) : :default
|
27
28
|
localized = @@dictionary.entries[string_to_lookup][context.to_sym][:localized] rescue string_to_lookup
|
28
29
|
sprintf(localized, *args)
|
29
30
|
end
|
data/rakefile
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
%w(rubygems rake/gempackagetask spec/rake/spectask erb libraries/rubyglot
|
1
|
+
%w(rubygems rake/gempackagetask spec/rake/spectask erb libraries/rubyglot).each { |x| require x }
|
2
2
|
|
3
3
|
Spec::Rake::SpecTask.new("specs") do |t|
|
4
4
|
t.spec_opts << '--format' << 'specdoc' << '--colour'
|
@@ -11,9 +11,24 @@ namespace :rubyglot do
|
|
11
11
|
scan, storage = ENV["SCAN"], ENV["STORAGE"]
|
12
12
|
locales = ENV["LOCALES"] ? ENV["LOCALES"].split(",") : ["en_US.UTF-8"]
|
13
13
|
|
14
|
-
template =
|
14
|
+
template = %{require "rubyglot/dictionary_definition"
|
15
15
|
|
16
|
-
|
16
|
+
module RubyGlot
|
17
|
+
module Definitions
|
18
|
+
include DictionaryDefinition
|
19
|
+
|
20
|
+
dictionary "<%= @locale %>" do |d|
|
21
|
+
<% @entries.each do |entry| -%>
|
22
|
+
d.entry "<%= entry %>", {
|
23
|
+
:default => { :localized => "<%= entry %>", :state => "active" }
|
24
|
+
}
|
25
|
+
<% end -%>
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
}
|
30
|
+
|
31
|
+
@entries = get_localizable_strings(scan)
|
17
32
|
|
18
33
|
locales.each do |locale|
|
19
34
|
@locale = locale
|
@@ -26,7 +41,24 @@ namespace :rubyglot do
|
|
26
41
|
scan = ENV["SCAN"]
|
27
42
|
storage = ENV["STORAGE"]
|
28
43
|
locales = ENV["LOCALES"] ? ENV["LOCALES"].split(",") : Dir.glob("#{ENV['STORAGE']}/*.rb").collect { |f| File.basename(f).gsub(".rb", "") }
|
29
|
-
template =
|
44
|
+
template = %{require "rubyglot/dictionary_definition"
|
45
|
+
|
46
|
+
module RubyGlot
|
47
|
+
module Definitions
|
48
|
+
include DictionaryDefinition
|
49
|
+
|
50
|
+
dictionary "<%= @locale %>" do |d|
|
51
|
+
<% @entries.each do |entry| -%>
|
52
|
+
d.entry "<%= entry[0] %>", {
|
53
|
+
<% (array = entry[1].to_a).each do |k, v| -%>
|
54
|
+
:<%= k %> => { :localized => "<%= v[:localized] %>", :state => "<%= v[:state] %>" }<%= "," unless k == array.last[0] %>
|
55
|
+
<% end -%>
|
56
|
+
}
|
57
|
+
<% end -%>
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
}
|
30
62
|
|
31
63
|
locales.each do |locale|
|
32
64
|
RubyGlot.current_locale = locale
|
data/rubyglot.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "rubyglot"
|
3
|
-
s.version = "0.1.0"
|
3
|
+
s.version = "0.1.0.1"
|
4
4
|
s.date = "2008-07-07"
|
5
5
|
s.summary = "Ruby internationalization."
|
6
6
|
s.email = "beawesomeinstead@yahoo.com"
|
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
|
|
9
9
|
s.authors = ["beawesomeinstead"]
|
10
10
|
s.has_rdoc = false
|
11
11
|
s.require_paths = ["libraries"]
|
12
|
-
s.files = ["libraries", "libraries/rubyglot", "libraries/rubyglot/dictionary.rb", "libraries/rubyglot/i18n.rb", "libraries/rubyglot/dictionary_definition.rb", "libraries/rubyglot.rb", "rakefile", "rubyglot.gemspec", "specifications", "specifications/i18n_spec.rb", "specifications/spec_helper.rb", "readme", "
|
12
|
+
s.files = ["libraries", "libraries/rubyglot", "libraries/rubyglot/dictionary.rb", "libraries/rubyglot/i18n.rb", "libraries/rubyglot/dictionary_definition.rb", "libraries/rubyglot.rb", "rakefile", "rubyglot.gemspec", "specifications", "specifications/i18n_spec.rb", "specifications/spec_helper.rb", "readme", "readme", "rakefile", "rubyglot.gemspec"]
|
13
13
|
end
|
14
14
|
|
15
15
|
# Dir.glob("**/*") + ["readme", "rakefile", "rubyglot.gemspec"]
|
data/specifications/i18n_spec.rb
CHANGED
@@ -13,21 +13,21 @@ describe RubyGlot do
|
|
13
13
|
|
14
14
|
it "should translate strings with namespace (Original/English)" do
|
15
15
|
RubyGlot.current_locale = "en_US.UTF-8"
|
16
|
-
localize("lolcatz",
|
16
|
+
localize("lolcatz", :dogs).should == "loldogs"
|
17
17
|
end
|
18
18
|
|
19
19
|
it "should translate strings with namespace (Original/Russian)" do
|
20
20
|
RubyGlot.current_locale = "ru_RU.UTF-8"
|
21
|
-
localize("lolcatz",
|
21
|
+
localize("lolcatz", :dogs).should == "смешные собачки"
|
22
22
|
end
|
23
23
|
|
24
24
|
it "should translate strings with number formatting (Original/English)" do
|
25
25
|
RubyGlot.current_locale = "en_US.UTF-8"
|
26
|
-
localize("lol %03d dogs",
|
26
|
+
localize("lol %03d dogs", :dogs, 16).should == "lol 016 dogs"
|
27
27
|
end
|
28
28
|
|
29
29
|
it "should translate strings with number formatting (Original/Russian)" do
|
30
30
|
RubyGlot.current_locale = "ru_RU.UTF-8"
|
31
|
-
localize("lol %03d dogs",
|
31
|
+
localize("lol %03d dogs", :dogs, 16).should == "лол 0016 собачек"
|
32
32
|
end
|
33
33
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bai-rubyglot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0
|
4
|
+
version: 0.1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- beawesomeinstead
|
@@ -34,8 +34,6 @@ files:
|
|
34
34
|
- specifications/i18n_spec.rb
|
35
35
|
- specifications/spec_helper.rb
|
36
36
|
- readme
|
37
|
-
- templates
|
38
|
-
- templates/dictionary.erb
|
39
37
|
has_rdoc: false
|
40
38
|
homepage: http://github.com/beawesomeinstead/rubyglot/wikis
|
41
39
|
post_install_message:
|
data/templates/dictionary.erb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
require "rubyglot/dictionary_definition"
|
2
|
-
|
3
|
-
module RubyGlot
|
4
|
-
module Definitions
|
5
|
-
include DictionaryDefinition
|
6
|
-
|
7
|
-
dictionary "<%= @locale %>" do |d|
|
8
|
-
<% @entries.each do |entry| -%>
|
9
|
-
d.entry "<%= entry[0] %>", {
|
10
|
-
<% (array = entry[1].to_a).each do |k, v| -%>
|
11
|
-
:<%= k %> => { :localized => "<%= v[:localized] %>", :state => "<%= v[:state] %>" }<%= "," unless k == array.last[0] %>
|
12
|
-
<% end -%>
|
13
|
-
}
|
14
|
-
<% end -%>
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|