grosser-fast_gettext 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  FastGettext
2
2
  ===========
3
- GetText but 9.17 times faster, simple, clean namespace (7 vs 34) and threadsave!
3
+ GetText but 7 times faster, simple, clean namespace (7 vs 34) and threadsave!
4
4
 
5
5
  [Example Rails application](https://github.com/grosser/gettext_i18n_rails_example)
6
6
 
@@ -39,19 +39,20 @@ Performance
39
39
  50_000 translations speed / memory
40
40
  small translation file <-> large translation file
41
41
  Baseline: (doing nothing in a loop)
42
- 0.410000s / 2904K <->
42
+ 0.460000s / 2904K
43
43
 
44
44
  Ideal: (primitive Hash lookup)
45
- 1.150000s / 3016K <-> 1.130000s / 3016K
45
+ 1.180000s / 3016K <-> 1.140000s / 3016K
46
46
 
47
47
  FastGettext:
48
- 1.800000s / 3040K <-> 1.750000s / 3040K
48
+ 2.180000s / 3036K <-> 2.430000s / 3152K
49
49
 
50
- GetText:
51
- 16.510000s / 5900K <-> 16.400000s / 6072K
50
+ GetText 2.0:
51
+ 15.250000s / 11784K <-> 15.640000s / 12192K
52
52
 
53
53
  ActiveSupport I18n::Backend::Simple :
54
- 31.880000s / 10028K <->
54
+ 32.670000s / 12488K
55
+
55
56
 
56
57
 
57
58
  Thread Safety and Rails
@@ -77,7 +78,7 @@ then e.g. controllers, so set them inside your application_controller.
77
78
  def set_locale
78
79
  FastGettext.available_locales = ['de','en',...]
79
80
  FastGettext.text_domain = 'frontend'
80
- sessions[:locale] = I18n.locale = FastGettext.set_locale(params[:locale] || sessions[:locale] || request.env['HTTP_ACCEPT_LANGUAGE'] || 'en')
81
+ session[:locale] = I18n.locale = FastGettext.set_locale(params[:locale] || session[:locale] || request.env['HTTP_ACCEPT_LANGUAGE'] || 'en')
81
82
  end
82
83
 
83
84
  #application_helper.rb
@@ -114,4 +115,4 @@ Mo/Po-file parsing from Masao Mutoh, see vendor/README
114
115
 
115
116
  [Michael Grosser](http://pragmatig.wordpress.com)
116
117
  grosser.michael@gmail.com
117
- Hereby placed under public domain, do what you want, just do not hold me accountable...
118
+ Hereby placed under public domain, do what you want, just do not hold me accountable...
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 0
3
3
  :minor: 3
4
- :patch: 2
4
+ :patch: 3
@@ -6,15 +6,14 @@ module FastGettext
6
6
  module Storage
7
7
  class NoTextDomainConfigured < Exception;end
8
8
 
9
- [:available_locales,:text_domain,:_locale,:current_cache].each do |method|
10
- eval <<EOF
11
- def #{method}
12
- Thread.current[:fast_gettext_#{method}]
9
+ [:available_locales,:text_domain,:_locale,:current_cache].each do |method_name|
10
+ key = "fast_gettext_#{method_name}".to_sym
11
+ define_method method_name do
12
+ Thread.current[key]
13
13
  end
14
- def #{method}=(value)
15
- Thread.current[:fast_gettext_#{method}]=value
14
+ define_method "#{method_name}=" do |value|
15
+ Thread.current[key]=value
16
16
  end
17
- EOF
18
17
  end
19
18
  private :_locale, :_locale=
20
19
  #so initial translations does not crash
@@ -102,4 +101,4 @@ EOF
102
101
  self.current_cache = caches[text_domain][locale]
103
102
  end
104
103
  end
105
- end
104
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grosser-fast_gettext
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Grosser
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-03-20 00:00:00 -07:00
12
+ date: 2009-03-31 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15