fast_gettext 0.6.4 → 0.6.5

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/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ pkg
2
+ benchmark/locle
data/Gemfile CHANGED
@@ -1,9 +1,9 @@
1
1
  source :rubygems
2
+ gemspec
2
3
 
3
- group :dev do
4
+ group :development do
4
5
  gem 'rake'
5
6
  gem 'sqlite3'
6
7
  gem 'rspec', '~>2'
7
- gem 'jeweler'
8
8
  gem 'activerecord', ENV['AR']
9
9
  end
data/Gemfile.lock CHANGED
@@ -1,3 +1,8 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ fast_gettext (0.6.5)
5
+
1
6
  GEM
2
7
  remote: http://rubygems.org/
3
8
  specs:
@@ -17,12 +22,7 @@ GEM
17
22
  bcrypt-ruby (3.0.1)
18
23
  builder (3.0.0)
19
24
  diff-lcs (1.1.3)
20
- git (1.2.5)
21
25
  i18n (0.6.0)
22
- jeweler (1.6.4)
23
- bundler (~> 1.0)
24
- git (>= 1.2.5)
25
- rake
26
26
  multi_json (1.0.3)
27
27
  rake (0.9.2)
28
28
  rspec (2.6.0)
@@ -41,7 +41,7 @@ PLATFORMS
41
41
 
42
42
  DEPENDENCIES
43
43
  activerecord
44
- jeweler
44
+ fast_gettext!
45
45
  rake
46
46
  rspec (~> 2)
47
47
  sqlite3
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ require 'bundler/gem_tasks'
2
+
1
3
  task :default do
2
4
  sh "AR='~>2' && (bundle || bundle install) && bundle exec rspec spec" # ActiveRecord 2
3
5
  sh "AR='~>3' && (bundle || bundle install) && bundle exec rspec spec" # ActiveRecord 3
@@ -16,17 +18,19 @@ task :namespaces do
16
18
  puts `ruby benchmark/namespace/fast_gettext.rb`
17
19
  end
18
20
 
19
- begin
20
- require 'jeweler'
21
- Jeweler::Tasks.new do |gem|
22
- gem.name = 'fast_gettext'
23
- gem.summary = "A simple, fast, memory-efficient and threadsafe implementation of GetText"
24
- gem.email = "michael@grosser.it"
25
- gem.homepage = "http://github.com/grosser/#{gem.name}"
26
- gem.authors = ["Michael Grosser"]
27
- end
21
+ # extracted from https://github.com/grosser/project_template
22
+ rule /^version:bump:.*/ do |t|
23
+ sh "git status | grep 'nothing to commit'" # ensure we are not dirty
24
+ index = ['major', 'minor','patch'].index(t.name.split(':').last)
25
+ file = 'lib/fast_gettext/version.rb'
26
+
27
+ version_file = File.read(file)
28
+ old_version, *version_parts = version_file.match(/(\d+)\.(\d+)\.(\d+)/).to_a
29
+ version_parts[index] = version_parts[index].to_i + 1
30
+ version_parts[2] = 0 if index < 2 # remove patch for minor
31
+ version_parts[1] = 0 if index < 1 # remove minor for major
32
+ new_version = version_parts * '.'
33
+ File.open(file,'w'){|f| f.write(version_file.sub(old_version, new_version)) }
28
34
 
29
- Jeweler::GemcutterTasks.new
30
- rescue LoadError
31
- puts "Jeweler, or one of its dependencies, is not available. Install it with: gem install jeweler"
35
+ sh "bundle && git add #{file} Gemfile.lock && git commit -m 'bump version to #{new_version}'"
32
36
  end
data/Readme.md CHANGED
@@ -35,7 +35,7 @@ Comparison
35
35
  <td></td>
36
36
  <td>db, yml, mo, po, logger, chain</td>
37
37
  <td>mo</td>
38
- <td>yml</td>
38
+ <td>yml (db/key-value/po/chain in other I18n backends)</td>
39
39
  </tr>
40
40
  </table>
41
41
  <small>*50.000 translations with ruby enterprise 1.8.6 through `rake benchmark`</small>
@@ -43,22 +43,27 @@ Comparison
43
43
  Setup
44
44
  =====
45
45
  ### 1. Install
46
+
46
47
  sudo gem install fast_gettext
47
48
 
48
49
  ### 2. Add a translation repository
49
50
 
50
51
  From mo files (traditional/default)
52
+
51
53
  FastGettext.add_text_domain('my_app',:path=>'locale')
52
54
 
53
55
  Or po files (less maintenance than mo)
56
+
54
57
  FastGettext.add_text_domain('my_app',:path=>'locale', :type=>:po)
55
58
  # :ignore_fuzzy => true to silence warnings about fuzzy translations
56
59
  # :ignore_obsolete => true to silence warnings about obsolete translations
57
60
 
58
61
  Or yaml files (use I18n syntax/indentation)
62
+
59
63
  FastGettext.add_text_domain('my_app',:path=>'config/locales', :type=>:yaml)
60
64
 
61
65
  Or database (scaleable, good for many locales/translators)
66
+
62
67
  # db access is cached <-> only first lookup hits the db
63
68
  require "fast_gettext/translation_repository/db"
64
69
  FastGettext::TranslationRepository::Db.require_models #load and include default models
@@ -66,11 +71,13 @@ Or database (scaleable, good for many locales/translators)
66
71
 
67
72
  ### 3. Choose text domain and locale for translation
68
73
  Do this once in every Thread. (e.g. Rails -> ApplicationController)
74
+
69
75
  FastGettext.text_domain = 'my_app'
70
76
  FastGettext.available_locales = ['de','en','fr','en_US','en_UK'] # only allow these locales to be set (optional)
71
77
  FastGettext.locale = 'de'
72
78
 
73
79
  ### 4. Start translating
80
+
74
81
  include FastGettext::Translation
75
82
  _('Car') == 'Auto'
76
83
  _('not-found') == 'not-found'
@@ -84,6 +91,7 @@ Managing translations
84
91
  Generate .po or .mo files using GetText parser (example tasks at [gettext_i18n_rails](http://github.com/grosser/gettext_i18n_rails))
85
92
 
86
93
  Tell Gettext where your .mo or .po files lie, e.g. for locale/de/my_app.po and locale/de/LC_MESSAGES/my_app.mo
94
+
87
95
  FastGettext.add_text_domain('my_app',:path=>'locale')
88
96
 
89
97
  Use the [original GetText](http://github.com/mutoh/gettext) to create and manage po/mo-files.
@@ -153,6 +161,7 @@ Fallback when no available_locales are set
153
161
  ###Chains
154
162
  You can use any number of repositories to find a translation. Simply add them to a chain and when
155
163
  the first cannot translate a given key, the next is asked and so forth.
164
+
156
165
  repos = [
157
166
  FastGettext::TranslationRepository.build('new', :path=>'....'),
158
167
  FastGettext::TranslationRepository.build('old', :path=>'....')
@@ -161,11 +170,13 @@ the first cannot translate a given key, the next is asked and so forth.
161
170
 
162
171
  ###Logger
163
172
  When you want to know which keys could not be translated or were used, add a Logger to a Chain:
173
+
164
174
  repos = [
165
175
  FastGettext::TranslationRepository.build('app', :path=>'....')
166
176
  FastGettext::TranslationRepository.build('logger', :type=>:logger, :callback=>lamda{|key_or_array_of_ids| ... }),
167
177
  }
168
178
  FastGettext.add_text_domain 'combined', :type=>:chain, :chain=>repos
179
+
169
180
  If the Logger is in position #1 it will see all translations, if it is in position #2 it will only see the unfound.
170
181
  Unfound may not always mean missing, if you choose not to translate a word because the key is a good translation, it will appear nevertheless.
171
182
  A lambda or anything that responds to `call` will do as callback. A good starting point may be `examples/missing_translations_logger.rb`.
@@ -173,6 +184,7 @@ A lambda or anything that responds to `call` will do as callback. A good startin
173
184
  ###Plugins
174
185
  Want a xml version ?
175
186
  Write your own TranslationRepository!
187
+
176
188
  #fast_gettext/translation_repository/xxx.rb
177
189
  module FastGettext
178
190
  module TranslationRepository
@@ -208,9 +220,9 @@ Mo/Po-file parsing from Masao Mutoh, see vendor/README
208
220
  - [Ramón Cahenzli](http://www.psy-q.ch)
209
221
  - [Rainux Luo](http://rainux.org)
210
222
  - [Dmitry Borodaenko](https://github.com/angdraug)
223
+ - [Kouhei Sutou](https://github.com/kou)
211
224
 
212
225
  [Michael Grosser](http://grosser.it)<br/>
213
226
  michael@grosser.it<br/>
214
227
  Hereby placed under public domain, do what you want, just do not hold me accountable...<br/>
215
- [![Flattr](http://api.flattr.com/button/flattr-badge-large.png)](https://flattr.com/submit/auto?user_id=grosser&url=https://github.com/grosser/fast_gettext&title=fast_gettext&language=en_GB&tags=github&category=software)
216
228
  [![Build Status](https://secure.travis-ci.org/grosser/fast_gettext.png)](http://travis-ci.org/grosser/fast_gettext)
data/fast_gettext.gemspec CHANGED
@@ -1,108 +1,12 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
- # -*- encoding: utf-8 -*-
1
+ $LOAD_PATH.unshift File.expand_path("../lib", __FILE__)
2
+ name = "fast_gettext"
3
+ require "#{name}/version"
5
4
 
6
- Gem::Specification.new do |s|
7
- s.name = %q{fast_gettext}
8
- s.version = "0.6.4"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
5
+ Gem::Specification.new name, FastGettext::VERSION do |s|
6
+ s.summary = "A simple, fast, memory-efficient and threadsafe implementation of GetText"
11
7
  s.authors = ["Michael Grosser"]
12
- s.date = %q{2011-12-04}
13
- s.email = %q{michael@grosser.it}
14
- s.files = [
15
- ".travis.yml",
16
- "CHANGELOG",
17
- "Gemfile",
18
- "Gemfile.lock",
19
- "Rakefile",
20
- "Readme.md",
21
- "VERSION",
22
- "benchmark/base.rb",
23
- "benchmark/baseline.rb",
24
- "benchmark/fast_gettext.rb",
25
- "benchmark/i18n_simple.rb",
26
- "benchmark/ideal.rb",
27
- "benchmark/locale/de.yml",
28
- "benchmark/locale/de/LC_MESSAGES/large.mo",
29
- "benchmark/misc/threadsave.rb",
30
- "benchmark/namespace/fast_gettext.rb",
31
- "benchmark/namespace/original.rb",
32
- "benchmark/original.rb",
33
- "examples/db/migration.rb",
34
- "examples/missing_translation_logger.rb",
35
- "fast_gettext.gemspec",
36
- "lib/fast_gettext.rb",
37
- "lib/fast_gettext/VERSION",
38
- "lib/fast_gettext/mo_file.rb",
39
- "lib/fast_gettext/po_file.rb",
40
- "lib/fast_gettext/storage.rb",
41
- "lib/fast_gettext/translation.rb",
42
- "lib/fast_gettext/translation_repository.rb",
43
- "lib/fast_gettext/translation_repository/base.rb",
44
- "lib/fast_gettext/translation_repository/chain.rb",
45
- "lib/fast_gettext/translation_repository/db.rb",
46
- "lib/fast_gettext/translation_repository/db_models/translation_key.rb",
47
- "lib/fast_gettext/translation_repository/db_models/translation_text.rb",
48
- "lib/fast_gettext/translation_repository/logger.rb",
49
- "lib/fast_gettext/translation_repository/mo.rb",
50
- "lib/fast_gettext/translation_repository/po.rb",
51
- "lib/fast_gettext/translation_repository/yaml.rb",
52
- "lib/fast_gettext/vendor/README.rdoc",
53
- "lib/fast_gettext/vendor/empty.mo",
54
- "lib/fast_gettext/vendor/iconv.rb",
55
- "lib/fast_gettext/vendor/mofile.rb",
56
- "lib/fast_gettext/vendor/poparser.rb",
57
- "lib/fast_gettext/vendor/string.rb",
58
- "spec/aa_unconfigued_spec.rb",
59
- "spec/cases/fake_load_path/iconv.rb",
60
- "spec/cases/iconv_fallback.rb",
61
- "spec/cases/interpolate_i18n_after_fast_gettext.rb",
62
- "spec/cases/interpolate_i18n_before_fast_gettext.rb",
63
- "spec/cases/safe_mode_can_handle_locales.rb",
64
- "spec/fast_gettext/mo_file_spec.rb",
65
- "spec/fast_gettext/po_file_spec.rb",
66
- "spec/fast_gettext/storage_spec.rb",
67
- "spec/fast_gettext/translation_repository/base_spec.rb",
68
- "spec/fast_gettext/translation_repository/chain_spec.rb",
69
- "spec/fast_gettext/translation_repository/db_spec.rb",
70
- "spec/fast_gettext/translation_repository/logger_spec.rb",
71
- "spec/fast_gettext/translation_repository/mo_spec.rb",
72
- "spec/fast_gettext/translation_repository/po_spec.rb",
73
- "spec/fast_gettext/translation_repository/yaml_spec.rb",
74
- "spec/fast_gettext/translation_repository_spec.rb",
75
- "spec/fast_gettext/translation_spec.rb",
76
- "spec/fast_gettext/vendor/iconv_spec.rb",
77
- "spec/fast_gettext/vendor/string_spec.rb",
78
- "spec/fast_gettext_spec.rb",
79
- "spec/fuzzy_locale/de/test.po",
80
- "spec/locale/de/LC_MESSAGES/test.mo",
81
- "spec/locale/de/test.po",
82
- "spec/locale/en/LC_MESSAGES/plural_test.mo",
83
- "spec/locale/en/LC_MESSAGES/test.mo",
84
- "spec/locale/en/plural_test.po",
85
- "spec/locale/en/test.po",
86
- "spec/locale/gsw_CH/LC_MESSAGES/test.mo",
87
- "spec/locale/gsw_CH/test.po",
88
- "spec/locale/yaml/de.yml",
89
- "spec/locale/yaml/en.yml",
90
- "spec/locale/yaml/notfound.yml",
91
- "spec/obsolete_locale/de/test.po",
92
- "spec/spec_helper.rb"
93
- ]
94
- s.homepage = %q{http://github.com/grosser/fast_gettext}
95
- s.require_paths = ["lib"]
96
- s.rubygems_version = %q{1.6.2}
97
- s.summary = %q{A simple, fast, memory-efficient and threadsafe implementation of GetText}
98
-
99
- if s.respond_to? :specification_version then
100
- s.specification_version = 3
101
-
102
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
103
- else
104
- end
105
- else
106
- end
8
+ s.email = "michael@grosser.it"
9
+ s.homepage = "http://github.com/grosser/#{name}"
10
+ s.files = `git ls-files`.split("\n")
11
+ s.license = "MIT"
107
12
  end
108
-
data/lib/fast_gettext.rb CHANGED
@@ -8,7 +8,6 @@ module FastGettext
8
8
  include FastGettext::Storage
9
9
  extend self
10
10
 
11
- VERSION = File.read( File.join(File.dirname(__FILE__), 'fast_gettext', 'VERSION') ).strip
12
11
  LOCALE_REX = /^[a-z]{2,3}$|^[a-z]{2,3}_[A-Z]{2,3}$/
13
12
  NAMESPACE_SEPARATOR = '|'
14
13
 
@@ -1,25 +1,25 @@
1
+ # encoding: utf-8
2
+
1
3
  =begin
2
4
  mofile.rb - A simple class for operating GNU MO file.
3
5
 
4
- Copyright (C) 2003-2008 Masao Mutoh
6
+ Copyright (C) 2012 Kouhei Sutou <kou@clear-code.com>
7
+ Copyright (C) 2003-2009 Masao Mutoh
5
8
  Copyright (C) 2002 Masahiro Sakai, Masao Mutoh
6
9
  Copyright (C) 2001 Masahiro Sakai
7
10
 
8
11
  Masahiro Sakai <s01397ms at sfc.keio.ac.jp>
9
- Masao Mutoh <mutoh at highway.ne.jp>
12
+ Masao Mutoh <mutomasa at gmail.com>
10
13
 
11
14
  You can redistribute this file and/or modify it under the same term
12
15
  of Ruby. License of Ruby is included with Ruby distribution in
13
16
  the file "README".
14
17
 
15
- $Id: mo.rb,v 1.10 2008/06/17 16:40:52 mutoh Exp $
16
18
  =end
17
19
 
18
- require 'fast_gettext/vendor/iconv'
19
- require 'stringio'
20
+ # Changes: Namespaced + uses FastGettext::Icvon
20
21
 
21
- #Modifications:
22
- # use Iconv or FastGettext::Icvon
22
+ require 'stringio'
23
23
 
24
24
  module FastGettext
25
25
  module GetText
@@ -48,6 +48,10 @@ module FastGettext
48
48
 
49
49
  MAGIC_BIG_ENDIAN = "\x95\x04\x12\xde"
50
50
  MAGIC_LITTLE_ENDIAN = "\xde\x12\x04\x95"
51
+ if "".respond_to?(:force_encoding)
52
+ MAGIC_BIG_ENDIAN.force_encoding("ASCII-8BIT")
53
+ MAGIC_LITTLE_ENDIAN.force_encoding("ASCII-8BIT")
54
+ end
51
55
 
52
56
  def self.open(arg = nil, output_charset = nil)
53
57
  result = self.new(output_charset)
@@ -59,6 +63,7 @@ module FastGettext
59
63
  @last_modified = nil
60
64
  @little_endian = true
61
65
  @output_charset = output_charset
66
+ @plural_proc = nil
62
67
  super()
63
68
  end
64
69
 
@@ -149,45 +154,42 @@ module FastGettext
149
154
  @plural = "0" unless @plural
150
155
  end
151
156
  else
152
- if @output_charset
153
- begin
154
- str = FastGettext::Iconv.conv(@output_charset, @charset, str) if @charset
155
- rescue FastGettext::Iconv::Failure
156
- if $DEBUG
157
- warn "@charset = ", @charset
158
- warn"@output_charset = ", @output_charset
159
- warn "msgid = ", original_strings[i]
160
- warn "msgstr = ", str
161
- end
162
- end
157
+ if @charset and @output_charset
158
+ str = convert_encoding(str, original_strings[i])
163
159
  end
164
160
  end
165
- self[original_strings[i]] = str.freeze
161
+ self[convert_encoding(original_strings[i], original_strings[i])] = str.freeze
166
162
  end
167
163
  self
168
164
  end
169
165
 
170
- # Is this number a prime number ?
171
- # http://apidock.com/ruby/Prime
172
166
  def prime?(number)
173
167
  ('1' * number) !~ /^1?$|^(11+?)\1+$/
174
168
  end
175
169
 
176
- def next_prime(seed)
177
- require 'mathn'
178
- prime = Prime.new
179
- while current = prime.succ
180
- return current if current > seed
170
+ begin
171
+ require 'prime'
172
+ def next_prime(seed)
173
+ Prime.instance.find{|x| x > seed }
174
+ end
175
+ rescue LoadError
176
+ def next_prime(seed)
177
+ require 'mathn'
178
+ prime = Prime.new
179
+ while current = prime.succ
180
+ return current if current > seed
181
+ end
181
182
  end
182
183
  end
183
184
 
185
+ HASHWORDBITS = 32
184
186
  # From gettext-0.12.1/gettext-runtime/intl/hash-string.h
185
187
  # Defines the so called `hashpjw' function by P.J. Weinberger
186
188
  # [see Aho/Sethi/Ullman, COMPILERS: Principles, Techniques and Tools,
187
189
  # 1986, 1987 Bell Telephone Laboratories, Inc.]
188
- HASHWORDBITS = 32
189
190
  def hash_string(str)
190
191
  hval = 0
192
+ i = 0
191
193
  str.each_byte do |b|
192
194
  break if b == '\0'
193
195
  hval <<= 4
@@ -201,8 +203,8 @@ module FastGettext
201
203
  hval
202
204
  end
203
205
 
206
+ #Save data as little endian format.
204
207
  def save_to_stream(io)
205
- #Save data as little endian format.
206
208
  header_size = 4 * 7
207
209
  table_size = 4 * 2 * size
208
210
 
@@ -226,17 +228,17 @@ module FastGettext
226
228
 
227
229
  orig_table_data = Array.new()
228
230
  ary.each{|item, _|
229
- orig_table_data.push(item.size)
231
+ orig_table_data.push(item.bytesize)
230
232
  orig_table_data.push(pos)
231
- pos += item.size + 1 # +1 is <NUL>
233
+ pos += item.bytesize + 1 # +1 is <NUL>
232
234
  }
233
235
  io.write(orig_table_data.pack('V*'))
234
236
 
235
237
  trans_table_data = Array.new()
236
238
  ary.each{|_, item|
237
- trans_table_data.push(item.size)
239
+ trans_table_data.push(item.bytesize)
238
240
  trans_table_data.push(pos)
239
- pos += item.size + 1 # +1 is <NUL>
241
+ pos += item.bytesize + 1 # +1 is <NUL>
240
242
  }
241
243
  io.write(trans_table_data.pack('V*'))
242
244
 
@@ -286,9 +288,74 @@ module FastGettext
286
288
  #Do nothing
287
289
  end
288
290
 
291
+ def plural_as_proc
292
+ unless @plural_proc
293
+ @plural_proc = Proc.new{|n| eval(@plural)}
294
+ begin
295
+ @plural_proc.call(1)
296
+ rescue
297
+ @plural_proc = Proc.new{|n| 0}
298
+ end
299
+ end
300
+ @plural_proc
301
+ end
289
302
 
290
303
  attr_accessor :little_endian, :path, :last_modified
291
304
  attr_reader :charset, :nplurals, :plural
305
+
306
+ private
307
+ if "".respond_to?(:encode)
308
+ def convert_encoding(string, original_string)
309
+ begin
310
+ string.encode(@output_charset, @charset)
311
+ rescue EncodingError
312
+ if $DEBUG
313
+ warn "@charset = ", @charset
314
+ warn "@output_charset = ", @output_charset
315
+ warn "msgid = ", original_string
316
+ warn "msgstr = ", string
317
+ end
318
+ string
319
+ end
320
+ end
321
+ else
322
+ require 'fast_gettext/vendor/iconv'
323
+ def convert_encoding(string, original_string)
324
+ begin
325
+ str = FastGettext::Iconv.conv(@output_charset, @charset, string)
326
+ rescue FastGettext::Iconv::Failure
327
+ if $DEBUG
328
+ warn "@charset = ", @charset
329
+ warn "@output_charset = ", @output_charset
330
+ warn "msgid = ", original_string
331
+ warn "msgstr = ", str
332
+ end
333
+ end
334
+ end
335
+ end
292
336
  end
293
337
  end
294
338
  end
339
+
340
+ # Test
341
+
342
+ if $0 == __FILE__
343
+ if (ARGV.include? "-h") or (ARGV.include? "--help")
344
+ STDERR.puts("mo.rb [filename.mo ...]")
345
+ exit
346
+ end
347
+
348
+ ARGV.each{ |item|
349
+ mo = FastGettext::GetText::MOFile.open(item)
350
+ puts "------------------------------------------------------------------"
351
+ puts "charset = \"#{mo.charset}\""
352
+ puts "nplurals = \"#{mo.nplurals}\""
353
+ puts "plural = \"#{mo.plural}\""
354
+ puts "------------------------------------------------------------------"
355
+ mo.each do |key, value|
356
+ puts "original message = #{key.inspect}"
357
+ puts "translated message = #{value.inspect}"
358
+ puts "--------------------------------------------------------------------"
359
+ end
360
+ }
361
+ end
@@ -0,0 +1,3 @@
1
+ module FastGettext
2
+ VERSION = Version = '0.6.5'
3
+ end
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require File.expand_path('spec/spec_helper')
2
3
 
3
4
  de_file = File.join('spec','locale','de','LC_MESSAGES','test.mo')
@@ -13,7 +14,7 @@ describe FastGettext::MoFile do
13
14
  end
14
15
 
15
16
  it "stores untranslated values as nil" do
16
- de['Car|Model'].should == nil
17
+ de['Untranslated'].should == nil
17
18
  end
18
19
 
19
20
  it "finds pluralized values" do
@@ -27,4 +28,8 @@ describe FastGettext::MoFile do
27
28
  it "can access plurals through []" do
28
29
  de['Axis'].should == 'Achse' #singular
29
30
  end
31
+
32
+ it "can successfully translate non-ASCII keys" do
33
+ de["Umläüte"].should == "Umlaute"
34
+ end
30
35
  end
Binary file
@@ -38,6 +38,9 @@ msgstr "Auto wurde erfolgreich aktualisiert"
38
38
  msgid "Car|Model"
39
39
  msgstr "Modell"
40
40
 
41
+ msgid "Untranslated"
42
+ msgstr ""
43
+
41
44
  #: app/views/cars/show.html.erb:3 locale/model_attributes.rb:4
42
45
  msgid "Car|Wheels count"
43
46
  msgstr "Räderzahl"
@@ -63,3 +66,6 @@ msgstr ""
63
66
  #: locale/test_escape.rb:2
64
67
  msgid "You should escape '\\' as '\\\\'."
65
68
  msgstr "Du solltest '\\' als '\\\\' escapen."
69
+
70
+ msgid "Umläüte"
71
+ msgstr "Umlaute"
metadata CHANGED
@@ -1,40 +1,29 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: fast_gettext
3
- version: !ruby/object:Gem::Version
4
- hash: 15
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.6.5
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 6
9
- - 4
10
- version: 0.6.4
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Michael Grosser
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-12-04 00:00:00 -08:00
19
- default_executable:
12
+ date: 2012-04-01 00:00:00.000000000 Z
20
13
  dependencies: []
21
-
22
14
  description:
23
15
  email: michael@grosser.it
24
16
  executables: []
25
-
26
17
  extensions: []
27
-
28
18
  extra_rdoc_files: []
29
-
30
- files:
19
+ files:
20
+ - .gitignore
31
21
  - .travis.yml
32
22
  - CHANGELOG
33
23
  - Gemfile
34
24
  - Gemfile.lock
35
25
  - Rakefile
36
26
  - Readme.md
37
- - VERSION
38
27
  - benchmark/base.rb
39
28
  - benchmark/baseline.rb
40
29
  - benchmark/fast_gettext.rb
@@ -50,7 +39,6 @@ files:
50
39
  - examples/missing_translation_logger.rb
51
40
  - fast_gettext.gemspec
52
41
  - lib/fast_gettext.rb
53
- - lib/fast_gettext/VERSION
54
42
  - lib/fast_gettext/mo_file.rb
55
43
  - lib/fast_gettext/po_file.rb
56
44
  - lib/fast_gettext/storage.rb
@@ -71,6 +59,7 @@ files:
71
59
  - lib/fast_gettext/vendor/mofile.rb
72
60
  - lib/fast_gettext/vendor/poparser.rb
73
61
  - lib/fast_gettext/vendor/string.rb
62
+ - lib/fast_gettext/version.rb
74
63
  - spec/aa_unconfigued_spec.rb
75
64
  - spec/cases/fake_load_path/iconv.rb
76
65
  - spec/cases/iconv_fallback.rb
@@ -106,39 +95,35 @@ files:
106
95
  - spec/locale/yaml/notfound.yml
107
96
  - spec/obsolete_locale/de/test.po
108
97
  - spec/spec_helper.rb
109
- has_rdoc: true
110
98
  homepage: http://github.com/grosser/fast_gettext
111
- licenses: []
112
-
99
+ licenses:
100
+ - MIT
113
101
  post_install_message:
114
102
  rdoc_options: []
115
-
116
- require_paths:
103
+ require_paths:
117
104
  - lib
118
- required_ruby_version: !ruby/object:Gem::Requirement
105
+ required_ruby_version: !ruby/object:Gem::Requirement
119
106
  none: false
120
- requirements:
121
- - - ">="
122
- - !ruby/object:Gem::Version
123
- hash: 3
124
- segments:
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ segments:
125
112
  - 0
126
- version: "0"
127
- required_rubygems_version: !ruby/object:Gem::Requirement
113
+ hash: -679116036762933784
114
+ required_rubygems_version: !ruby/object:Gem::Requirement
128
115
  none: false
129
- requirements:
130
- - - ">="
131
- - !ruby/object:Gem::Version
132
- hash: 3
133
- segments:
116
+ requirements:
117
+ - - ! '>='
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ segments:
134
121
  - 0
135
- version: "0"
122
+ hash: -679116036762933784
136
123
  requirements: []
137
-
138
124
  rubyforge_project:
139
- rubygems_version: 1.6.2
125
+ rubygems_version: 1.8.15
140
126
  signing_key:
141
127
  specification_version: 3
142
128
  summary: A simple, fast, memory-efficient and threadsafe implementation of GetText
143
129
  test_files: []
144
-
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.6.4
@@ -1 +0,0 @@
1
- 0.5.1