grosser-fast_gettext 0.3.2 → 0.3.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/README.markdown +10 -9
- data/VERSION.yml +1 -1
- data/lib/fast_gettext/storage.rb +7 -8
- metadata +2 -2
data/README.markdown
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
FastGettext
|
2
2
|
===========
|
3
|
-
GetText but
|
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.
|
42
|
+
0.460000s / 2904K
|
43
43
|
|
44
44
|
Ideal: (primitive Hash lookup)
|
45
|
-
1.
|
45
|
+
1.180000s / 3016K <-> 1.140000s / 3016K
|
46
46
|
|
47
47
|
FastGettext:
|
48
|
-
|
48
|
+
2.180000s / 3036K <-> 2.430000s / 3152K
|
49
49
|
|
50
|
-
GetText:
|
51
|
-
|
50
|
+
GetText 2.0:
|
51
|
+
15.250000s / 11784K <-> 15.640000s / 12192K
|
52
52
|
|
53
53
|
ActiveSupport I18n::Backend::Simple :
|
54
|
-
|
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
|
-
|
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...
|
data/VERSION.yml
CHANGED
data/lib/fast_gettext/storage.rb
CHANGED
@@ -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 |
|
10
|
-
|
11
|
-
|
12
|
-
Thread.current[
|
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
|
-
|
15
|
-
Thread.current[
|
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.
|
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-
|
12
|
+
date: 2009-03-31 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|