gettext 1.2.0-mswin32 → 1.3.0-mswin32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. data/ChangeLog +74 -0
  2. data/NEWS +16 -0
  3. data/README +9 -9
  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/sv/LC_MESSAGES/rgettext.mo +0 -0
  24. data/lib/gettext.rb +9 -4
  25. data/lib/gettext/locale.rb +11 -5
  26. data/lib/gettext/locale_cgi.rb +2 -5
  27. data/lib/gettext/locale_object.rb +68 -21
  28. data/lib/gettext/poparser.rb +2 -2
  29. data/lib/gettext/rails.rb +150 -30
  30. data/lib/gettext/version.rb +1 -1
  31. data/po/cs/rails.po +27 -27
  32. data/po/cs/rgettext.po +8 -8
  33. data/po/de/rails.po +28 -28
  34. data/po/de/rgettext.po +8 -8
  35. data/po/el/rails.po +25 -25
  36. data/po/el/rgettext.po +8 -8
  37. data/po/es/rails.po +25 -25
  38. data/po/es/rgettext.po +8 -8
  39. data/po/fr/rails.po +26 -26
  40. data/po/fr/rgettext.po +8 -8
  41. data/po/it/rgettext.po +8 -8
  42. data/po/ja/rails.po +23 -23
  43. data/po/ja/rgettext.po +8 -8
  44. data/po/ko/rails.po +23 -23
  45. data/po/ko/rgettext.po +8 -8
  46. data/po/nl/rails.po +25 -25
  47. data/po/nl/rgettext.po +8 -8
  48. data/po/pt_BR/rails.po +25 -25
  49. data/po/pt_BR/rgettext.po +8 -8
  50. data/po/rails.pot +25 -25
  51. data/po/rgettext.pot +8 -8
  52. data/po/sv/rgettext.po +8 -8
  53. data/samples/rails/README +3 -2
  54. data/samples/rails/Rakefile +6 -217
  55. data/samples/rails/app/controllers/application.rb +1 -0
  56. data/samples/rails/app/models/article.rb +7 -16
  57. data/samples/rails/config/database.yml +2 -1
  58. data/samples/rails/lib/tasks/gettext.rake +18 -0
  59. data/samples/rails/locale/ja/LC_MESSAGES/blog.mo +0 -0
  60. data/samples/rails/po/ja/blog.po +12 -0
  61. data/samples/rails/public/index.html +15 -17
  62. data/samples/rails/public/javascripts/controls.js +30 -1
  63. data/samples/rails/public/javascripts/dragdrop.js +210 -145
  64. data/samples/rails/public/javascripts/effects.js +261 -399
  65. data/samples/rails/public/javascripts/prototype.js +131 -72
  66. data/test/gettext_test.rb +5 -0
  67. data/test/gettext_test_locale.rb +133 -9
  68. metadata +5 -4
  69. data/samples/rails/script/benchmarker +0 -19
  70. data/samples/rails/script/profiler +0 -34
data/ChangeLog CHANGED
@@ -1,3 +1,77 @@
1
+ 2006-03-11 Masao Mutoh <mutoh@highway.ne.jp>
2
+
3
+ * lib/gettext/rails.rb: ActiveRecord::Column.human_name translates
4
+ the column name using s_("Model|fieldname").
5
+ Pointed out by Kazuhiro NISHIYAMA.
6
+ * samples/rails/lib/tasks/gettext.rake: Move from Rakefile.
7
+ Pointed out by Kazuhiro NISHIYAMA.
8
+ * samples/rails/Rakefile: Move gettext tasks to lib/tasks/gettext.rake.
9
+ * samples/rails/*: Updates files to which generated with rails 1.0.
10
+ * NEWS: Updated.
11
+
12
+ 2006-03-10 Masao Mutoh <mutoh@highway.ne.jp>
13
+
14
+ * lib/gettext/rails.rb: Localized ActiveRecord::Base.validates_* works correctly
15
+ under production mode.
16
+ Reported by Nickolay Kolev.
17
+ ActionView::Base#render_file supports localized template such as
18
+ foo_ja.rhml, foo_ja_JP.rhtml. Revert Action::Controller::Base#render.
19
+ * NEWS: follow this change.
20
+
21
+ 2006-03-09 Masao Mutoh <mutoh@highway.ne.jp>
22
+
23
+ * lib/gettext/rails.rb: ActiveRecord::Base.error_message_(title|explanation)
24
+ works production mode.
25
+
26
+ 2006-03-08 Masao Mutoh <mutoh@highway.ne.jp>
27
+
28
+ * NEWS: Updated.
29
+ * lib/gettext/rails.rb: Fix a problem of ActionMailer in "ja".
30
+ * lib/gettext/version.rb: Incremented version number.
31
+
32
+ 2006-03-04 Masao Mutoh <mutoh@highway.ne.jp>
33
+
34
+ * lib/gettext/rails.rb: @params["lang"] is treated as cgi["lang"].
35
+ Reported by Erkki Eilonen.
36
+
37
+ 2006-03-03 Masao Mutoh <mutoh@highway.ne.jp>
38
+
39
+ * lib/gettext/locale_cgi.rb: Remove debug code.
40
+ * lib/gettext/locale_object.rb:
41
+ - Fix a memory leak. Reported by Jonas Schwertfeger.
42
+ - Locale::Object.parser improved.
43
+ - Rename Locale::Object#sort_order to #variant.
44
+ - "POSIX" and "C" locale strings are converted to "en".
45
+ - Add Locale::Object#to_general.
46
+ * test/gettext_test_locale.rb: Add tests follow the changes.
47
+ * lib/gettext/rails.rb:
48
+ - ActionMailer sends a mail
49
+ - in ISO-2022-JP if the language is japanese. The idea from
50
+ Iso2022Mailer by drawnboy.
51
+ - ActionController::Base.render_text is overrided to find
52
+ localized templates such as foo_ja.rhml, foo_ja_JP.rhtml.
53
+ You can reject this to set false to
54
+ GetText::Rails.use_localized_templates.
55
+ The idea is from Yugui.
56
+
57
+ 2006-03-02 Masao Mutoh <mutoh@highway.ne.jp>
58
+
59
+ * samples/rails/app/models/article.rb: Add a sample of
60
+ ActiveRecord::Base.set_error_message_(title|explanation).
61
+ * lib/gettext/rails.rb: Fix a non-translated problem on production mode.
62
+ ActionMailer supported by Albert Ramstedt.
63
+ ActiveRecord::Base.set_error_message_(title|explanation) accepts Nn_()
64
+ value(Array).
65
+
66
+ 2006-02-25 Masao Mutoh <mutoh@highway.ne.jp>
67
+
68
+ * lib/gettext/locale.rb: Fix to return system value when @@default is unset.
69
+ * lib/gettext/rails.rb: Fix a problem with Locale.default=.
70
+
71
+ 2006-02-24 Masao Mutoh <mutoh@highway.ne.jp>
72
+
73
+ * lib/gettext.rb: Fix a typo.
74
+
1
75
  2006-02-23 Masao Mutoh <mutoh@highway.ne.jp>
2
76
 
3
77
  * Rakefile: Fix a problem to make package on Win32.
data/NEWS CHANGED
@@ -1,3 +1,19 @@
1
+ = Ruby-GetText-Package-1.3.0 (2006-03-08)
2
+
3
+ * Improve Local::Object
4
+ * POSIX, C convert to "en".
5
+ * Enhance supports of Ruby on Rails.
6
+ * ActionMailer localization support.
7
+ * Use GetText function(_() N_() etc) in template.
8
+ * ISO-2022-JP charset is used when language is "ja"(Japanese).
9
+ * Localization templates support.
10
+ * ActionController::Base.render_text is overrided to find
11
+ localized templates such as foo_ja.rhml, foo_ja_JP.rhtml.
12
+ * @params["lang"] is treated as cgi["lang"]
13
+ * Use N_() as localized messages of validates_* instead of _().
14
+ * Translates ActiveRecord::Column.human_name values automatically.
15
+ * Fix memory leak, other bugs.
16
+
1
17
  = Ruby-GetText-Package-1.2.0 (2006-02-23)
2
18
 
3
19
  * Re-implement Locale module and Implements Locale::Object,
data/README CHANGED
@@ -118,16 +118,16 @@ Swedish - Nikolai Weibull <mailing-lists.ruby-talk at rawuncut.elitem
118
118
 
119
119
  Status of translations
120
120
  ----------------------
121
- cs - 1.2.0
122
- fr - 1.2.0
123
- de - 1.2.0
124
- el - 1.2.0
125
- es - 1.2.0
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
126
  it - 1.0.0
127
- ja - 1.2.0
128
- ko - 1.2.0
129
- nl - 1.2.0
130
- pt_BR - 1.2.0
127
+ ja - 1.3.0
128
+ ko - 1.3.0
129
+ nl - 1.3.0
130
+ pt_BR - 1.3.0
131
131
  sv - 0.8.0
132
132
 
133
133
  Maintainer
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.rb CHANGED
@@ -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.8 2006/02/20 12:35:06 mutoh Exp $
13
+ $Id: gettext.rb,v 1.10 2006/03/03 09:22:03 mutoh Exp $
14
14
  =end
15
15
 
16
16
  require 'rbconfig'
@@ -145,6 +145,7 @@ module GetText
145
145
 
146
146
  # This is same function as N_ but for ngettext.
147
147
  # * msgid: the message id.
148
+ # * msgid_plural: the plural message id.
148
149
  # * Returns: msgid.
149
150
  def Nn_(msgid, msgid_plural)
150
151
  [msgid, msgid_plural]
@@ -181,15 +182,19 @@ module GetText
181
182
  caller(2)[0].sub(/:\d+(?::in \`\S+\')?\Z/, '')
182
183
  end
183
184
 
184
- # Sets locale(String) such as "de", "fr", "it", "ko", "ja_JP.eucJP", "zh_CN.EUC" ...
185
+ # Sets locale such as "de", "fr", "it", "ko", "ja_JP.eucJP", "zh_CN.EUC" ...
185
186
  #
186
187
  # Notice that you shouldn't use this for your own Libraries.
187
- # * locale: a locale string
188
+ # * locale: a locale string or Locale::Object.
188
189
  # * src: internal usage only. You shouldn't use this.
189
190
  # * Returns: self
190
191
  def set_locale(locale, src = callersrc)
191
192
  if locale
192
- ret = Locale::Object.new(locale)
193
+ if locale.kind_of? Locale::Object
194
+ ret = locale
195
+ else
196
+ ret = Locale::Object.new(locale.to_s)
197
+ end
193
198
  ret.charset = @@__output_charset if @@__output_charset
194
199
  else
195
200
  ret = nil
@@ -1,12 +1,12 @@
1
1
  =begin
2
2
  locale.rb - Locale module
3
3
 
4
- Copyright (C) 2002-2005 Masao Mutoh
4
+ Copyright (C) 2002-2006 Masao Mutoh
5
5
 
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.9 2006/02/20 12:35:06 mutoh Exp $
9
+ $Id: locale.rb,v 1.10 2006/03/03 07:03:50 mutoh Exp $
10
10
  =end
11
11
 
12
12
  require 'gettext/locale_object'
@@ -87,8 +87,7 @@ module Locale
87
87
  # If the default locale not set, this returns system locale.
88
88
  # * Returns: the default locale (Locale::Object).
89
89
  def default
90
- @@default = system unless @@default
91
- @@default
90
+ @@default ? @@default : system
92
91
  end
93
92
 
94
93
  # Gets the current locale (Locale::Object).
@@ -143,6 +142,11 @@ module Locale
143
142
  # set(lang)
144
143
  # set(lang, country = nil, charset = nil)
145
144
  #
145
+ # * lang: language as String, or Locale::Object
146
+ # * country: country as String or nil
147
+ # * charset: charset as String or nil
148
+ # * Returns: a Locale::Object.
149
+ #
146
150
  # Sets a default locale. This function is an alias of Locale.set_default.
147
151
  #
148
152
  # *Notice*: Locale.set(lctype, locale) is deprecated.
@@ -155,8 +159,10 @@ module Locale
155
159
  charset = nil
156
160
  end
157
161
 
158
- if lang
162
+ if lang.kind_of? String
159
163
  set_default(Locale::Object.new(lang, country, charset))
164
+ elsif lang.kind_of? Locale::Object
165
+ set_default(lang)
160
166
  else
161
167
  set_default(nil)
162
168
  end
@@ -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_cgi.rb,v 1.1 2006/02/20 12:35:06 mutoh Exp $
9
+ $Id: locale_cgi.rb,v 1.3 2006/03/07 17:26:57 mutoh Exp $
10
10
  =end
11
11
 
12
12
 
@@ -23,16 +23,13 @@ module Locale # :nodoc:
23
23
  def system
24
24
  cgi_ = cgi
25
25
  if ret = cgi_["lang"] and ret.size > 0
26
- $stderr.print "query_string: lang = #{ret}\n" if $DEBUG
27
26
  elsif ret = cgi_.cookies["lang"][0]
28
- $stderr.print "cookie: lang = #{ret}\n" if $DEBUG
29
27
  elsif lang = cgi_.accept_language and lang.size > 0
30
- $stderr.print "accept lanaugage: lang = #{lang}\n" if $DEBUG
31
28
  ret = lang.split(/,|;/).first
32
29
  else
33
30
  ret = @@default_locale.to_str
34
31
  end
35
-
32
+
36
33
  codesets = cgi_.accept_charset
37
34
  if codesets and codesets.size > 0
38
35
  ary = codesets.split(',')
@@ -6,23 +6,29 @@
6
6
  You may redistribute it and/or modify it under the same
7
7
  license terms as Ruby.
8
8
 
9
- $Id: locale_object.rb,v 1.6 2006/02/20 16:12:05 mutoh Exp $
9
+ $Id: locale_object.rb,v 1.7 2006/03/03 07:03:50 mutoh Exp $
10
10
  =end
11
11
 
12
12
 
13
13
  module Locale # :nodoc:
14
14
  class Object
15
- attr_accessor :language, :country, :charset, :script, :sort_order, :modifier, :orig_str
15
+ attr_accessor :language, :country, :charset, :script, :variant, :modifier, :orig_str
16
16
 
17
17
  # Parse POSIX or RFC 3066 style locale name to Array.
18
18
  #
19
19
  # * locale_name: locale name as String
20
20
  #
21
21
  # * Basic POSIX format: <language>_<COUNTRY>.<charset>@<modifier>
22
+ # * Both of POSIX and C are converted to "en".
22
23
  # * Basic RFC3066 format: <language>-<COUNTRY>
24
+ # * Win32 format: <language>-<COUNTRY>-<Script>_<sort order>
25
+ # * CLDR format: <language>_<Script>_<COUNTRY>_<variant>@<modifier>
26
+ # * Some broken format: <language>_<country>_<script> # Don't use this.
23
27
  # * The max locale format is below:
24
- # <language>-<COUNTRY>-<Script>_<sort order>.<charset>@<modifier>
25
- # * both of '-' and '_' are separators.
28
+ # * <language>-<COUNTRY>-<Script>_<sort order>.<charset>@<modifier>
29
+ # * format: <language>_<Script>_<COUNTRY>_<variant>@<modifier>
30
+ # * both of '-' and '_' are separators.
31
+ # * each elements are omittable.
26
32
  #
27
33
  # (e.g.) uz-UZ-Latn, ja_JP.eucJP, wa_BE.iso885915@euro
28
34
  # * Returns: [language, country, charset, script, modifier]
@@ -30,10 +36,9 @@ module Locale # :nodoc:
30
36
  # * country: an uppercase ISO 3166-1 country/region identifier.
31
37
  # * charset: charset(codeset) (no standard)
32
38
  # * script: an initial-uppercase ISO 15924 script code.
33
- # * sort_order: (Win32 only?)
39
+ # * variant: variant value in CLDR or sort order in Win32.
34
40
  # * modifier: (no standard)
35
41
  #
36
- # script, sort_order and modifier are not used now.
37
42
  #
38
43
  # "ja_JP.eucJP" => ["ja", "JP", "eucJP", nil, nil]
39
44
  # "ja-jp.utf-8" => ["ja", "JP", "utf-8", nil, nil]
@@ -41,16 +46,38 @@ module Locale # :nodoc:
41
46
  # "ja" => ["ja", nil, nil, nil, nil]
42
47
  # "uz@Latn" => ["uz", nil, nil, nil, "Latn"]
43
48
  # "uz-UZ-Latn" => ["uz", "UZ", nil, "Latn", nil]
49
+ # "uz_UZ_Latn" => ["uz", "UZ", nil, "Latn", nil]
44
50
  # "wa_BE.iso885915@euro" => ["wa", "BE", "iso885915", nil, "euro"]
51
+ # "C" => ["en", nil, nil, nil, nil]
52
+ # "POSIX" => ["en", nil, nil, nil, nil]
53
+ # "zh_Hant" => ["zh", nil, nil, "Hant", nil]
54
+ # "zh_Hant_HK" => ["zh", "HK", nil, "Hant", nil]
55
+ # "de_DE@collation=phonebook,currency=DDM" => ["de", "DE", nil, nil, "collation=phonebook,currency=DDM"]
45
56
  def self.parse(locale_name)
46
57
  lang_charset, modifier = locale_name.split(/@/)
47
58
  lang, charset = lang_charset.split(/\./)
48
- language, country, script, sort_order = lang.sub(/_/, "-").split('-')
59
+ language, country, script, variant = lang.gsub(/_/, "-").split('-')
49
60
  language = language ? language.downcase : nil
50
- language = "C" if language == "c"
51
- country = country ? country.upcase : nil
52
- script = script ? script[0].chr.upcase + script[1..script.size].downcase : nil
53
- [language, country, charset, script, sort_order, modifier]
61
+ language = "en" if language == "c" || language == "posix"
62
+ if country
63
+ if country =~ /[A-Z][a-z]+/ #Latn => script
64
+ tmp = script
65
+ script = country
66
+ if tmp =~ /[A-Z]+/ # US => country
67
+ country = tmp
68
+ else
69
+ country = nil
70
+ variant = tmp
71
+ end
72
+ else
73
+ country = country.upcase
74
+ if script !~ /[A-Z][a-z]+/ #Latn => script
75
+ variant = script
76
+ script = nil
77
+ end
78
+ end
79
+ end
80
+ [language, country, charset, script, variant, modifier]
54
81
  end
55
82
 
56
83
  # Initialize Locale::Object.
@@ -70,11 +97,17 @@ module Locale # :nodoc:
70
97
  # -> language = "en", country = "CA", charset = nil.
71
98
  # Locale::Object.new("uz-uz-latn")
72
99
  # -> language = "uz", country = "UZ", charset = nil, script = "Latn"
100
+ # Locale::Object.new("uz_UZ_Latn")
101
+ # -> language = "uz", country = "UZ", charset = nil, script = "Latn"
73
102
  # Locale::Object.new("we_BE.iso885915@euro")
74
103
  # -> language = "we", country = "BE", charset = "iso885915", modifier = "euroo".
104
+ # Locale::Object.new("C")
105
+ # -> language = "en", country = nil, charset = nil.
106
+ # Locale::Object.new("POSIX")
107
+ # -> language = "en", country = nil, charset = nil.
75
108
  def initialize(language_or_locale_name, country = nil, charset = nil)
76
109
  @orig_str = language_or_locale_name
77
- @language, @country, @charset, @script, @sort_order, @modifier =
110
+ @language, @country, @charset, @script, @variant, @modifier =
78
111
  self.class.parse(language_or_locale_name)
79
112
  @country = country if country
80
113
  @charset = charset if charset
@@ -94,7 +127,9 @@ module Locale # :nodoc:
94
127
  ret
95
128
  end
96
129
 
97
- # Returns the locale as Win32 format. (e.g.) "az_AZ-Latn"
130
+ # Returns the locale as Win32 format. (e.g.) "az-AZ-Latn".
131
+ #
132
+ # This is used to find the charset from locale table.
98
133
  def to_win
99
134
  ret = @language
100
135
  ret += "-#{@country}" if @country
@@ -102,29 +137,41 @@ module Locale # :nodoc:
102
137
  ret
103
138
  end
104
139
 
140
+ # Returns the locale as 'ruby' general format. (e.g.) "az_AZ_Latn"
141
+ def to_general
142
+ ret = @language
143
+ ret += "_#{@country}" if @country
144
+ ret += "_#{@script}" if @script
145
+ ret
146
+ end
147
+
105
148
  # Gets the locale informations as an Array.
106
- # * Returns [language, country, charset, script, sort_order, modifier]
149
+ # * Returns [language, country, charset, script, variant, modifier]
107
150
  # * language: a lowercase ISO 639(or 639-2/T) language code.
108
151
  # * country: an uppercase ISO 3166-1 country/region identifier.
109
152
  # * charset: charset(codeset) (no standard)
110
153
  # * script: an initial-uppercase ISO 15924 script code.
111
- # * sort_order: (Win32 only?)
154
+ # * variant: variant value in CLDR or sort order in Win32.
112
155
  # * modifier: (no standard)
113
156
  def to_a
114
- [@language, @country, @charset, @script, @sort_order, @modifier]
157
+ [@language, @country, @charset, @script, @variant, @modifier]
115
158
  end
116
159
 
117
- # Compare self and another object
118
- # * other: another object.
119
- # * Returns: true if the 2 objects are same object.
120
- def ==(other)
160
+ def ==(other) #:nodoc:
121
161
  other != nil and
122
162
  @language == other.language and @country == other.country and
123
163
  @charset == other.charset and @script == other.script and
124
- @sort_order == other.sort_order and @modifier == other.modifier and
164
+ @variant == other.variant and @modifier == other.modifier and
125
165
  @charset == other.charset
126
166
  end
127
167
 
168
+ def eql?(other) #:nodoc:
169
+ self.==(other)
170
+ end
171
+
172
+ def hash #:nodoc:
173
+ "#{self.class}:#{to_general}.#{@charset}@#{modifier}".hash
174
+ end
128
175
  alias :to_s :to_posix
129
176
  alias :to_str :to_posix
130
177
  end