gettext 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,3 +1,50 @@
1
+ 2006-04-15 Masao Mutoh <mutoh@highway.ne.jp>
2
+
3
+ * NEWS: Updated.
4
+ * lib/gettext/version.rb: Increment minor version.
5
+ * test/gettext_test_rails.rb: Works with Rails-1.1.2.
6
+ * test/gettext_test_locale.rb: Works on OpenBSD 3.8.
7
+ * ext/gettext/locale_system.c: Set nil instead of "UTF-8"
8
+ when nl_langinfo is not found.
9
+ * samples/rails/README: Updated.
10
+
11
+ 2006-04-05 Masao Mutoh <mutoh@highway.ne.jp>
12
+
13
+ * ext/gettext/locale_system.c: Fix compilation problem
14
+ when /usr/include/langinfo.h doesn't have CODESET such as OpenBSD.
15
+ You may need to set OUTPUT_CHARSET to ENV variable in such
16
+ environment.
17
+ Reported by Johan Allard.
18
+
19
+ 2006-03-25 Masao Mutoh <mutoh@highway.ne.jp>
20
+
21
+ * lib/gettext/rails.rb: Revised docs.
22
+
23
+ 2006-03-24 Masao Mutoh <mutoh@highway.ne.jp>
24
+
25
+ * lib/gettext/rails.rb: Support ActionWebService.
26
+ Reported by Nick Snels.
27
+
28
+ 2006-03-19 Masao Mutoh <mutoh@highway.ne.jp>
29
+
30
+ * lib/gettext/rails.rb: Improve multipart-mail in ja locale by Nobuhiro IMAI.
31
+
32
+ 2006-03-16 Masao Mutoh <mutoh@highway.ne.jp>
33
+
34
+ * lib/gettext/rails.rb: ActiveMailer works with multipart-mail in ja locale.
35
+ Reported by Nobuhiro IMAI.
36
+ * lib/gettext/textdomain.rb: GetText::TextDomain.gettext returns "" when
37
+ arg is "" or nil.
38
+ * lib/gettext.rb, locale.rb: Fix the problem to switch the locale again.
39
+ * test/gettext_test.rb: Add the test for above problem.
40
+ * test/gettext_test_rails.rb: Added, too.
41
+ * test/test.sh: ditto.
42
+
43
+ 2006-03-12 Masao Mutoh <mutoh@highway.ne.jp>
44
+
45
+ * lib/gettext.rb: GetText.locale= reset Locale's default locale.
46
+ Reported by Donald Piret.
47
+
1
48
  2006-03-11 Masao Mutoh <mutoh@highway.ne.jp>
2
49
 
3
50
  * lib/gettext/rails.rb: ActiveRecord::Column.human_name translates
data/NEWS CHANGED
@@ -1,4 +1,13 @@
1
- = Ruby-GetText-Package-1.3.0 (2006-03-08)
1
+ = Ruby-GetText-Package-1.4.0 (2006-04-15)
2
+
3
+ * Support OpenBSD.
4
+ * Fix bugs
5
+ * Enhance supports of Ruby on Rails.
6
+ * Improved ActionMailer localization support.
7
+ * Support ActionWebService
8
+ * test/gettext_test_rails.rb works with Rails-1.1.2.
9
+
10
+ = Ruby-GetText-Package-1.3.0 (2006-03-11)
2
11
 
3
12
  * Improve Local::Object
4
13
  * POSIX, C convert to "en".
data/README CHANGED
@@ -118,17 +118,17 @@ Swedish - Nikolai Weibull <mailing-lists.ruby-talk at rawuncut.elitem
118
118
 
119
119
  Status of translations
120
120
  ----------------------
121
- cs - 1.3.0
122
- fr - 1.3.0
123
- de - 1.3.0
124
- el - 1.3.0
125
- es - 1.3.0
126
- it - 1.0.0
127
- ja - 1.3.0
128
- ko - 1.3.0
129
- nl - 1.3.0
130
- pt_BR - 1.3.0
131
- sv - 0.8.0
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)
132
132
 
133
133
  Maintainer
134
134
  ----------
@@ -5,7 +5,7 @@
5
5
  * You may redistribute it and/or modify it under the same
6
6
  * license terms as Ruby.
7
7
  *
8
- * $Id: locale_system.c,v 1.3 2006/02/20 12:35:06 mutoh Exp $
8
+ * $Id: locale_system.c,v 1.5 2006/04/15 03:58:52 mutoh Exp $
9
9
  */
10
10
 
11
11
  #include "ruby.h"
@@ -50,13 +50,14 @@ gt_codeset(self)
50
50
  VALUE self;
51
51
  {
52
52
  #if defined HAVE_WINDOWS_H
53
+ /* This isn't used now. See lib/gettext/locale_win32.rb */
53
54
  char buf[2 + 10 + 1];
54
55
  sprintf (buf, "CP%u", GetACP ());
55
56
  return rb_str_new2(buf);
56
- #elif defined HAVE_NL_LANGINFO
57
+ #elif defined HAVE_NL_LANGINFO && defined CODESET
57
58
  return rb_str_new2(nl_langinfo(CODESET));
58
59
  #else
59
- return rb_str_new2("UTF-8");
60
+ return Qnil;
60
61
  #endif
61
62
  }
62
63
 
@@ -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: gettext.rb,v 1.10 2006/03/03 09:22:03 mutoh Exp $
13
+ $Id: gettext.rb,v 1.11 2006/03/15 16:34:05 mutoh Exp $
14
14
  =end
15
15
 
16
16
  require 'rbconfig'
@@ -199,7 +199,7 @@ module GetText
199
199
  else
200
200
  ret = nil
201
201
  end
202
- Locale.set_current(ret)
202
+ Locale.set(ret)
203
203
 
204
204
  textdomain = @@__textdomain[src]
205
205
  textdomain.set_locale(ret, true) if textdomain
@@ -217,7 +217,6 @@ module GetText
217
217
  end
218
218
 
219
219
  # Sets charset(String) such as "euc-jp", "sjis", "CP932", "utf-8", ...
220
- # This affect all of the TextDomains which are created after calling this method.
221
220
  # You shouldn't use this in your own Libraries.
222
221
  # * charset: an output_charset
223
222
  # * Returns: charset
@@ -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: locale.rb,v 1.10 2006/03/03 07:03:50 mutoh Exp $
9
+ $Id: locale.rb,v 1.11 2006/03/15 16:34:05 mutoh Exp $
10
10
  =end
11
11
 
12
12
  require 'gettext/locale_object'
@@ -159,6 +159,7 @@ module Locale
159
159
  charset = nil
160
160
  end
161
161
 
162
+ set_current(nil)
162
163
  if lang.kind_of? String
163
164
  set_default(Locale::Object.new(lang, country, charset))
164
165
  elsif lang.kind_of? Locale::Object
@@ -20,7 +20,7 @@ module GetText
20
20
 
21
21
  class PoParser < Racc::Parser
22
22
 
23
- module_eval <<'..end src/poparser.ry modeval..id8534b05645', 'src/poparser.ry', 90
23
+ module_eval <<'..end src/poparser.ry modeval..id9eaafde9e3', '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..id8534b05645', 'src/poparser.ry',
103
103
  @comments << comment
104
104
  end
105
105
 
106
- ..end src/poparser.ry modeval..id8534b05645
106
+ ..end src/poparser.ry modeval..id9eaafde9e3
107
107
 
108
108
  ##### racc 1.4.4 generates ###
109
109
 
@@ -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.26 2006/03/11 13:16:39 mutoh Exp $
9
+ $Id: rails.rb,v 1.29 2006/03/25 08:32:53 mutoh Exp $
10
10
  =end
11
11
 
12
12
  require 'gettext/cgi'
@@ -108,9 +108,13 @@ module ActionController #:nodoc:
108
108
  after_filter :init_content_type
109
109
 
110
110
  def init_gettext_main #:nodoc:
111
- cgi_ = request.cgi
112
- cgi_.params["lang"] = [@params["lang"]] if @params["lang"]
113
- bindtextdomain(@@gettext_domainname, cgi_) #You need to pass CGI object first.
111
+ if defined? request.cgi
112
+ cgi_ = request.cgi
113
+ cgi_.params["lang"] = [@params["lang"]] if @params["lang"]
114
+ bindtextdomain(@@gettext_domainname, cgi_) #You need to pass CGI object first.
115
+ else
116
+ bindtextdomain(@@gettext_domainname, nil, @params["lang"])
117
+ end
114
118
  end
115
119
 
116
120
  def init_content_type #:nodoc:
@@ -136,6 +140,10 @@ module ActionController #:nodoc:
136
140
  # * charset: the output charset. Default is "UTF-8"
137
141
  # * content_type: the content type. Default is "text/html"
138
142
  #
143
+ # locale is searched the order by @params["lang"] > "lang" value of QUERY_STRING >
144
+ # "lang" value of Cookie > HTTP_ACCEPT_LANGUAGE value > Default locale(en).
145
+ # And the charset is set order by "the argument of bindtextdomain" > HTTP_ACCEPT_CHARSET > Default charset(UTF-8).
146
+ #
139
147
  # If you want to separate the textdomain each controllers, you need to call this function in the each controllers.
140
148
  #
141
149
  # app/controller/blog_controller.rb:
@@ -386,14 +394,15 @@ module ActionMailer #:nodoc:
386
394
  end
387
395
 
388
396
  def create!(*arg) #:nodoc:
397
+ _create!(*arg)
389
398
  if Locale.get.language == "ja"
390
- require 'nkf'
391
- _create!(*arg)
392
- @mail.charset = 'iso-2022-jp'
393
- @mail.subject = base64(@mail.subject)
394
- @mail.body = NKF.nkf('-j', @mail.body)
395
- else
396
- _create!(*arg)
399
+ require 'nkf'
400
+ @mail.subject = base64(@mail.subject)
401
+ part = @mail.parts.empty? ? @mail : @mail.parts.first
402
+ if part.content_type == 'text/plain'
403
+ part.charset = 'iso-2022-jp'
404
+ part.body = NKF.nkf('-j', part.body)
405
+ end
397
406
  end
398
407
  @mail
399
408
  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.14 2006/02/23 14:53:59 mutoh Exp $
13
+ $Id: textdomain.rb,v 1.15 2006/03/15 16:55:47 mutoh Exp $
14
14
  =end
15
15
 
16
16
  require 'gettext/string'
@@ -95,6 +95,7 @@ module GetText
95
95
  # * msgid: the original message.
96
96
  # * Returns: the translated string.
97
97
  def gettext(msgid)
98
+ return "" if msgid == "" or msgid.nil?
98
99
  if @current_mo and @current_mo[msgid] and (@current_mo[msgid].size > 0)
99
100
  @current_mo[msgid]
100
101
  else
@@ -8,5 +8,5 @@
8
8
  license terms as Ruby.
9
9
  =end
10
10
  module GetText
11
- VERSION = "1.3.0"
11
+ VERSION = "1.4.0"
12
12
  end
@@ -2,8 +2,8 @@ Ruby-GetText Sample blog for Ruby on Rails and Ruby-GetText-Package.
2
2
 
3
3
  Requirement
4
4
  -----------
5
- * ruby-1.8.3
6
- * rails-1.0.0
5
+ * ruby-1.8.3 or later
6
+ * rails-1.0.0 or later
7
7
  * rake
8
8
  * mysql
9
9
 
@@ -55,6 +55,8 @@ class TestGetText < Test::Unit::TestCase
55
55
  GetText.locale = nil
56
56
  bindtextdomain("test1", "locale")
57
57
  assert_equal("japanese", gettext("language"))
58
+ assert_equal("", gettext(""))
59
+ assert_equal("", gettext(nil))
58
60
  end
59
61
 
60
62
  def test_class
@@ -239,6 +241,14 @@ DDD
239
241
  setlocale("fr")
240
242
  assert_equal("french", _("language"))
241
243
 
244
+ Locale.set "en"
245
+ bindtextdomain("test1", "locale")
246
+ assert_equal("language", _("language"))
247
+
248
+ Locale.set "ja"
249
+ bindtextdomain("test1", "locale")
250
+ assert_equal("japanese", _("language"))
251
+
242
252
  # Confirm to set Locale::Object.
243
253
  loc = Locale::Object.new("ja_JP.eucJP")
244
254
  assert_equal(loc, GetText.locale = loc)
@@ -230,12 +230,20 @@ class TestLocale < Test::Unit::TestCase
230
230
  else
231
231
  loc = Locale.get
232
232
  assert_equal("ja_JP", Locale.get.to_str)
233
- assert_equal("EUC-JP", Locale.codeset)
233
+ if /openbsd/ =~ RUBY_PLATFORM
234
+ assert_equal("eucJP", Locale.codeset)
235
+ else
236
+ assert_equal("EUC-JP", Locale.codeset)
237
+ end
234
238
 
235
239
  loc = Locale.set("ja_JP")
236
240
  assert_equal("ja_JP", loc.to_str)
237
241
  assert_equal("ja_JP", Locale.get.to_str)
238
- assert_equal("EUC-JP", Locale.codeset)
242
+ if /openbsd/ =~ RUBY_PLATFORM
243
+ assert_equal(nil, Locale.codeset)
244
+ else
245
+ assert_equal("EUC-JP", Locale.codeset)
246
+ end
239
247
 
240
248
  # Confirm to set Locale::Object
241
249
  assert_equal(loc, Locale.set(loc))
@@ -0,0 +1,38 @@
1
+ require 'test/unit'
2
+ require 'rubygems'
3
+ require_gem 'rails'
4
+ require 'initializer'
5
+ begin
6
+ require 'rails_info'
7
+ rescue Gem::Exception
8
+ module Rails
9
+ module Info
10
+ module_function
11
+ def property(name, &block)
12
+
13
+ end
14
+ end
15
+ end
16
+ end
17
+ require 'gettext/rails'
18
+ require 'stringio'
19
+
20
+ class TestRails < Test::Unit::TestCase
21
+ def setup_cgi(str)
22
+ $stdin = StringIO.new(str)
23
+ cgi = CGI.new
24
+ Locale.cgi = cgi
25
+ end
26
+
27
+ def test_bindtextdomain
28
+ #query string
29
+ Locale.default = Locale::Object.new("ja_JP.UTF-8")
30
+ GetText.locale = "fr"
31
+ GetText.bindtextdomain("test1", "locale")
32
+ assert_equal("french", GetText._("language"))
33
+ setup_cgi("lang=ja_JP")
34
+ ENV["HTTP_ACCEPT_LANGUAGE"] = "ja,en-us;q=0.7,en;q=0.3"
35
+ GetText.bindtextdomain("test1", "locale")
36
+ assert_equal("french", GetText._("language"))
37
+ end
38
+ end
@@ -3,4 +3,4 @@
3
3
  export LC_ALL="ja_JP.eucJP";
4
4
  ruby -I../lib -I../ext/gettext gettext_runner.rb $1
5
5
  ruby -I../lib -I../ext/gettext gettext_test_cgi.rb
6
-
6
+ ruby -I../lib -I../ext/gettext gettext_test_rails.rb
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.11
3
3
  specification_version: 1
4
4
  name: gettext
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.3.0
7
- date: 2006-03-11 00:00:00 +09:00
6
+ version: 1.4.0
7
+ date: 2006-04-15 00:00:00 +09:00
8
8
  summary: Ruby-GetText-Package is a libary and tools to localize messages.
9
9
  require_paths:
10
10
  - lib
@@ -669,6 +669,7 @@ files:
669
669
  - test/test_erb.rxml
670
670
  - test/locale
671
671
  - test/gettext_test_cgi.rb
672
+ - test/gettext_test_rails.rb
672
673
  - test/testlib4.rb
673
674
  - test/po/la
674
675
  - test/po/ja