i18n 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of i18n might be problematic. Click here for more details.

Files changed (68) hide show
  1. data/CHANGELOG.textile +19 -0
  2. data/README.textile +41 -15
  3. data/Rakefile +1 -1
  4. data/VERSION +1 -1
  5. data/lib/i18n.rb +1 -1
  6. data/lib/i18n/backend/active_record.rb +6 -5
  7. data/lib/i18n/backend/active_record/missing.rb +64 -0
  8. data/lib/i18n/backend/active_record/translation.rb +2 -2
  9. data/lib/i18n/backend/base.rb +2 -2
  10. data/lib/i18n/backend/chain.rb +3 -3
  11. data/lib/i18n/helpers/gettext.rb +1 -1
  12. data/test/all.rb +4 -4
  13. data/test/api/basics.rb +8 -8
  14. data/test/api/defaults.rb +40 -0
  15. data/test/api/interpolation.rb +65 -67
  16. data/test/api/link.rb +31 -38
  17. data/test/api/localization/date.rb +69 -50
  18. data/test/api/localization/date_time.rb +66 -42
  19. data/test/api/localization/procs.rb +54 -0
  20. data/test/api/localization/time.rb +71 -52
  21. data/test/api/lookup.rb +38 -0
  22. data/test/api/pluralization.rb +22 -24
  23. data/test/api/procs.rb +40 -0
  24. data/test/cases/api/active_record_test.rb +28 -0
  25. data/test/cases/api/all_features_test.rb +37 -0
  26. data/test/cases/api/chain_test.rb +26 -0
  27. data/test/cases/api/fallbacks_test.rb +33 -0
  28. data/test/cases/api/pluralization_test.rb +33 -0
  29. data/test/cases/api/simple_test.rb +21 -0
  30. data/test/{backend/active_record_missing/active_record_missing_test.rb → cases/backend/active_record/missing_test.rb} +5 -8
  31. data/test/{backend/active_record → cases/backend}/active_record_test.rb +13 -3
  32. data/test/{backend/cache → cases/backend}/cache_test.rb +7 -7
  33. data/test/{backend/chain → cases/backend}/chain_test.rb +1 -1
  34. data/test/{backend/fallbacks → cases/backend}/fallbacks_test.rb +5 -5
  35. data/test/{backend/simple → cases/backend}/helpers_test.rb +1 -1
  36. data/test/{backend/metadata → cases/backend}/metadata_test.rb +12 -10
  37. data/test/{backend/pluralization → cases/backend}/pluralization_test.rb +10 -10
  38. data/test/cases/backend/simple_test.rb +77 -0
  39. data/test/{core_ext → cases/core_ext}/string/interpolate_test.rb +15 -15
  40. data/test/{gettext → cases/gettext}/api_test.rb +1 -4
  41. data/test/{gettext → cases/gettext}/backend_test.rb +9 -2
  42. data/test/{i18n_exceptions_test.rb → cases/i18n_exceptions_test.rb} +1 -1
  43. data/test/{i18n_load_path_test.rb → cases/i18n_load_path_test.rb} +2 -2
  44. data/test/{i18n_test.rb → cases/i18n_test.rb} +1 -1
  45. data/test/{locale → cases/locale}/fallbacks_test.rb +1 -3
  46. data/test/{locale → cases/locale}/tag/rfc4646_test.rb +1 -3
  47. data/test/{locale → cases/locale}/tag/simple_test.rb +1 -3
  48. data/test/fixtures/locales/de.po +5 -0
  49. data/test/test_helper.rb +45 -30
  50. data/vendor/po_parser.rb +329 -0
  51. metadata +60 -69
  52. data/lib/i18n/backend/active_record_missing.rb +0 -55
  53. data/test/api/lambda.rb +0 -52
  54. data/test/api/localization/lambda.rb +0 -26
  55. data/test/api/translation.rb +0 -51
  56. data/test/backend/active_record/all.rb +0 -3
  57. data/test/backend/active_record/api_test.rb +0 -54
  58. data/test/backend/active_record/setup.rb +0 -166
  59. data/test/backend/all/api_test.rb +0 -88
  60. data/test/backend/chain/api_test.rb +0 -80
  61. data/test/backend/fallbacks/api_test.rb +0 -84
  62. data/test/backend/pluralization/api_test.rb +0 -86
  63. data/test/backend/simple/all.rb +0 -5
  64. data/test/backend/simple/api_test.rb +0 -92
  65. data/test/backend/simple/lookup_test.rb +0 -24
  66. data/test/backend/simple/setup.rb +0 -147
  67. data/test/backend/simple/translations_test.rb +0 -83
  68. data/test/with_options.rb +0 -34
@@ -0,0 +1,329 @@
1
+ =begin
2
+ poparser.rb - Generate a .mo
3
+
4
+ Copyright (C) 2003-2009 Masao Mutoh <mutoh at highway.ne.jp>
5
+
6
+ You may redistribute it and/or modify it under the same
7
+ license terms as Ruby.
8
+ =end
9
+
10
+ #MODIFIED
11
+ # removed include GetText etc
12
+ # added stub translation method _(x)
13
+ require 'racc/parser'
14
+
15
+ module GetText
16
+
17
+ class PoParser < Racc::Parser
18
+
19
+ def _(x)
20
+ x
21
+ end
22
+
23
+ module_eval <<'..end src/poparser.ry modeval..id7a99570e05', 'src/poparser.ry', 108
24
+ def unescape(orig)
25
+ ret = orig.gsub(/\\n/, "\n")
26
+ ret.gsub!(/\\t/, "\t")
27
+ ret.gsub!(/\\r/, "\r")
28
+ ret.gsub!(/\\"/, "\"")
29
+ ret
30
+ end
31
+
32
+ def parse(str, data, ignore_fuzzy = true)
33
+ @comments = []
34
+ @data = data
35
+ @fuzzy = false
36
+ @msgctxt = ""
37
+ $ignore_fuzzy = ignore_fuzzy
38
+
39
+ str.strip!
40
+ @q = []
41
+ until str.empty? do
42
+ case str
43
+ when /\A\s+/
44
+ str = $'
45
+ when /\Amsgctxt/
46
+ @q.push [:MSGCTXT, $&]
47
+ str = $'
48
+ when /\Amsgid_plural/
49
+ @q.push [:MSGID_PLURAL, $&]
50
+ str = $'
51
+ when /\Amsgid/
52
+ @q.push [:MSGID, $&]
53
+ str = $'
54
+ when /\Amsgstr/
55
+ @q.push [:MSGSTR, $&]
56
+ str = $'
57
+ when /\A\[(\d+)\]/
58
+ @q.push [:PLURAL_NUM, $1]
59
+ str = $'
60
+ when /\A\#~(.*)/
61
+ $stderr.print _("Warning: obsolete msgid exists.\n")
62
+ $stderr.print " #{$&}\n"
63
+ @q.push [:COMMENT, $&]
64
+ str = $'
65
+ when /\A\#(.*)/
66
+ @q.push [:COMMENT, $&]
67
+ str = $'
68
+ when /\A\"(.*)\"/
69
+ @q.push [:STRING, $1]
70
+ str = $'
71
+ else
72
+ #c = str[0,1]
73
+ #@q.push [:STRING, c]
74
+ str = str[1..-1]
75
+ end
76
+ end
77
+ @q.push [false, '$end']
78
+ if $DEBUG
79
+ @q.each do |a,b|
80
+ puts "[#{a}, #{b}]"
81
+ end
82
+ end
83
+ @yydebug = true if $DEBUG
84
+ do_parse
85
+
86
+ if @comments.size > 0
87
+ @data.set_comment(:last, @comments.join("\n"))
88
+ end
89
+ @data
90
+ end
91
+
92
+ def next_token
93
+ @q.shift
94
+ end
95
+
96
+ def on_message(msgid, msgstr)
97
+ if msgstr.size > 0
98
+ @data[msgid] = msgstr
99
+ @data.set_comment(msgid, @comments.join("\n"))
100
+ end
101
+ @comments.clear
102
+ @msgctxt = ""
103
+ end
104
+
105
+ def on_comment(comment)
106
+ @fuzzy = true if (/fuzzy/ =~ comment)
107
+ @comments << comment
108
+ end
109
+
110
+
111
+ ..end src/poparser.ry modeval..id7a99570e05
112
+
113
+ ##### racc 1.4.5 generates ###
114
+
115
+ racc_reduce_table = [
116
+ 0, 0, :racc_error,
117
+ 0, 10, :_reduce_none,
118
+ 2, 10, :_reduce_none,
119
+ 2, 10, :_reduce_none,
120
+ 2, 10, :_reduce_none,
121
+ 2, 12, :_reduce_5,
122
+ 1, 13, :_reduce_none,
123
+ 1, 13, :_reduce_none,
124
+ 4, 15, :_reduce_8,
125
+ 5, 16, :_reduce_9,
126
+ 2, 17, :_reduce_10,
127
+ 1, 17, :_reduce_none,
128
+ 3, 18, :_reduce_12,
129
+ 1, 11, :_reduce_13,
130
+ 2, 14, :_reduce_14,
131
+ 1, 14, :_reduce_15 ]
132
+
133
+ racc_reduce_n = 16
134
+
135
+ racc_shift_n = 26
136
+
137
+ racc_action_table = [
138
+ 3, 13, 5, 7, 9, 15, 16, 17, 20, 17,
139
+ 13, 17, 13, 13, 11, 17, 23, 20, 13, 17 ]
140
+
141
+ racc_action_check = [
142
+ 1, 16, 1, 1, 1, 12, 12, 12, 18, 18,
143
+ 7, 14, 15, 9, 3, 19, 20, 21, 23, 25 ]
144
+
145
+ racc_action_pointer = [
146
+ nil, 0, nil, 14, nil, nil, nil, 3, nil, 6,
147
+ nil, nil, 0, nil, 4, 5, -6, nil, 2, 8,
148
+ 8, 11, nil, 11, nil, 12 ]
149
+
150
+ racc_action_default = [
151
+ -1, -16, -2, -16, -3, -13, -4, -16, -6, -16,
152
+ -7, 26, -16, -15, -5, -16, -16, -14, -16, -8,
153
+ -16, -9, -11, -16, -10, -12 ]
154
+
155
+ racc_goto_table = [
156
+ 12, 22, 14, 4, 24, 6, 2, 8, 18, 19,
157
+ 10, 21, 1, nil, nil, nil, 25 ]
158
+
159
+ racc_goto_check = [
160
+ 5, 9, 5, 3, 9, 4, 2, 6, 5, 5,
161
+ 7, 8, 1, nil, nil, nil, 5 ]
162
+
163
+ racc_goto_pointer = [
164
+ nil, 12, 5, 2, 4, -7, 6, 9, -7, -17 ]
165
+
166
+ racc_goto_default = [
167
+ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil ]
168
+
169
+ racc_token_table = {
170
+ false => 0,
171
+ Object.new => 1,
172
+ :COMMENT => 2,
173
+ :MSGID => 3,
174
+ :MSGCTXT => 4,
175
+ :MSGID_PLURAL => 5,
176
+ :MSGSTR => 6,
177
+ :STRING => 7,
178
+ :PLURAL_NUM => 8 }
179
+
180
+ racc_use_result_var = true
181
+
182
+ racc_nt_base = 9
183
+
184
+ Racc_arg = [
185
+ racc_action_table,
186
+ racc_action_check,
187
+ racc_action_default,
188
+ racc_action_pointer,
189
+ racc_goto_table,
190
+ racc_goto_check,
191
+ racc_goto_default,
192
+ racc_goto_pointer,
193
+ racc_nt_base,
194
+ racc_reduce_table,
195
+ racc_token_table,
196
+ racc_shift_n,
197
+ racc_reduce_n,
198
+ racc_use_result_var ]
199
+
200
+ Racc_token_to_s_table = [
201
+ '$end',
202
+ 'error',
203
+ 'COMMENT',
204
+ 'MSGID',
205
+ 'MSGCTXT',
206
+ 'MSGID_PLURAL',
207
+ 'MSGSTR',
208
+ 'STRING',
209
+ 'PLURAL_NUM',
210
+ '$start',
211
+ 'msgfmt',
212
+ 'comment',
213
+ 'msgctxt',
214
+ 'message',
215
+ 'string_list',
216
+ 'single_message',
217
+ 'plural_message',
218
+ 'msgstr_plural',
219
+ 'msgstr_plural_line']
220
+
221
+ Racc_debug_parser = true
222
+
223
+ ##### racc system variables end #####
224
+
225
+ # reduce 0 omitted
226
+
227
+ # reduce 1 omitted
228
+
229
+ # reduce 2 omitted
230
+
231
+ # reduce 3 omitted
232
+
233
+ # reduce 4 omitted
234
+
235
+ module_eval <<'.,.,', 'src/poparser.ry', 25
236
+ def _reduce_5( val, _values, result )
237
+ @msgctxt = unescape(val[1]) + "\004"
238
+ result
239
+ end
240
+ .,.,
241
+
242
+ # reduce 6 omitted
243
+
244
+ # reduce 7 omitted
245
+
246
+ module_eval <<'.,.,', 'src/poparser.ry', 48
247
+ def _reduce_8( val, _values, result )
248
+ if @fuzzy and $ignore_fuzzy
249
+ if val[1] != ""
250
+ $stderr.print _("Warning: fuzzy message was ignored.\n")
251
+ $stderr.print " msgid '#{val[1]}'\n"
252
+ else
253
+ on_message('', unescape(val[3]))
254
+ end
255
+ @fuzzy = false
256
+ else
257
+ on_message(@msgctxt + unescape(val[1]), unescape(val[3]))
258
+ end
259
+ result = ""
260
+ result
261
+ end
262
+ .,.,
263
+
264
+ module_eval <<'.,.,', 'src/poparser.ry', 65
265
+ def _reduce_9( val, _values, result )
266
+ if @fuzzy and $ignore_fuzzy
267
+ if val[1] != ""
268
+ $stderr.print _("Warning: fuzzy message was ignored.\n")
269
+ $stderr.print "msgid = '#{val[1]}\n"
270
+ else
271
+ on_message('', unescape(val[3]))
272
+ end
273
+ @fuzzy = false
274
+ else
275
+ on_message(@msgctxt + unescape(val[1]) + "\000" + unescape(val[3]), unescape(val[4]))
276
+ end
277
+ result = ""
278
+ result
279
+ end
280
+ .,.,
281
+
282
+ module_eval <<'.,.,', 'src/poparser.ry', 76
283
+ def _reduce_10( val, _values, result )
284
+ if val[0].size > 0
285
+ result = val[0] + "\000" + val[1]
286
+ else
287
+ result = ""
288
+ end
289
+ result
290
+ end
291
+ .,.,
292
+
293
+ # reduce 11 omitted
294
+
295
+ module_eval <<'.,.,', 'src/poparser.ry', 84
296
+ def _reduce_12( val, _values, result )
297
+ result = val[2]
298
+ result
299
+ end
300
+ .,.,
301
+
302
+ module_eval <<'.,.,', 'src/poparser.ry', 91
303
+ def _reduce_13( val, _values, result )
304
+ on_comment(val[0])
305
+ result
306
+ end
307
+ .,.,
308
+
309
+ module_eval <<'.,.,', 'src/poparser.ry', 99
310
+ def _reduce_14( val, _values, result )
311
+ result = val.delete_if{|item| item == ""}.join
312
+ result
313
+ end
314
+ .,.,
315
+
316
+ module_eval <<'.,.,', 'src/poparser.ry', 103
317
+ def _reduce_15( val, _values, result )
318
+ result = val[0]
319
+ result
320
+ end
321
+ .,.,
322
+
323
+ def _reduce_none( val, _values, result )
324
+ result
325
+ end
326
+
327
+ end # class PoParser
328
+
329
+ end # module GetText
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: i18n
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sven Fuchs
@@ -13,7 +13,7 @@ autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
15
 
16
- date: 2009-11-30 00:00:00 +01:00
16
+ date: 2009-12-11 00:00:00 +01:00
17
17
  default_executable:
18
18
  dependencies: []
19
19
 
@@ -34,9 +34,9 @@ files:
34
34
  - lib/i18n.rb
35
35
  - lib/i18n/backend.rb
36
36
  - lib/i18n/backend/active_record.rb
37
+ - lib/i18n/backend/active_record/missing.rb
37
38
  - lib/i18n/backend/active_record/store_procs.rb
38
39
  - lib/i18n/backend/active_record/translation.rb
39
- - lib/i18n/backend/active_record_missing.rb
40
40
  - lib/i18n/backend/base.rb
41
41
  - lib/i18n/backend/cache.rb
42
42
  - lib/i18n/backend/chain.rb
@@ -60,50 +60,46 @@ files:
60
60
  - lib/i18n/locale/tag/simple.rb
61
61
  - test/all.rb
62
62
  - test/api/basics.rb
63
+ - test/api/defaults.rb
63
64
  - test/api/interpolation.rb
64
- - test/api/lambda.rb
65
65
  - test/api/link.rb
66
66
  - test/api/localization/date.rb
67
67
  - test/api/localization/date_time.rb
68
- - test/api/localization/lambda.rb
68
+ - test/api/localization/procs.rb
69
69
  - test/api/localization/time.rb
70
+ - test/api/lookup.rb
70
71
  - test/api/pluralization.rb
71
- - test/api/translation.rb
72
- - test/backend/active_record/active_record_test.rb
73
- - test/backend/active_record/all.rb
74
- - test/backend/active_record/api_test.rb
75
- - test/backend/active_record/setup.rb
76
- - test/backend/active_record_missing/active_record_missing_test.rb
77
- - test/backend/all/api_test.rb
78
- - test/backend/cache/cache_test.rb
79
- - test/backend/chain/api_test.rb
80
- - test/backend/chain/chain_test.rb
81
- - test/backend/fallbacks/api_test.rb
82
- - test/backend/fallbacks/fallbacks_test.rb
83
- - test/backend/metadata/metadata_test.rb
84
- - test/backend/pluralization/api_test.rb
85
- - test/backend/pluralization/pluralization_test.rb
86
- - test/backend/simple/all.rb
87
- - test/backend/simple/api_test.rb
88
- - test/backend/simple/helpers_test.rb
89
- - test/backend/simple/lookup_test.rb
90
- - test/backend/simple/setup.rb
91
- - test/backend/simple/translations_test.rb
92
- - test/core_ext/string/interpolate_test.rb
72
+ - test/api/procs.rb
73
+ - test/cases/api/active_record_test.rb
74
+ - test/cases/api/all_features_test.rb
75
+ - test/cases/api/chain_test.rb
76
+ - test/cases/api/fallbacks_test.rb
77
+ - test/cases/api/pluralization_test.rb
78
+ - test/cases/api/simple_test.rb
79
+ - test/cases/backend/active_record/missing_test.rb
80
+ - test/cases/backend/active_record_test.rb
81
+ - test/cases/backend/cache_test.rb
82
+ - test/cases/backend/chain_test.rb
83
+ - test/cases/backend/fallbacks_test.rb
84
+ - test/cases/backend/helpers_test.rb
85
+ - test/cases/backend/metadata_test.rb
86
+ - test/cases/backend/pluralization_test.rb
87
+ - test/cases/backend/simple_test.rb
88
+ - test/cases/core_ext/string/interpolate_test.rb
89
+ - test/cases/gettext/api_test.rb
90
+ - test/cases/gettext/backend_test.rb
91
+ - test/cases/i18n_exceptions_test.rb
92
+ - test/cases/i18n_load_path_test.rb
93
+ - test/cases/i18n_test.rb
94
+ - test/cases/locale/fallbacks_test.rb
95
+ - test/cases/locale/tag/rfc4646_test.rb
96
+ - test/cases/locale/tag/simple_test.rb
93
97
  - test/fixtures/locales/de.po
94
98
  - test/fixtures/locales/en.rb
95
99
  - test/fixtures/locales/en.yml
96
100
  - test/fixtures/locales/plurals.rb
97
- - test/gettext/api_test.rb
98
- - test/gettext/backend_test.rb
99
- - test/i18n_exceptions_test.rb
100
- - test/i18n_load_path_test.rb
101
- - test/i18n_test.rb
102
- - test/locale/fallbacks_test.rb
103
- - test/locale/tag/rfc4646_test.rb
104
- - test/locale/tag/simple_test.rb
105
101
  - test/test_helper.rb
106
- - test/with_options.rb
102
+ - vendor/po_parser.rb
107
103
  has_rdoc: true
108
104
  homepage: http://rails-i18n.org
109
105
  licenses: []
@@ -135,45 +131,40 @@ summary: New wave Internationalization support for Ruby
135
131
  test_files:
136
132
  - test/all.rb
137
133
  - test/api/basics.rb
134
+ - test/api/defaults.rb
138
135
  - test/api/interpolation.rb
139
- - test/api/lambda.rb
140
136
  - test/api/link.rb
141
137
  - test/api/localization/date.rb
142
138
  - test/api/localization/date_time.rb
143
- - test/api/localization/lambda.rb
139
+ - test/api/localization/procs.rb
144
140
  - test/api/localization/time.rb
141
+ - test/api/lookup.rb
145
142
  - test/api/pluralization.rb
146
- - test/api/translation.rb
147
- - test/backend/active_record/active_record_test.rb
148
- - test/backend/active_record/all.rb
149
- - test/backend/active_record/api_test.rb
150
- - test/backend/active_record/setup.rb
151
- - test/backend/active_record_missing/active_record_missing_test.rb
152
- - test/backend/all/api_test.rb
153
- - test/backend/cache/cache_test.rb
154
- - test/backend/chain/api_test.rb
155
- - test/backend/chain/chain_test.rb
156
- - test/backend/fallbacks/api_test.rb
157
- - test/backend/fallbacks/fallbacks_test.rb
158
- - test/backend/metadata/metadata_test.rb
159
- - test/backend/pluralization/api_test.rb
160
- - test/backend/pluralization/pluralization_test.rb
161
- - test/backend/simple/all.rb
162
- - test/backend/simple/api_test.rb
163
- - test/backend/simple/helpers_test.rb
164
- - test/backend/simple/lookup_test.rb
165
- - test/backend/simple/setup.rb
166
- - test/backend/simple/translations_test.rb
167
- - test/core_ext/string/interpolate_test.rb
143
+ - test/api/procs.rb
144
+ - test/cases/api/active_record_test.rb
145
+ - test/cases/api/all_features_test.rb
146
+ - test/cases/api/chain_test.rb
147
+ - test/cases/api/fallbacks_test.rb
148
+ - test/cases/api/pluralization_test.rb
149
+ - test/cases/api/simple_test.rb
150
+ - test/cases/backend/active_record/missing_test.rb
151
+ - test/cases/backend/active_record_test.rb
152
+ - test/cases/backend/cache_test.rb
153
+ - test/cases/backend/chain_test.rb
154
+ - test/cases/backend/fallbacks_test.rb
155
+ - test/cases/backend/helpers_test.rb
156
+ - test/cases/backend/metadata_test.rb
157
+ - test/cases/backend/pluralization_test.rb
158
+ - test/cases/backend/simple_test.rb
159
+ - test/cases/core_ext/string/interpolate_test.rb
160
+ - test/cases/gettext/api_test.rb
161
+ - test/cases/gettext/backend_test.rb
162
+ - test/cases/i18n_exceptions_test.rb
163
+ - test/cases/i18n_load_path_test.rb
164
+ - test/cases/i18n_test.rb
165
+ - test/cases/locale/fallbacks_test.rb
166
+ - test/cases/locale/tag/rfc4646_test.rb
167
+ - test/cases/locale/tag/simple_test.rb
168
168
  - test/fixtures/locales/en.rb
169
169
  - test/fixtures/locales/plurals.rb
170
- - test/gettext/api_test.rb
171
- - test/gettext/backend_test.rb
172
- - test/i18n_exceptions_test.rb
173
- - test/i18n_load_path_test.rb
174
- - test/i18n_test.rb
175
- - test/locale/fallbacks_test.rb
176
- - test/locale/tag/rfc4646_test.rb
177
- - test/locale/tag/simple_test.rb
178
170
  - test/test_helper.rb
179
- - test/with_options.rb