gettext 1.4.0 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. data/ChangeLog +46 -0
  2. data/NEWS +9 -0
  3. data/README +28 -25
  4. data/data/locale/cs/LC_MESSAGES/rails.mo +0 -0
  5. data/data/locale/cs/LC_MESSAGES/rgettext.mo +0 -0
  6. data/data/locale/de/LC_MESSAGES/rails.mo +0 -0
  7. data/data/locale/de/LC_MESSAGES/rgettext.mo +0 -0
  8. data/data/locale/el/LC_MESSAGES/rails.mo +0 -0
  9. data/data/locale/el/LC_MESSAGES/rgettext.mo +0 -0
  10. data/data/locale/es/LC_MESSAGES/rails.mo +0 -0
  11. data/data/locale/es/LC_MESSAGES/rgettext.mo +0 -0
  12. data/data/locale/fr/LC_MESSAGES/rails.mo +0 -0
  13. data/data/locale/fr/LC_MESSAGES/rgettext.mo +0 -0
  14. data/data/locale/it/LC_MESSAGES/rgettext.mo +0 -0
  15. data/data/locale/ja/LC_MESSAGES/rails.mo +0 -0
  16. data/data/locale/ja/LC_MESSAGES/rgettext.mo +0 -0
  17. data/data/locale/ko/LC_MESSAGES/rails.mo +0 -0
  18. data/data/locale/ko/LC_MESSAGES/rgettext.mo +0 -0
  19. data/data/locale/nl/LC_MESSAGES/rails.mo +0 -0
  20. data/data/locale/nl/LC_MESSAGES/rgettext.mo +0 -0
  21. data/data/locale/pt_BR/LC_MESSAGES/rails.mo +0 -0
  22. data/data/locale/pt_BR/LC_MESSAGES/rgettext.mo +0 -0
  23. data/data/locale/ru/LC_MESSAGES/rails.mo +0 -0
  24. data/data/locale/ru/LC_MESSAGES/rgettext.mo +0 -0
  25. data/data/locale/sv/LC_MESSAGES/rgettext.mo +0 -0
  26. data/lib/gettext/mo.rb +31 -10
  27. data/lib/gettext/parser/activerecord.rb +15 -4
  28. data/lib/gettext/poparser.rb +2 -2
  29. data/lib/gettext/rails.rb +14 -5
  30. data/lib/gettext/string.rb +6 -1
  31. data/lib/gettext/textdomain.rb +33 -4
  32. data/lib/gettext/version.rb +1 -1
  33. data/po/cs/rails.po +16 -16
  34. data/po/cs/rgettext.po +2 -2
  35. data/po/de/rails.po +16 -16
  36. data/po/de/rgettext.po +2 -2
  37. data/po/el/rails.po +16 -16
  38. data/po/el/rgettext.po +2 -2
  39. data/po/es/rails.po +16 -16
  40. data/po/es/rgettext.po +2 -2
  41. data/po/fr/rails.po +16 -16
  42. data/po/fr/rgettext.po +2 -2
  43. data/po/it/rgettext.po +2 -2
  44. data/po/ja/rails.po +16 -16
  45. data/po/ja/rgettext.po +2 -2
  46. data/po/ko/rails.po +16 -16
  47. data/po/ko/rgettext.po +2 -2
  48. data/po/nl/rails.po +16 -16
  49. data/po/nl/rgettext.po +2 -2
  50. data/po/pt_BR/rails.po +16 -16
  51. data/po/pt_BR/rgettext.po +2 -2
  52. data/po/rails.pot +16 -16
  53. data/po/rgettext.pot +2 -2
  54. data/po/ru/rails.po +82 -0
  55. data/po/ru/rgettext.po +103 -0
  56. data/po/sv/rgettext.po +2 -2
  57. data/samples/cgi/locale/ru/LC_MESSAGES/helloerb1.mo +0 -0
  58. data/samples/cgi/locale/ru/LC_MESSAGES/helloerb2.mo +0 -0
  59. data/samples/cgi/locale/ru/LC_MESSAGES/hellolib.mo +0 -0
  60. data/samples/cgi/locale/ru/LC_MESSAGES/main.mo +0 -0
  61. data/samples/cgi/po/ru/helloerb1.po +58 -0
  62. data/samples/cgi/po/ru/helloerb2.po +50 -0
  63. data/samples/cgi/po/ru/hellolib.po +22 -0
  64. data/samples/cgi/po/ru/main.po +82 -0
  65. data/samples/locale/ru/LC_MESSAGES/hello.mo +0 -0
  66. data/samples/locale/ru/LC_MESSAGES/hello2.mo +0 -0
  67. data/samples/locale/ru/LC_MESSAGES/hello_noop.mo +0 -0
  68. data/samples/locale/ru/LC_MESSAGES/hello_plural.mo +0 -0
  69. data/samples/locale/ru/LC_MESSAGES/helloglade2.mo +0 -0
  70. data/samples/locale/ru/LC_MESSAGES/hellogtk.mo +0 -0
  71. data/samples/locale/ru/LC_MESSAGES/hellotk.mo +0 -0
  72. data/samples/po/ru/hello.po +22 -0
  73. data/samples/po/ru/hello2.po +30 -0
  74. data/samples/po/ru/hello_noop.po +26 -0
  75. data/samples/po/ru/hello_plural.po +25 -0
  76. data/samples/po/ru/helloglade2.po +30 -0
  77. data/samples/po/ru/hellogtk.po +22 -0
  78. data/samples/po/ru/hellotk.po +22 -0
  79. data/samples/rails/locale/ru/LC_MESSAGES/blog.mo +0 -0
  80. data/samples/rails/locale/ru/LC_MESSAGES/gettext_plugin.mo +0 -0
  81. data/samples/rails/po/ru/blog.po +108 -0
  82. data/samples/rails/po/ru/gettext_plugin.po +26 -0
  83. data/test/gettext_test_locale.rb +1 -1
  84. data/test/gettext_test_rails.rb +1 -1
  85. metadata +44 -2
data/ChangeLog CHANGED
@@ -1,3 +1,49 @@
1
+ 2006-05-07 Masao Mutoh <mutoh@highway.ne.jp>
2
+
3
+ * lib/gettext/version.rb: Increment revision number.
4
+ * NEWS: Updated.
5
+
6
+ 2006-05-06 Masao Mutoh <mutoh@highway.ne.jp>
7
+
8
+ * lib/gettext/rails.rb: error_messages_for works same as
9
+ actionpack-1.12.1 when nil or symbol are given as @object_name.
10
+ By arton.
11
+ * test/gettext_test_rails.rb: Works again.
12
+
13
+ 2006-05-05 Masao Mutoh <mutoh@highway.ne.jp>
14
+
15
+ * lib/gettext/parser/activerecord.rb: Fixed again.
16
+
17
+ 2006-05-04 Masao Mutoh <mutoh@highway.ne.jp>
18
+
19
+ * lib/gettext/parser/activerecord.rb: Fixed "duplicate message definition"
20
+ error in rake updatepo task using ActiveRecord::Base.set_table_name.
21
+ Reported by Karel Miarka.
22
+
23
+ 2006-05-02 Masao Mutoh <mutoh@highway.ne.jp>
24
+
25
+ * lib/gettext/rails.rb: Fixed an abort when Rails::Info isn't
26
+ required like as Typo. Reported by Masayoshi Takahashi.
27
+
28
+ 2006-04-30 Masao Mutoh <mutoh@highway.ne.jp>
29
+
30
+ * lib/gettext/textdomain.rb: Added GetText::TextDomain#check_mo=,
31
+ #check_mo?. When the value is true, check the MOFile and if it's
32
+ updated, reload MOFile again. This is usefule for development
33
+ time.
34
+ * lib/gettext/rails.rb: When development mode, check mo files
35
+ and reload it if it's updated.
36
+ * lib/gettext/mo.rb: Added MOFile#update!.
37
+ * lib/gettext/string.rb: String#% doesn't raise ArgumentError
38
+ when execute ruby with -d option.
39
+
40
+ 2006-04-21 Masao Mutoh <mutoh@highway.ne.jp>
41
+
42
+ * samples/po/ru/*.po, samples/cgi/po/ru/*.po,
43
+ samples/rails/po/ru/*.po, po/rgettext.po,
44
+ rails.po: Added Russian locale by Yuri Kozlov.
45
+ * README: Revised.
46
+
1
47
  2006-04-15 Masao Mutoh <mutoh@highway.ne.jp>
2
48
 
3
49
  * NEWS: Updated.
data/NEWS CHANGED
@@ -1,3 +1,12 @@
1
+ = Ruby-GetText-Package-1.5.0 (2006-05-07)
2
+
3
+ * Support Russian.
4
+ * Fix bugs.
5
+ * Refresh mo option was added.
6
+ Check mo files and reload it if it's updated.
7
+ ruby -d or GetText::TextDomain#check_mo=(true).
8
+ Or development mode in Ruby on Rails.
9
+
1
10
  = Ruby-GetText-Package-1.4.0 (2006-04-15)
2
11
 
3
12
  * Support OpenBSD.
data/README CHANGED
@@ -101,34 +101,37 @@ License
101
101
 
102
102
  Translators
103
103
  -----------
104
- Czech - Karel Miarka <kajism at yahoo.com>
105
- Dutch - Menno Jonkers <ruby-gettext at jonkers.com>
106
- French - Laurent Sansonetti <laurent.sansonetti at gmail.com>
107
- German - Detlef Reichl <detlef.reichl at gmx.org>
108
- Sven Herzberg <herzi at abi02.de>
109
- Sascha Ebach <se at digitale-wertschoepfung.de>
110
- Greek - Damphyr <damphyr at gmx.net>
111
- Italian - Gabriele Renzi <surrender_it at yahoo.it>
112
- Japanese - Masao Mutoh <mutoh at highway.ne.jp>
113
- Korean - Gyoung-Yoon Noh <nohmad at gmail.com>
114
- Portuguese(Brazil) - Joao Pedrosa <joaopedrosa at gmail.com>
115
- Spanish - David Espada <davinci at escomposlinux.org> (current)
116
- David Moreno Garza <damog at damog.net>
117
- Swedish - Nikolai Weibull <mailing-lists.ruby-talk at rawuncut.elitemail.org>
104
+ Czech(cs) - Karel Miarka <kajism at yahoo.com>
105
+ Dutch(nl) - Menno Jonkers <ruby-gettext at jonkers.com>
106
+ French(fr) - Laurent Sansonetti <laurent.sansonetti at gmail.com>
107
+ German(de) - Detlef Reichl <detlef.reichl at gmx.org>
108
+ Sven Herzberg <herzi at abi02.de>
109
+ Sascha Ebach <se at digitale-wertschoepfung.de>
110
+ Greek(el) - Damphyr <damphyr at gmx.net>
111
+ Italian(it) - Gabriele Renzi <surrender_it at yahoo.it>
112
+ Japanese(ja) - Masao Mutoh <mutoh at highway.ne.jp>
113
+ Korean(ko) - Gyoung-Yoon Noh <nohmad at gmail.com>
114
+ Portuguese(Brazil)(pt_BR) - Joao Pedrosa <joaopedrosa at gmail.com>
115
+ Russian(ru) - Yuri Kozlov <kozlov.y at gmail.com>
116
+ Spanish(es) - David Espada <davinci at escomposlinux.org> (current)
117
+ David Moreno Garza <damog at damog.net>
118
+ Swedish(sv) - Nikolai Weibull <mailing-lists.ruby-talk at rawuncut.elitemail.org>
118
119
 
119
120
  Status of translations
120
121
  ----------------------
121
- cs - 1.4.0
122
- fr - 1.4.0
123
- de - 1.4.0
124
- el - 1.4.0
125
- es - 1.4.0
126
- it - 1.0.0 (old)
127
- ja - 1.4.0
128
- ko - 1.4.0
129
- nl - 1.4.0
130
- pt_BR - 1.4.0
131
- sv - 0.8.0 (old)
122
+ Czech(cs) - 1.5.0
123
+ Dutch(nl) - 1.5.0
124
+ English(default) - 1.5.0
125
+ French(fr) - 1.5.0
126
+ German(de) - 1.5.0
127
+ Greek(el) - 1.5.0
128
+ Spanish(es) - 1.5.0
129
+ Italian(it) - 1.0.0 (old)
130
+ Japanese(ja) - 1.5.0
131
+ Korean(ko) - 1.5.0
132
+ Portuguese(Brazil)(pt_BR) - 1.5.0
133
+ Russian(ru) - 1.5.0
134
+ Swedish(sv) - 0.8.0 (old)
132
135
 
133
136
  Maintainer
134
137
  ----------
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
data/lib/gettext/mo.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  =begin
2
2
  mo.rb - A simple class for operating GNU MO file.
3
3
 
4
- Copyright (C) 2003-2005 Masao Mutoh
4
+ Copyright (C) 2003-2006 Masao Mutoh
5
5
  Copyright (C) 2002 Masahiro Sakai, Masao Mutoh
6
6
  Copyright (C) 2001 Masahiro Sakai
7
7
 
@@ -12,7 +12,7 @@
12
12
  of Ruby. License of Ruby is included with Ruby distribution in
13
13
  the file "README".
14
14
 
15
- $Id: mo.rb,v 1.3 2006/02/23 14:53:59 mutoh Exp $
15
+ $Id: mo.rb,v 1.4 2006/04/29 17:17:15 mutoh Exp $
16
16
  =end
17
17
 
18
18
  require 'gettext/iconv'
@@ -33,21 +33,42 @@ class MOFile < Hash #:nodoc:
33
33
 
34
34
  def self.open(arg = nil, output_charset = nil)
35
35
  result = self.new(output_charset)
36
- case arg
37
- when String
38
- result.load_from_file(arg)
39
- when IO
40
- result.load_from_stream(arg)
41
- end
42
- result
36
+ result.load(arg)
43
37
  end
44
38
 
45
39
  def initialize(output_charset = nil)
40
+ @filename = nil
41
+ @last_modified = Time.now
46
42
  @little_endian = true
47
43
  @output_charset = output_charset
48
44
  super()
49
45
  end
50
46
 
47
+ def update!
48
+ if FileTest.exist?(@filename)
49
+ load (@filename) unless (@last_modified == File.ctime(@filename))
50
+ else
51
+ puts "#{@filename} was lost." if $DEBUG
52
+ clear
53
+ end
54
+ self
55
+ end
56
+
57
+ def load(arg)
58
+ case arg
59
+ when String
60
+ begin
61
+ @last_modified = File.ctime(arg)
62
+ rescue Exception
63
+ end
64
+ load_from_file(arg)
65
+ when IO
66
+ load_from_stream(arg)
67
+ end
68
+ @filename = arg
69
+ self
70
+ end
71
+
51
72
  def load_from_stream(io)
52
73
  magic = io.read(4)
53
74
  case magic
@@ -238,7 +259,7 @@ class MOFile < Hash #:nodoc:
238
259
  end
239
260
 
240
261
 
241
- attr_accessor :little_endian
262
+ attr_accessor :little_endian, :path, :last_modified
242
263
  attr_reader :charset, :nplurals, :plural
243
264
  end
244
265
 
@@ -7,7 +7,7 @@
7
7
  You may redistribute it and/or modify it under the same
8
8
  license terms as Ruby.
9
9
 
10
- $Id: activerecord.rb,v 1.6 2006/02/22 16:42:41 mutoh Exp $
10
+ $Id: activerecord.rb,v 1.8 2006/05/06 14:59:08 mutoh Exp $
11
11
  =end
12
12
 
13
13
  require 'gettext'
@@ -70,15 +70,16 @@ module GetText
70
70
  loaded_constants.each do |classname|
71
71
  klass = eval(classname)
72
72
  if klass < ActiveRecord::Base
73
- targets << [::Inflector.singularize(klass.table_name.gsub(/_/, " ")), "#{file}:-"]
73
+ add_target(targets, file, ::Inflector.singularize(klass.table_name.gsub(/_/, " ")))
74
74
  tablename = klass.class_name
75
75
  begin
76
76
  klass.columns.each do |column|
77
77
  if @config[:use_classname]
78
- targets << [tablename + "|" + klass.human_attribute_name(column.name), "#{file}:-"]
78
+ msgid = tablename + "|" + klass.human_attribute_name(column.name)
79
79
  else
80
- targets << [klass.human_attribute_name(column.name), "#{file}:-"]
80
+ msgid = klass.human_attribute_name(column.name)
81
81
  end
82
+ add_target(targets, file, msgid)
82
83
  end
83
84
  rescue
84
85
  $stderr.puts _("No database is available.")
@@ -93,6 +94,16 @@ module GetText
93
94
  targets
94
95
  end
95
96
 
97
+ def add_target(targets, file, msgid) # :nodoc:
98
+ key_existed = targets.assoc(msgid)
99
+ if key_existed
100
+ targets[targets.index(key_existed)] = key_existed << "#{file}:-"
101
+ else
102
+ targets << [msgid, "#{file}:-"]
103
+ end
104
+ targets
105
+ end
106
+
96
107
  def target?(file) # :nodoc:
97
108
  init(nil) unless @ar_re
98
109
  data = IO.readlines(file)
@@ -20,7 +20,7 @@ module GetText
20
20
 
21
21
  class PoParser < Racc::Parser
22
22
 
23
- module_eval <<'..end src/poparser.ry modeval..id9eaafde9e3', 'src/poparser.ry', 90
23
+ module_eval <<'..end src/poparser.ry modeval..id4c20337d09', 'src/poparser.ry', 90
24
24
  include GetText
25
25
  GetText.bindtextdomain("rgettext")
26
26
 
@@ -103,7 +103,7 @@ module_eval <<'..end src/poparser.ry modeval..id9eaafde9e3', 'src/poparser.ry',
103
103
  @comments << comment
104
104
  end
105
105
 
106
- ..end src/poparser.ry modeval..id9eaafde9e3
106
+ ..end src/poparser.ry modeval..id4c20337d09
107
107
 
108
108
  ##### racc 1.4.4 generates ###
109
109
 
data/lib/gettext/rails.rb CHANGED
@@ -6,7 +6,7 @@
6
6
  You may redistribute it and/or modify it under the same
7
7
  license terms as Ruby.
8
8
 
9
- $Id: rails.rb,v 1.29 2006/03/25 08:32:53 mutoh Exp $
9
+ $Id: rails.rb,v 1.33 2006/05/06 14:59:08 mutoh Exp $
10
10
  =end
11
11
 
12
12
  require 'gettext/cgi'
@@ -360,9 +360,9 @@ module ActionView #:nodoc:
360
360
 
361
361
  options = options.symbolize_keys
362
362
 
363
- unless object.errors.empty?
363
+ if object && ! object.errors.empty?
364
364
  count = object.errors.count
365
- record = ActiveRecord::Base.human_attribute_table_name_for_error(object_name)
365
+ record = ActiveRecord::Base.human_attribute_table_name_for_error(object_name.to_s)
366
366
  render_error_message(object, klass, record, count, options)
367
367
  end
368
368
  end
@@ -409,6 +409,15 @@ module ActionMailer #:nodoc:
409
409
  end
410
410
  end
411
411
 
412
- Rails::Info.property("GetText version") do
413
- GetText::VERSION
412
+ begin
413
+ Rails::Info.property("GetText version") do
414
+ GetText::VERSION
415
+ end
416
+ rescue Exception
417
+ $stderr.puts "GetText: #{GetText::VERSION} Rails::Info is not found." if $DEBUG
418
+ end
419
+
420
+
421
+ if ::RAILS_ENV == "development"
422
+ GetText::TextDomain.check_mo = true
414
423
  end
@@ -42,7 +42,12 @@ class String
42
42
  ret
43
43
  else
44
44
  ret = gsub(/%\{/, '%%{')
45
- ret._old_format_m(args)
45
+ begin
46
+ ret._old_format_m(args)
47
+ rescue ArgumentError
48
+ $stderr.puts " The string:#{ret}"
49
+ $stderr.puts " args:#{args.inspect}"
50
+ end
46
51
  end
47
52
  end
48
53
  end
@@ -10,7 +10,7 @@
10
10
  You may redistribute it and/or modify it under the same
11
11
  license terms as Ruby.
12
12
 
13
- $Id: textdomain.rb,v 1.15 2006/03/15 16:55:47 mutoh Exp $
13
+ $Id: textdomain.rb,v 1.16 2006/04/29 17:17:15 mutoh Exp $
14
14
  =end
15
15
 
16
16
  require 'gettext/string'
@@ -29,6 +29,22 @@ module GetText
29
29
  attr_reader :current_locale
30
30
  attr_reader :current_mo
31
31
 
32
+ @@check_mo = false
33
+ # Check mo-file is modified or not, and if mo-file is modified,
34
+ # reload mo-file again. This is effective in debug mode.
35
+ # Default is false. If $DEBUG is true, mo-file is checked even if
36
+ # this value is false.
37
+ # * Returns: true if "check mo" mode.
38
+ def self.check_mo?
39
+ @@check_mo
40
+ end
41
+
42
+ # Sets to check mo-file or not. See GetText::TextDoman.check_mo? for more details.
43
+ # * val: true if "check mo" mode.
44
+ # * Returns: val
45
+ def self.check_mo=(val)
46
+ @@check_mo = val
47
+ end
32
48
  # The default locale paths.
33
49
  DEFAULT_LOCALE_PATHS = [
34
50
  "#{Config::CONFIG['datadir']}/locale/%{locale}/LC_MESSAGES/%{name}.mo",
@@ -145,8 +161,15 @@ module GetText
145
161
  unless reload
146
162
  @current_mo = @mofiles[@current_locale]
147
163
  if @current_mo
148
- @current_mo = (@current_mo == :empty) ? nil : @current_mo
149
- return @current_mo
164
+ if @current_mo == :empty
165
+ @current_mo = nil
166
+ return nil unless (@@check_mo or $DEBUG)
167
+ elsif (@@check_mo or $DEBUG)
168
+ @current_mo.update!
169
+ return @current_mo
170
+ else
171
+ return @current_mo
172
+ end
150
173
  end
151
174
  end
152
175
  locales = [@current_locale.orig_str, @current_locale.to_posix, @current_locale.language]
@@ -163,7 +186,13 @@ module GetText
163
186
  }
164
187
  end
165
188
  unless @current_mo
166
- @mofiles[@current_locale] = :empty
189
+ @mofiles[@current_locale] = :empty
190
+ if $DEBUG
191
+ $stderr.puts "MO file is not found in"
192
+ @search_files.each do |v|
193
+ $stderr.puts " #{v}"
194
+ end
195
+ end
167
196
  end
168
197
  @current_mo
169
198
  end
@@ -8,5 +8,5 @@
8
8
  license terms as Ruby.
9
9
  =end
10
10
  module GetText
11
- VERSION = "1.4.0"
11
+ VERSION = "1.5.0"
12
12
  end