fast_gettext 0.8.1 → 0.9.0

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.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/lib/fast_gettext/cache.rb +42 -0
  3. data/lib/fast_gettext/storage.rb +28 -55
  4. data/lib/fast_gettext/version.rb +1 -1
  5. metadata +105 -73
  6. data/.gitignore +0 -2
  7. data/.travis.yml +0 -17
  8. data/Appraisals +0 -8
  9. data/CHANGELOG +0 -8
  10. data/Gemfile +0 -10
  11. data/Gemfile.lock +0 -52
  12. data/Rakefile +0 -25
  13. data/Readme.md +0 -261
  14. data/benchmark/base.rb +0 -46
  15. data/benchmark/baseline.rb +0 -5
  16. data/benchmark/fast_gettext.rb +0 -18
  17. data/benchmark/i18n_simple.rb +0 -8
  18. data/benchmark/ideal.rb +0 -24
  19. data/benchmark/locale/de.yml +0 -126
  20. data/benchmark/locale/de/LC_MESSAGES/large.mo +0 -0
  21. data/benchmark/misc/threadsave.rb +0 -21
  22. data/benchmark/namespace/fast_gettext.rb +0 -15
  23. data/benchmark/namespace/original.rb +0 -14
  24. data/benchmark/original.rb +0 -22
  25. data/examples/db/migration.rb +0 -22
  26. data/examples/missing_translation_logger.rb +0 -13
  27. data/fast_gettext.gemspec +0 -12
  28. data/gemfiles/rails23.gemfile +0 -14
  29. data/gemfiles/rails23.gemfile.lock +0 -56
  30. data/gemfiles/rails32.gemfile +0 -14
  31. data/gemfiles/rails32.gemfile.lock +0 -112
  32. data/gemfiles/rails40.gemfile +0 -15
  33. data/gemfiles/rails40.gemfile.lock +0 -110
  34. data/spec/aa_unconfigued_spec.rb +0 -21
  35. data/spec/cases/fake_load_path/iconv.rb +0 -2
  36. data/spec/cases/iconv_fallback.rb +0 -22
  37. data/spec/cases/interpolate_i18n_after_fast_gettext.rb +0 -7
  38. data/spec/cases/interpolate_i18n_before_fast_gettext.rb +0 -9
  39. data/spec/cases/safe_mode_can_handle_locales.rb +0 -5
  40. data/spec/fast_gettext/mo_file_spec.rb +0 -35
  41. data/spec/fast_gettext/po_file_spec.rb +0 -35
  42. data/spec/fast_gettext/storage_spec.rb +0 -386
  43. data/spec/fast_gettext/translation_repository/base_spec.rb +0 -24
  44. data/spec/fast_gettext/translation_repository/chain_spec.rb +0 -98
  45. data/spec/fast_gettext/translation_repository/db_spec.rb +0 -114
  46. data/spec/fast_gettext/translation_repository/logger_spec.rb +0 -40
  47. data/spec/fast_gettext/translation_repository/mo_spec.rb +0 -58
  48. data/spec/fast_gettext/translation_repository/po_spec.rb +0 -65
  49. data/spec/fast_gettext/translation_repository/yaml_spec.rb +0 -84
  50. data/spec/fast_gettext/translation_repository_spec.rb +0 -33
  51. data/spec/fast_gettext/translation_spec.rb +0 -363
  52. data/spec/fast_gettext/vendor/iconv_spec.rb +0 -7
  53. data/spec/fast_gettext/vendor/string_spec.rb +0 -101
  54. data/spec/fast_gettext_spec.rb +0 -51
  55. data/spec/fuzzy_locale/de/test.po +0 -22
  56. data/spec/locale/de/LC_MESSAGES/test.mo +0 -0
  57. data/spec/locale/de/LC_MESSAGES/test2.mo +0 -0
  58. data/spec/locale/de/test.po +0 -74
  59. data/spec/locale/de/test2.po +0 -64
  60. data/spec/locale/en/LC_MESSAGES/plural_test.mo +0 -0
  61. data/spec/locale/en/LC_MESSAGES/test.mo +0 -0
  62. data/spec/locale/en/plural_test.po +0 -20
  63. data/spec/locale/en/test.po +0 -59
  64. data/spec/locale/gsw_CH/LC_MESSAGES/test.mo +0 -0
  65. data/spec/locale/gsw_CH/test.po +0 -61
  66. data/spec/locale/yaml/de.yml +0 -25
  67. data/spec/locale/yaml/de2.yml +0 -25
  68. data/spec/locale/yaml/en.yml +0 -21
  69. data/spec/locale/yaml/notfound.yml +0 -2
  70. data/spec/obsolete_locale/de/test.po +0 -21
  71. data/spec/spec_helper.rb +0 -42
  72. data/spec/support/be_accessible_matcher.rb +0 -8
@@ -1,8 +0,0 @@
1
- require 'benchmark/base'
2
- require 'active_support'
3
-
4
- I18n.backend = I18n::Backend::Simple.new
5
- I18n.load_path = ['benchmark/locale/de.yml']
6
- I18n.locale = :de
7
- puts "ActiveSupport I18n::Backend::Simple :"
8
- results_test{I18n.translate('activerecord.models.car')=='Auto'}
data/benchmark/ideal.rb DELETED
@@ -1,24 +0,0 @@
1
- require 'benchmark/base'
2
-
3
- $LOAD_PATH.unshift 'lib'
4
-
5
- module FastestGettext
6
- def set_domain(folder,domain,locale)
7
- @data = {}
8
- require 'fast_gettext/vendor/mofile'
9
- FastGettext::GetText::MOFile.open(File.join(folder,locale,'LC_MESSAGES',"#{domain}.mo"), "UTF-8").each{|k,v|@data[k]=v}
10
- end
11
- def _(word)
12
- @data[word]
13
- end
14
- end
15
-
16
-
17
- include FastestGettext
18
- set_domain(locale_folder('test'),'test','de')
19
- puts "Ideal: (primitive Hash lookup)"
20
- results_test{_('car') == 'Auto'}
21
-
22
- #i cannot add the large file, since its an internal applications mo file
23
- set_domain(locale_folder('large'),'large','de')
24
- results_large
@@ -1,126 +0,0 @@
1
- # German translations for Ruby on Rails
2
- # by Clemens Kofler (clemens@railway.at)
3
-
4
- de:
5
- date:
6
- formats:
7
- default: "%d.%m.%Y"
8
- short: "%e. %b"
9
- long: "%e. %B %Y"
10
- only_day: "%e"
11
-
12
- day_names: [Sonntag, Montag, Dienstag, Mittwoch, Donnerstag, Freitag, Samstag]
13
- abbr_day_names: [So, Mo, Di, Mi, Do, Fr, Sa]
14
- month_names: [~, Januar, Februar, März, April, Mai, Juni, Juli, August, September, Oktober, November, Dezember]
15
- abbr_month_names: [~, Jan, Feb, Mär, Apr, Mai, Jun, Jul, Aug, Sep, Okt, Nov, Dez]
16
-
17
- time:
18
- formats:
19
- default: "%A, %e. %B %Y, %H:%M Uhr"
20
- short: "%e. %B, %H:%M Uhr"
21
- long: "%A, %e. %B %Y, %H:%M Uhr"
22
- time: "%H:%M"
23
-
24
- am: "vormittags"
25
- pm: "nachmittags"
26
-
27
- datetime:
28
- distance_in_words:
29
- half_a_minute: 'eine halbe Minute'
30
- less_than_x_seconds:
31
- zero: 'weniger als 1 Sekunde'
32
- one: 'weniger als 1 Sekunde'
33
- other: 'weniger als {{count}} Sekunden'
34
- x_seconds:
35
- one: '1 Sekunde'
36
- other: '{{count}} Sekunden'
37
- less_than_x_minutes:
38
- zero: 'weniger als 1 Minute'
39
- one: 'weniger als eine Minute'
40
- other: 'weniger als {{count}} Minuten'
41
- x_minutes:
42
- one: '1 Minute'
43
- other: '{{count}} Minuten'
44
- about_x_hours:
45
- one: 'etwa 1 Stunde'
46
- other: 'etwa {{count}} Stunden'
47
- x_days:
48
- one: '1 Tag'
49
- other: '{{count}} Tage'
50
- about_x_months:
51
- one: 'etwa 1 Monat'
52
- other: 'etwa {{count}} Monate'
53
- x_months:
54
- one: '1 Monat'
55
- other: '{{count}} Monate'
56
- about_x_years:
57
- one: 'etwa 1 Jahr'
58
- other: 'etwa {{count}} Jahre'
59
- over_x_years:
60
- one: 'mehr als 1 Jahr'
61
- other: 'mehr als {{count}} Jahre'
62
-
63
- number:
64
- format:
65
- precision: 2
66
- separator: ','
67
- delimiter: '.'
68
- currency:
69
- format:
70
- unit: '€'
71
- format: '%n%u'
72
- separator:
73
- delimiter:
74
- precision:
75
- percentage:
76
- format:
77
- delimiter: ""
78
- precision:
79
- format:
80
- delimiter: ""
81
- human:
82
- format:
83
- delimiter: ""
84
- precision: 1
85
-
86
- support:
87
- array:
88
- sentence_connector: "und"
89
- skip_last_comma: true
90
-
91
- activerecord:
92
- errors:
93
- template:
94
- header:
95
- one: "Konnte dieses {{model}} Objekt nicht speichern: 1 Fehler."
96
- other: "Konnte dieses {{model}} Objekt nicht speichern: {{count}} Fehler."
97
- body: "Bitte überprüfen Sie die folgenden Felder:"
98
- format:
99
- seperator: ' '
100
- messages:
101
- inclusion: "ist kein gültiger Wert"
102
- exclusion: "ist nicht verfügbar"
103
- invalid: "ist nicht gültig"
104
- confirmation: "stimmt nicht mit der Bestätigung überein"
105
- accepted: "muss akzeptiert werden"
106
- empty: "muss ausgefüllt werden"
107
- blank: "muss ausgefüllt werden"
108
- too_long: "ist zu lang (nicht mehr als {{count}} Zeichen)"
109
- too_short: "ist zu kurz (nicht weniger als {{count}} Zeichen)"
110
- wrong_length: "hat die falsche Länge (muss genau {{count}} Zeichen haben)"
111
- taken: "ist bereits vergeben"
112
- not_a_number: "ist keine Zahl"
113
- greater_than: "muss größer als {{count}} sein"
114
- greater_than_or_equal_to: "muss größer oder gleich {{count}} sein"
115
- equal_to: "muss genau {{count}} sein"
116
- less_than: "muss kleiner als {{count}} sein"
117
- less_than_or_equal_to: "muss kleiner oder gleich {{count}} sein"
118
- odd: "muss ungerade sein"
119
- even: "muss gerade sein"
120
- models:
121
- car: 'BAUTO'
122
- cars: 'CAUTO'
123
- Car: 'DAUTO'
124
-
125
- models:
126
- car: 'Auto'
@@ -1,21 +0,0 @@
1
- require 'benchmark'
2
- BASELINE = 0
3
- def test
4
- result = Benchmark.measure {1_000_000.times{ yield }}
5
- result.to_s.strip.split(' ').first.to_f - BASELINE
6
- end
7
-
8
- BASELINE = (test{})
9
- Thread.current[:library_name]={}
10
- other = "x"
11
- puts "Ruby #{VERSION}"
12
-
13
- puts "generic:"
14
- puts " Symbol: #{test{Thread.current[:library_name][:just_a_symbol]}}s"
15
- puts " String concat: #{test{Thread.current["xxxxxx"<<other.to_s]}}s"
16
- puts " String add: #{test{Thread.current["xxxxxx"+other.to_s]}}s"
17
- puts " String insert: #{test{Thread.current["xxxxxx#{other}"]}}s"
18
-
19
- puts "single:"
20
- puts " Symbol: #{test{Thread.current[:long_unique_symbol]}}s"
21
- puts " String: #{test{Thread.current["xxxxxx"]}}s"
@@ -1,15 +0,0 @@
1
- #Iconv will not be defined, unless it is found -> normalize test results for users that have Iconv/those who do not have it
2
- begin;require 'iconv';rescue;LoadError;end
3
- initial = methods.count + Module.constants.count
4
-
5
- #FastGettext
6
- $LOAD_PATH.unshift File.join(File.dirname(__FILE__),'..','..','lib')
7
- require 'fast_gettext'
8
- FastGettext.locale = 'de'
9
- FastGettext.add_text_domain 'test', :path=>'spec/locale'
10
- FastGettext.text_domain = 'test'
11
- include FastGettext::Translation
12
- raise unless _('car')=='Auto'
13
-
14
- puts "FastGettext"
15
- puts methods.count + Module.constants.count - initial
@@ -1,14 +0,0 @@
1
- require 'rubygems'
2
- initial = methods.count + Module.constants.count
3
-
4
- #GetText
5
- gem 'gettext', '>=2.0.0'
6
- require 'gettext'
7
- GetText.locale = 'de'
8
- GetText.bindtextdomain('test',:path=>'spec/locale')
9
- include GetText
10
- raise unless _('car') == 'Auto'
11
-
12
-
13
- puts "GetText"
14
- puts methods.count + Module.constants.count - initial
@@ -1,22 +0,0 @@
1
- require 'benchmark/base'
2
-
3
- begin
4
- gem 'gettext', '>=2.0.0'
5
- rescue LoadError
6
- puts 'To run this benchmark, please install the gettext gem'
7
- exit 1
8
- end
9
-
10
- $LOAD_PATH.unshift 'lib'
11
- require 'gettext'
12
- include GetText
13
-
14
- self.locale = 'de'
15
-
16
- puts "GetText #{GetText::VERSION}:"
17
- bindtextdomain('test',:path=>locale_folder('test'))
18
- results_test{_('car') == 'Auto'}
19
-
20
- #i cannot add the large file, since its an internal applications mo file
21
- bindtextdomain('large',:path=>locale_folder('large'))
22
- results_large
@@ -1,22 +0,0 @@
1
- class CreateTranslationTables < ActiveRecord::Migration
2
- def self.up
3
- create_table :translation_keys do |t|
4
- t.string :key, :unique=>true, :null=>false
5
- t.timestamps
6
- end
7
- add_index :translation_keys, :key #I am not sure if this helps....
8
-
9
- create_table :translation_texts do |t|
10
- t.text :text
11
- t.string :locale
12
- t.integer :translation_key_id, :null=>false
13
- t.timestamps
14
- end
15
- add_index :translation_texts, :translation_key_id
16
- end
17
-
18
- def self.down
19
- drop_table :translation_keys
20
- drop_table :translation_texts
21
- end
22
- end
@@ -1,13 +0,0 @@
1
- class MissingTranslationLogger
2
- def call(unfound)
3
- logger.warn "#{FastGettext.locale}: #{unfound}" unless FastGettext.locale == 'en'
4
- end
5
-
6
- private
7
-
8
- def logger
9
- return @logger if @logger
10
- require 'logger'
11
- @logger = Logger.new("log/unfound_translations", 2, 5*(1024**2))#max 2x 5mb logfile
12
- end
13
- end
data/fast_gettext.gemspec DELETED
@@ -1,12 +0,0 @@
1
- $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
2
- name = "fast_gettext"
3
- require "#{name}/version"
4
-
5
- Gem::Specification.new name, FastGettext::VERSION do |s|
6
- s.summary = "A simple, fast, memory-efficient and threadsafe implementation of GetText"
7
- s.authors = ["Michael Grosser"]
8
- s.email = "michael@grosser.it"
9
- s.homepage = "http://github.com/grosser/#{name}"
10
- s.files = `git ls-files`.split("\n")
11
- s.licenses = ["MIT", "Ruby"]
12
- end
@@ -1,14 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "appraisal"
6
- gem "rake"
7
- gem "sqlite3"
8
- gem "rspec"
9
- gem "activerecord"
10
- gem "i18n"
11
- gem "bump"
12
- gem "rails", "~>2.3.0"
13
-
14
- gemspec :path=>"../"
@@ -1,56 +0,0 @@
1
- PATH
2
- remote: /Users/mgrosser/code/tools/fast_gettext
3
- specs:
4
- fast_gettext (0.7.1)
5
-
6
- GEM
7
- remote: https://rubygems.org/
8
- specs:
9
- actionmailer (2.3.18)
10
- actionpack (= 2.3.18)
11
- actionpack (2.3.18)
12
- activesupport (= 2.3.18)
13
- rack (~> 1.1.0)
14
- activerecord (2.3.18)
15
- activesupport (= 2.3.18)
16
- activeresource (2.3.18)
17
- activesupport (= 2.3.18)
18
- activesupport (2.3.18)
19
- appraisal (0.5.2)
20
- bundler
21
- rake
22
- bump (0.4.2)
23
- diff-lcs (1.2.4)
24
- i18n (0.6.4)
25
- rack (1.1.6)
26
- rails (2.3.18)
27
- actionmailer (= 2.3.18)
28
- actionpack (= 2.3.18)
29
- activerecord (= 2.3.18)
30
- activeresource (= 2.3.18)
31
- activesupport (= 2.3.18)
32
- rake (>= 0.8.3)
33
- rake (10.1.0)
34
- rspec (2.14.1)
35
- rspec-core (~> 2.14.0)
36
- rspec-expectations (~> 2.14.0)
37
- rspec-mocks (~> 2.14.0)
38
- rspec-core (2.14.4)
39
- rspec-expectations (2.14.0)
40
- diff-lcs (>= 1.1.3, < 2.0)
41
- rspec-mocks (2.14.2)
42
- sqlite3 (1.3.7)
43
-
44
- PLATFORMS
45
- ruby
46
-
47
- DEPENDENCIES
48
- activerecord
49
- appraisal
50
- bump
51
- fast_gettext!
52
- i18n
53
- rails (~> 2.3.0)
54
- rake
55
- rspec
56
- sqlite3
@@ -1,14 +0,0 @@
1
- # This file was generated by Appraisal
2
-
3
- source "https://rubygems.org"
4
-
5
- gem "appraisal"
6
- gem "rake"
7
- gem "sqlite3"
8
- gem "rspec"
9
- gem "activerecord"
10
- gem "i18n"
11
- gem "bump"
12
- gem "rails", "~>3.2.0"
13
-
14
- gemspec :path=>"../"
@@ -1,112 +0,0 @@
1
- PATH
2
- remote: /Users/mgrosser/code/tools/fast_gettext
3
- specs:
4
- fast_gettext (0.7.1)
5
-
6
- GEM
7
- remote: https://rubygems.org/
8
- specs:
9
- actionmailer (3.2.14)
10
- actionpack (= 3.2.14)
11
- mail (~> 2.5.4)
12
- actionpack (3.2.14)
13
- activemodel (= 3.2.14)
14
- activesupport (= 3.2.14)
15
- builder (~> 3.0.0)
16
- erubis (~> 2.7.0)
17
- journey (~> 1.0.4)
18
- rack (~> 1.4.5)
19
- rack-cache (~> 1.2)
20
- rack-test (~> 0.6.1)
21
- sprockets (~> 2.2.1)
22
- activemodel (3.2.14)
23
- activesupport (= 3.2.14)
24
- builder (~> 3.0.0)
25
- activerecord (3.2.14)
26
- activemodel (= 3.2.14)
27
- activesupport (= 3.2.14)
28
- arel (~> 3.0.2)
29
- tzinfo (~> 0.3.29)
30
- activeresource (3.2.14)
31
- activemodel (= 3.2.14)
32
- activesupport (= 3.2.14)
33
- activesupport (3.2.14)
34
- i18n (~> 0.6, >= 0.6.4)
35
- multi_json (~> 1.0)
36
- appraisal (0.5.2)
37
- bundler
38
- rake
39
- arel (3.0.2)
40
- builder (3.0.4)
41
- bump (0.4.2)
42
- diff-lcs (1.2.4)
43
- erubis (2.7.0)
44
- hike (1.2.3)
45
- i18n (0.6.4)
46
- journey (1.0.4)
47
- json (1.8.0)
48
- mail (2.5.4)
49
- mime-types (~> 1.16)
50
- treetop (~> 1.4.8)
51
- mime-types (1.23)
52
- multi_json (1.7.8)
53
- polyglot (0.3.3)
54
- rack (1.4.5)
55
- rack-cache (1.2)
56
- rack (>= 0.4)
57
- rack-ssl (1.3.3)
58
- rack
59
- rack-test (0.6.2)
60
- rack (>= 1.0)
61
- rails (3.2.14)
62
- actionmailer (= 3.2.14)
63
- actionpack (= 3.2.14)
64
- activerecord (= 3.2.14)
65
- activeresource (= 3.2.14)
66
- activesupport (= 3.2.14)
67
- bundler (~> 1.0)
68
- railties (= 3.2.14)
69
- railties (3.2.14)
70
- actionpack (= 3.2.14)
71
- activesupport (= 3.2.14)
72
- rack-ssl (~> 1.3.2)
73
- rake (>= 0.8.7)
74
- rdoc (~> 3.4)
75
- thor (>= 0.14.6, < 2.0)
76
- rake (10.1.0)
77
- rdoc (3.12.2)
78
- json (~> 1.4)
79
- rspec (2.14.1)
80
- rspec-core (~> 2.14.0)
81
- rspec-expectations (~> 2.14.0)
82
- rspec-mocks (~> 2.14.0)
83
- rspec-core (2.14.4)
84
- rspec-expectations (2.14.0)
85
- diff-lcs (>= 1.1.3, < 2.0)
86
- rspec-mocks (2.14.2)
87
- sprockets (2.2.2)
88
- hike (~> 1.2)
89
- multi_json (~> 1.0)
90
- rack (~> 1.0)
91
- tilt (~> 1.1, != 1.3.0)
92
- sqlite3 (1.3.7)
93
- thor (0.18.1)
94
- tilt (1.4.1)
95
- treetop (1.4.14)
96
- polyglot
97
- polyglot (>= 0.3.1)
98
- tzinfo (0.3.37)
99
-
100
- PLATFORMS
101
- ruby
102
-
103
- DEPENDENCIES
104
- activerecord
105
- appraisal
106
- bump
107
- fast_gettext!
108
- i18n
109
- rails (~> 3.2.0)
110
- rake
111
- rspec
112
- sqlite3