fast_gettext 0.4.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. data/.gitignore +2 -0
  2. data/CHANGELOG +6 -0
  3. data/README.markdown +181 -0
  4. data/Rakefile +42 -0
  5. data/VERSION +1 -0
  6. data/benchmark/base.rb +42 -0
  7. data/benchmark/baseline.rb +5 -0
  8. data/benchmark/fast_gettext.rb +18 -0
  9. data/benchmark/i18n_simple.rb +7 -0
  10. data/benchmark/ideal.rb +22 -0
  11. data/benchmark/locale/de.yml +127 -0
  12. data/benchmark/locale/de/LC_MESSAGES/large.mo +0 -0
  13. data/benchmark/misc/threadsave.rb +21 -0
  14. data/benchmark/namespace/fast_gettext.rb +15 -0
  15. data/benchmark/namespace/original.rb +14 -0
  16. data/benchmark/original.rb +15 -0
  17. data/examples/db/migration.rb +22 -0
  18. data/examples/missing_translation_logger.rb +13 -0
  19. data/fast_gettext.gemspec +114 -0
  20. data/lib/fast_gettext.rb +30 -0
  21. data/lib/fast_gettext/mo_file.rb +67 -0
  22. data/lib/fast_gettext/po_file.rb +14 -0
  23. data/lib/fast_gettext/storage.rb +188 -0
  24. data/lib/fast_gettext/translation.rb +53 -0
  25. data/lib/fast_gettext/translation_repository.rb +15 -0
  26. data/lib/fast_gettext/translation_repository/base.rb +49 -0
  27. data/lib/fast_gettext/translation_repository/chain.rb +43 -0
  28. data/lib/fast_gettext/translation_repository/db.rb +57 -0
  29. data/lib/fast_gettext/translation_repository/db_models/translation_key.rb +26 -0
  30. data/lib/fast_gettext/translation_repository/db_models/translation_text.rb +9 -0
  31. data/lib/fast_gettext/translation_repository/logger.rb +27 -0
  32. data/lib/fast_gettext/translation_repository/mo.rb +35 -0
  33. data/lib/fast_gettext/translation_repository/po.rb +18 -0
  34. data/spec/aa_unconfigued_spec.rb +21 -0
  35. data/spec/fast_gettext/mo_file_spec.rb +36 -0
  36. data/spec/fast_gettext/storage_spec.rb +309 -0
  37. data/spec/fast_gettext/translation_repository/base_spec.rb +21 -0
  38. data/spec/fast_gettext/translation_repository/chain_spec.rb +82 -0
  39. data/spec/fast_gettext/translation_repository/db_spec.rb +71 -0
  40. data/spec/fast_gettext/translation_repository/logger_spec.rb +41 -0
  41. data/spec/fast_gettext/translation_repository/mo_spec.rb +31 -0
  42. data/spec/fast_gettext/translation_repository/po_spec.rb +31 -0
  43. data/spec/fast_gettext/translation_spec.rb +152 -0
  44. data/spec/fast_gettext_spec.rb +44 -0
  45. data/spec/locale/de/LC_MESSAGES/test.mo +0 -0
  46. data/spec/locale/de/test.po +61 -0
  47. data/spec/locale/en/LC_MESSAGES/plural_test.mo +0 -0
  48. data/spec/locale/en/LC_MESSAGES/test.mo +0 -0
  49. data/spec/locale/en/plural_test.po +20 -0
  50. data/spec/locale/en/test.po +59 -0
  51. data/spec/spec_helper.rb +26 -0
  52. data/spec/vendor/fake_load_path/iconv.rb +2 -0
  53. data/spec/vendor/iconv_spec.rb +27 -0
  54. data/spec/vendor/string_spec.rb +67 -0
  55. data/vendor/README.rdoc +236 -0
  56. data/vendor/empty.mo +0 -0
  57. data/vendor/iconv.rb +107 -0
  58. data/vendor/mofile.rb +296 -0
  59. data/vendor/poparser.rb +331 -0
  60. data/vendor/string.rb +58 -0
  61. metadata +130 -0
data/vendor/string.rb ADDED
@@ -0,0 +1,58 @@
1
+ #! /usr/bin/ruby
2
+ =begin
3
+ string.rb - Extension for String.
4
+
5
+ Copyright (C) 2005,2006 Masao Mutoh
6
+
7
+ You may redistribute it and/or modify it under the same
8
+ license terms as Ruby.
9
+ =end
10
+
11
+ # Extension for String class. This feature is included in Ruby 1.9 or later.
12
+ begin
13
+ raise unless ("a %{x}" % {:x=>'b'}) == 'a b'
14
+ rescue ArgumentError
15
+ class String
16
+ alias :_fast_gettext_old_format_m :% # :nodoc:
17
+
18
+ PERCENT_MATCH_RE = Regexp.union(
19
+ /%%/,
20
+ /%\{([-\.\w]+)\}/,
21
+ /%<([-\.\w]+)>(.*?\d*\.?\d*[bBdiouxXeEfgGcps])/
22
+ )
23
+
24
+ # call-seq:
25
+ # %(hash)
26
+ #
27
+ # Default: "%s, %s" % ["Masao", "Mutoh"]
28
+ # Extended:
29
+ # "%{firstname}, %{lastname}" % {:firstname=>"Masao",:lastname=>"Mutoh"} == "Masao Mutoh"
30
+ # with field type such as d(decimal), f(float), ...
31
+ # "%<age>d, %<weight>.1f" % {:age => 10, :weight => 43.4} == "10 43.4"
32
+ # This is the recommanded way for Ruby-GetText
33
+ # because the translators can understand the meanings of the keys easily.
34
+ def %(args)
35
+ if args.kind_of? Hash
36
+ #stringify keys
37
+ replace = {}
38
+ args.each{|k,v|replace[k.to_s]=v}
39
+
40
+ #replace occurances
41
+ ret = dup
42
+ ret.gsub!(PERCENT_MATCH_RE) do |match|
43
+ if match == '%%'
44
+ '%'
45
+ elsif $1
46
+ replace.has_key?($1) ? replace[$1] : match
47
+ elsif $2
48
+ replace.has_key?($2) ? sprintf("%#{$3}", replace[$2]) : match
49
+ end
50
+ end
51
+ ret
52
+ else
53
+ ret = gsub(/%([{<])/, '%%\1')
54
+ ret._fast_gettext_old_format_m(args)
55
+ end
56
+ end
57
+ end
58
+ end
metadata ADDED
@@ -0,0 +1,130 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fast_gettext
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.4.16
5
+ platform: ruby
6
+ authors:
7
+ - Michael Grosser
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-10-16 00:00:00 +02:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description:
17
+ email: grosser.michael@gmail.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README.markdown
24
+ files:
25
+ - .gitignore
26
+ - CHANGELOG
27
+ - README.markdown
28
+ - Rakefile
29
+ - VERSION
30
+ - benchmark/base.rb
31
+ - benchmark/baseline.rb
32
+ - benchmark/fast_gettext.rb
33
+ - benchmark/i18n_simple.rb
34
+ - benchmark/ideal.rb
35
+ - benchmark/locale/de.yml
36
+ - benchmark/locale/de/LC_MESSAGES/large.mo
37
+ - benchmark/misc/threadsave.rb
38
+ - benchmark/namespace/fast_gettext.rb
39
+ - benchmark/namespace/original.rb
40
+ - benchmark/original.rb
41
+ - examples/db/migration.rb
42
+ - examples/missing_translation_logger.rb
43
+ - fast_gettext.gemspec
44
+ - lib/fast_gettext.rb
45
+ - lib/fast_gettext/mo_file.rb
46
+ - lib/fast_gettext/po_file.rb
47
+ - lib/fast_gettext/storage.rb
48
+ - lib/fast_gettext/translation.rb
49
+ - lib/fast_gettext/translation_repository.rb
50
+ - lib/fast_gettext/translation_repository/base.rb
51
+ - lib/fast_gettext/translation_repository/chain.rb
52
+ - lib/fast_gettext/translation_repository/db.rb
53
+ - lib/fast_gettext/translation_repository/db_models/translation_key.rb
54
+ - lib/fast_gettext/translation_repository/db_models/translation_text.rb
55
+ - lib/fast_gettext/translation_repository/logger.rb
56
+ - lib/fast_gettext/translation_repository/mo.rb
57
+ - lib/fast_gettext/translation_repository/po.rb
58
+ - spec/aa_unconfigued_spec.rb
59
+ - spec/fast_gettext/mo_file_spec.rb
60
+ - spec/fast_gettext/storage_spec.rb
61
+ - spec/fast_gettext/translation_repository/base_spec.rb
62
+ - spec/fast_gettext/translation_repository/chain_spec.rb
63
+ - spec/fast_gettext/translation_repository/db_spec.rb
64
+ - spec/fast_gettext/translation_repository/logger_spec.rb
65
+ - spec/fast_gettext/translation_repository/mo_spec.rb
66
+ - spec/fast_gettext/translation_repository/po_spec.rb
67
+ - spec/fast_gettext/translation_spec.rb
68
+ - spec/fast_gettext_spec.rb
69
+ - spec/locale/de/LC_MESSAGES/test.mo
70
+ - spec/locale/de/test.po
71
+ - spec/locale/en/LC_MESSAGES/plural_test.mo
72
+ - spec/locale/en/LC_MESSAGES/test.mo
73
+ - spec/locale/en/plural_test.po
74
+ - spec/locale/en/test.po
75
+ - spec/spec_helper.rb
76
+ - spec/vendor/fake_load_path/iconv.rb
77
+ - spec/vendor/iconv_spec.rb
78
+ - spec/vendor/string_spec.rb
79
+ - vendor/README.rdoc
80
+ - vendor/empty.mo
81
+ - vendor/iconv.rb
82
+ - vendor/mofile.rb
83
+ - vendor/poparser.rb
84
+ - vendor/string.rb
85
+ has_rdoc: true
86
+ homepage: http://github.com/grosser/fast_gettext
87
+ licenses: []
88
+
89
+ post_install_message:
90
+ rdoc_options:
91
+ - --charset=UTF-8
92
+ require_paths:
93
+ - lib
94
+ required_ruby_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: "0"
99
+ version:
100
+ required_rubygems_version: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - ">="
103
+ - !ruby/object:Gem::Version
104
+ version: "0"
105
+ version:
106
+ requirements: []
107
+
108
+ rubyforge_project: fast-gettext
109
+ rubygems_version: 1.3.5
110
+ signing_key:
111
+ specification_version: 3
112
+ summary: A simple, fast and threadsafe implementation of GetText
113
+ test_files:
114
+ - spec/fast_gettext_spec.rb
115
+ - spec/spec_helper.rb
116
+ - spec/fast_gettext/translation_spec.rb
117
+ - spec/fast_gettext/storage_spec.rb
118
+ - spec/fast_gettext/translation_repository/chain_spec.rb
119
+ - spec/fast_gettext/translation_repository/logger_spec.rb
120
+ - spec/fast_gettext/translation_repository/base_spec.rb
121
+ - spec/fast_gettext/translation_repository/po_spec.rb
122
+ - spec/fast_gettext/translation_repository/db_spec.rb
123
+ - spec/fast_gettext/translation_repository/mo_spec.rb
124
+ - spec/fast_gettext/mo_file_spec.rb
125
+ - spec/aa_unconfigued_spec.rb
126
+ - spec/vendor/iconv_spec.rb
127
+ - spec/vendor/fake_load_path/iconv.rb
128
+ - spec/vendor/string_spec.rb
129
+ - examples/db/migration.rb
130
+ - examples/missing_translation_logger.rb