visionmedia-translatable 0.0.1 → 0.0.2

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 CHANGED
@@ -3,6 +3,21 @@
3
3
 
4
4
  High performance, minimalistic translation library
5
5
 
6
+ == Description:
7
+
8
+ Translatable differs from many I18N libraries for Ruby in the fact
9
+ that most, if not all require you to store the entire original English
10
+ strings in an arbitrary location. With Translatable you can write your
11
+ English strings just as you would any other string, then translate as
12
+ necessary in external files. This allows for greater readability in code
13
+ rather than see constants or method calls similar to:
14
+
15
+ puts I18N.welcome_message_for_home_page, user.name
16
+
17
+ where with translatable this would simply be:
18
+
19
+ puts 'Hello %s, welcome to our site.'.t user.name
20
+
6
21
  == License:
7
22
 
8
23
  (The MIT License)
data/Todo.rdoc CHANGED
@@ -1,6 +1,14 @@
1
1
 
2
2
  == Major:
3
3
 
4
+ * How does Rack etc use threads? does it contain mutexs?? how can something be run once
5
+ * Thread safe branch (on github too)
6
+ * Thread safe / (test slow-down with mutex) / test in threads
7
+ * Use YAML since its only loaded once ? or does Thin load the app each time? test the state
8
+ * Pluralization
9
+ * RFC 3066
4
10
  * Faster !!!
11
+ * Exec, parse file(s) for translatable strings
5
12
  * Docs
6
13
  * HTML entity escaping (optional but default)
14
+ * C
@@ -4,7 +4,7 @@ require 'benchmark'
4
4
  require File.dirname(__FILE__) + '/../lib/translatable'
5
5
  require File.dirname(__FILE__) + '/faux_translations'
6
6
 
7
- n = ENV['TIMES'].to_i || 1000
7
+ n = (ENV['TIMES'] || 1000).to_i
8
8
  puts "\nEach report ran %d times with %d faux translations\n\n" % [n, translations[:en].length]
9
9
  Benchmark.bm(25) do |x|
10
10
  x.report("String") {
@@ -31,7 +31,7 @@ class String
31
31
  if t.language == :en and not t.english_translations_allowed?
32
32
  self % args
33
33
  else
34
- s = t.translations[t.language][self] rescue self
34
+ s = (t.translations[t.language][self] || self) rescue self
35
35
  s % args
36
36
  end
37
37
  end
@@ -1,7 +1,7 @@
1
1
 
2
2
  module Translatable
3
3
  module VERSION #:nodoc:
4
- MAJOR, MINOR, TINY = [0, 0, 1]
4
+ MAJOR, MINOR, TINY = [0, 0, 2]
5
5
  STRING = [MAJOR, MINOR, TINY].join '.'
6
6
  end
7
7
  end
@@ -5,18 +5,18 @@ describe "Translateable" do
5
5
  disallow_english_translations
6
6
  end
7
7
 
8
- it "should not allow overriding of english strings" do
9
- translate :en, 'foo' => 'bar'
10
- 'foo'.t.should eql('foo')
11
- 'foo'.t.should_not eql('bar')
12
- end
13
-
14
8
  it "should allow overriding of english strings" do
15
9
  allow_english_translations
16
10
  translate :en, 'foo' => 'bar'
17
11
  'foo'.t.should eql('bar')
18
12
  end
19
13
 
14
+ it "should not allow overriding of english strings" do
15
+ translate :en, 'foo' => 'bar'
16
+ 'foo'.t.should eql('foo')
17
+ 'foo'.t.should_not eql('bar')
18
+ end
19
+
20
20
  it "should allow overriding of strings in english with placeholders" do
21
21
  allow_english_translations
22
22
  translate :en, 'Your username is %s, you may also login using %s.' => 'Try your email %2$s, or maybe the username %1$s.'
@@ -31,4 +31,8 @@ describe "Translateable" do
31
31
  string.should eql("J'aime cookies")
32
32
  end
33
33
 
34
+ it "should translate symbols once converted to strings" do
35
+ :test.to_s.t.should eql('test')
36
+ end
37
+
34
38
  end
data/translatable.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{translatable}
5
- s.version = "0.0.1"
5
+ s.version = "0.0.2"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["TJ Holowaychuk"]
9
- s.date = %q{2008-12-11}
9
+ s.date = %q{2009-01-15}
10
10
  s.description = %q{High performance, minimalistic translation library}
11
11
  s.email = %q{tj@vision-media.ca}
12
12
  s.extra_rdoc_files = ["lib/translatable/string.rb", "lib/translatable/translatable.rb", "lib/translatable/version.rb", "lib/translatable.rb", "README.rdoc"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: visionmedia-translatable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - TJ Holowaychuk
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-12-11 00:00:00 -08:00
12
+ date: 2009-01-15 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency