README.markdown in grosser-fast_gettext-0.2.4 vs README.markdown in grosser-fast_gettext-0.2.5
- old
+ new
@@ -1,8 +1,8 @@
FastGettext
===========
-GetText but fast + simple + threadsave!
+GetText but 4 times faster, simple, clean namespace (7 vs 34) and threadsave!
Setup
=====
sudo gem install grosser-fast_gettext -s http://gems.github.com/
@@ -14,38 +14,48 @@
FastGettext.text_domain = 'my_app'
FastGettext.available_locales = ['de','en','fr','en_US','en_UK'] # only allow these locales to be set (optional)
FastGettext.locale = 'de'
Start translating
- include FastGettext
+ include FastGettext::Translation
_('Car') == 'Auto'
_('not-found') == 'not-found'
s_('Namespace|no-found') == 'not-found'
n_('Axis','Axis',3) == 'Achsen' #German plural of Axis
Speed
=====
-FastGettext
- small:
- 1.000000 0.130000 1.130000 ( 1.132578)
- mapped: 8620K writeable/private: 5588K shared: 28K
+50_000 translations:
+Ideal: (primitive Hash lookup)
+ small translation file:
+ 1.100000 0.180000 1.280000 ( 1.287230)
+ mapped: 5832K writeable/private: 3016K shared: 28K
- large:
- 1.060000 0.100000 1.160000 ( 1.163962)
- mapped: 8620K writeable/private: 5588K shared: 28K
+ large translation file:
+ 1.150000 0.150000 1.300000 ( 1.296114)
+ mapped: 5832K writeable/private: 3016K shared: 28K
+FastGettext:
+ small translation file:
+ 3.980000 0.430000 4.410000 ( 4.407260)
+ mapped: 5852K writeable/private: 3036K shared: 28K
-GetText
- small:
- 3.220000 0.260000 3.480000 ( 3.478093)
- mapped: 9036K writeable/private: 6004K shared: 28K
+ large translation file:
+ 4.070000 0.450000 4.520000 ( 4.515585)
+ mapped: 5972K writeable/private: 3156K shared: 28K
- large:
- 3.280000 0.230000 3.510000 ( 3.511891)
- mapped: 9156K writeable/private: 6124K shared: 28K
+GetText:
+ small translation file:
+ 16.280000 1.340000 17.620000 ( 17.630391)
+ mapped: 8976K writeable/private: 5944K shared: 28K
+ large translation file:
+ 16.590000 1.430000 18.020000 ( 18.042926)
+ mapped: 9024K writeable/private: 5992K shared: 28K
+
+
Thread Safety and Rails
=======================
`text_domains` is not stored thread-save, so that they can be added inside the `environment.rb`,
and do not need to be readded for every thread (parsing takes time...).
@@ -57,20 +67,20 @@
FastGettext.add_text_domain('frontend',:path=>'locale')
...
#application_controller.rb
class ApplicationController ...
- include FastGettext
+ include FastGettext::Translation
before_filter :set_locale
def set_locale
FastGettext.available_locales = ['de','en',...]
FastGettext.text_domain = 'frontend'
sessions[:locale] = I18n.locale = FastGettext.locale = params[:locale] || sessions[:locale] || 'en'
end
#application_helper.rb
module ApplicationHelper
- include FastGettext
+ include FastGettext::Translation
...
Try the [gettext_i18n_rails plugin](http://github.com/grosser/gettext_i18n_rails), it simplifies the setup.
Updating translations
\ No newline at end of file