localite 0.1 → 0.1.3
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/VERSION +1 -1
- data/lib/localite.rb +16 -12
- data/lib/localite/translate.rb +2 -2
- data/localite.gemspec +2 -2
- data/tasks/echoe.rake +3 -3
- data/test/test.rb +2 -1
- metadata +2 -2
- data/init.rb +0 -11
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1
|
1
|
+
0.1.3
|
data/lib/localite.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require "logger"
|
2
|
+
require "i18n"
|
2
3
|
|
3
4
|
#
|
4
5
|
# This is a *really* simple template and translation engine.
|
@@ -9,32 +10,34 @@ module Localite; end
|
|
9
10
|
|
10
11
|
file_dir = File.expand_path(File.dirname(__FILE__))
|
11
12
|
|
12
|
-
# require "#{file_dir}/localite/missing_translation"
|
13
13
|
require "#{file_dir}/localite/scope"
|
14
14
|
require "#{file_dir}/localite/settings"
|
15
15
|
require "#{file_dir}/localite/translate"
|
16
16
|
require "#{file_dir}/localite/template"
|
17
17
|
|
18
18
|
module Localite
|
19
|
-
#
|
20
|
-
# Add the Localite adapters for Strings ad Symbols.
|
21
|
-
def self.init
|
22
|
-
String.send :include, StringAdapter
|
23
|
-
Symbol.send :include, SymbolAdapter
|
24
|
-
end
|
25
|
-
|
26
19
|
#
|
27
20
|
# a logger
|
28
21
|
def self.logger
|
29
22
|
klass = defined?(ActiveSupport) ? ActiveSupport::BufferedLogger : Logger
|
30
23
|
|
31
|
-
@logger ||=
|
24
|
+
@logger ||= begin
|
25
|
+
klass.new("log/localite.log")
|
26
|
+
rescue Errno::ENOENT
|
27
|
+
::Logger.new(STDERR)
|
28
|
+
end
|
32
29
|
end
|
33
30
|
|
34
31
|
extend Settings
|
35
32
|
extend Translate
|
36
33
|
extend Scope
|
37
34
|
|
35
|
+
private
|
36
|
+
|
37
|
+
def self.template(template, *args)
|
38
|
+
Template.run mode, template, *args
|
39
|
+
end
|
40
|
+
|
38
41
|
public
|
39
42
|
|
40
43
|
#
|
@@ -69,9 +72,10 @@ module Localite
|
|
69
72
|
end
|
70
73
|
end
|
71
74
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
+
#
|
76
|
+
# == initialize Localite adapters =======================================
|
77
|
+
::String.send :include, StringAdapter
|
78
|
+
::Symbol.send :include, SymbolAdapter
|
75
79
|
end
|
76
80
|
|
77
81
|
module Localite::Etest
|
data/lib/localite/translate.rb
CHANGED
@@ -22,7 +22,7 @@ module Localite::Translate
|
|
22
22
|
|
23
23
|
def do_translate(locale, s)
|
24
24
|
scopes.each(s) do |scoped_string|
|
25
|
-
tr =
|
25
|
+
tr = translate_via_i18n locale, scoped_string
|
26
26
|
return tr if tr
|
27
27
|
end
|
28
28
|
|
@@ -30,7 +30,7 @@ module Localite::Translate
|
|
30
30
|
nil
|
31
31
|
end
|
32
32
|
|
33
|
-
def
|
33
|
+
def translate_via_i18n(locale, s)
|
34
34
|
locale = base unless I18n.backend.available_locales.include?(locale)
|
35
35
|
I18n.locale = locale
|
36
36
|
I18n.translate(s, :raise => true)
|
data/localite.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{localite}
|
5
|
-
s.version = "0.1"
|
5
|
+
s.version = "0.1.3"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["pboy"]
|
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.description = %q{An easy to use localization gem.}
|
11
11
|
s.email = %q{eno-pboy@open-lab.org}
|
12
12
|
s.extra_rdoc_files = ["lib/localite.rb", "lib/localite/rails_filter.rb", "lib/localite/scope.rb", "lib/localite/settings.rb", "lib/localite/template.rb", "lib/localite/translate.rb", "tasks/echoe.rake"]
|
13
|
-
s.files = ["Manifest", "Rakefile", "VERSION", "config/dependencies.rb", "config/gem.yml", "
|
13
|
+
s.files = ["Manifest", "Rakefile", "VERSION", "config/dependencies.rb", "config/gem.yml", "lib/localite.rb", "lib/localite/rails_filter.rb", "lib/localite/scope.rb", "lib/localite/settings.rb", "lib/localite/template.rb", "lib/localite/translate.rb", "localite.tmproj", "script/console", "script/rebuild", "tasks/echoe.rake", "test/i18n/de.yml", "test/initializers/fake_rails.rb", "test/test.rb", "localite.gemspec"]
|
14
14
|
s.homepage = %q{http://github.com/pboy/localite}
|
15
15
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Localite"]
|
16
16
|
s.require_paths = ["lib"]
|
data/tasks/echoe.rake
CHANGED
@@ -34,12 +34,12 @@ if gem_config = YAML.load(File.read("#{GEM_ROOT}/config/gem.yml"))
|
|
34
34
|
gem = Dir.glob("pkg/*.gem").sort_by do |filename|
|
35
35
|
File.new(filename).mtime
|
36
36
|
end.last
|
37
|
-
|
37
|
+
|
38
38
|
puts "============================================="
|
39
39
|
puts "Installing gem..."
|
40
|
-
|
40
|
+
|
41
41
|
system "gem install #{gem} > /dev/null 2>&1"
|
42
|
-
|
42
|
+
|
43
43
|
puts ""
|
44
44
|
puts "I built and installed the gem for you. To upload, run "
|
45
45
|
puts
|
data/test/test.rb
CHANGED
metadata
CHANGED
@@ -5,7 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
|
8
|
+
- 3
|
9
|
+
version: 0.1.3
|
9
10
|
platform: ruby
|
10
11
|
authors:
|
11
12
|
- pboy
|
@@ -48,7 +49,6 @@ files:
|
|
48
49
|
- VERSION
|
49
50
|
- config/dependencies.rb
|
50
51
|
- config/gem.yml
|
51
|
-
- init.rb
|
52
52
|
- lib/localite.rb
|
53
53
|
- lib/localite/rails_filter.rb
|
54
54
|
- lib/localite/scope.rb
|
data/init.rb
DELETED