gettext 1.8.0 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ChangeLog +120 -0
- data/NEWS +16 -0
- data/README +27 -19
- data/data/locale/ca/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/ca/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/cs/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/cs/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/de/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/de/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/el/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/el/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/eo/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/eo/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/es/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/es/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/et/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/fr/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/fr/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/it/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/it/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/ja/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/ja/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/ko/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/ko/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/nl/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/nl/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/pt_BR/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/pt_BR/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/ru/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/ru/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/sv/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/zh/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/zh/LC_MESSAGES/rgettext.mo +0 -0
- data/data/locale/zh_TW/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/zh_TW/LC_MESSAGES/rgettext.mo +0 -0
- data/lib/gettext.rb +13 -10
- data/lib/gettext/active_record.rb +130 -113
- data/lib/gettext/erb.rb +2 -2
- data/lib/gettext/locale.rb +11 -5
- data/lib/gettext/locale_cgi.rb +3 -3
- data/lib/gettext/locale_posix.rb +2 -2
- data/lib/gettext/locale_win32.rb +2 -1
- data/lib/gettext/parser/active_record.rb +24 -14
- data/lib/gettext/parser/ruby.rb +4 -63
- data/lib/gettext/poparser.rb +3 -3
- data/lib/gettext/rails.rb +23 -20
- data/lib/gettext/rgettext.rb +6 -6
- data/lib/gettext/utils.rb +12 -6
- data/lib/gettext/version.rb +2 -2
- data/po/ca/rails.po +121 -0
- data/po/ca/rgettext.po +130 -0
- data/po/cs/rails.po +30 -26
- data/po/cs/rgettext.po +44 -36
- data/po/de/rails.po +28 -24
- data/po/de/rgettext.po +43 -35
- data/po/el/rails.po +38 -34
- data/po/el/rgettext.po +54 -46
- data/po/eo/rails.po +121 -0
- data/po/eo/rgettext.po +127 -0
- data/po/es/rails.po +28 -24
- data/po/es/rgettext.po +45 -37
- data/po/et/rails.po +28 -24
- data/po/fr/rails.po +39 -33
- data/po/fr/rgettext.po +43 -35
- data/po/it/rails.po +28 -24
- data/po/it/rgettext.po +43 -35
- data/po/ja/rails.po +30 -26
- data/po/ja/rgettext.po +44 -36
- data/po/ko/rails.po +36 -32
- data/po/ko/rgettext.po +43 -35
- data/po/nl/rails.po +32 -28
- data/po/nl/rgettext.po +46 -38
- data/po/pt_BR/rails.po +36 -31
- data/po/pt_BR/rgettext.po +45 -37
- data/po/rails.pot +28 -24
- data/po/rgettext.pot +39 -31
- data/po/ru/rails.po +36 -30
- data/po/ru/rgettext.po +50 -41
- data/po/sv/rgettext.po +40 -32
- data/po/zh/rails.po +29 -24
- data/po/zh/rgettext.po +46 -36
- data/po/zh_TW/rails.po +29 -24
- data/po/zh_TW/rgettext.po +45 -36
- data/samples/cgi/locale/ca/LC_MESSAGES/helloerb1.mo +0 -0
- data/samples/cgi/locale/ca/LC_MESSAGES/helloerb2.mo +0 -0
- data/samples/cgi/locale/ca/LC_MESSAGES/hellolib.mo +0 -0
- data/samples/cgi/locale/ca/LC_MESSAGES/main.mo +0 -0
- data/samples/cgi/locale/eo/LC_MESSAGES/helloerb1.mo +0 -0
- data/samples/cgi/locale/eo/LC_MESSAGES/helloerb2.mo +0 -0
- data/samples/cgi/locale/eo/LC_MESSAGES/hellolib.mo +0 -0
- data/samples/cgi/locale/eo/LC_MESSAGES/main.mo +0 -0
- data/samples/cgi/po/ca/helloerb1.po +59 -0
- data/samples/cgi/po/ca/helloerb2.po +51 -0
- data/samples/cgi/po/ca/hellolib.po +23 -0
- data/samples/cgi/po/ca/main.po +83 -0
- data/samples/cgi/po/eo/helloerb1.po +60 -0
- data/samples/cgi/po/eo/helloerb2.po +52 -0
- data/samples/cgi/po/eo/hellolib.po +24 -0
- data/samples/cgi/po/eo/main.po +84 -0
- data/samples/locale/ca/LC_MESSAGES/hello.mo +0 -0
- data/samples/locale/ca/LC_MESSAGES/hello2.mo +0 -0
- data/samples/locale/ca/LC_MESSAGES/hello_noop.mo +0 -0
- data/samples/locale/ca/LC_MESSAGES/hello_plural.mo +0 -0
- data/samples/locale/ca/LC_MESSAGES/helloglade2.mo +0 -0
- data/samples/locale/ca/LC_MESSAGES/hellogtk.mo +0 -0
- data/samples/locale/ca/LC_MESSAGES/hellotk.mo +0 -0
- data/samples/locale/eo/LC_MESSAGES/hello.mo +0 -0
- data/samples/locale/eo/LC_MESSAGES/hello2.mo +0 -0
- data/samples/locale/eo/LC_MESSAGES/hello_noop.mo +0 -0
- data/samples/locale/eo/LC_MESSAGES/hello_plural.mo +0 -0
- data/samples/locale/eo/LC_MESSAGES/helloglade2.mo +0 -0
- data/samples/locale/eo/LC_MESSAGES/hellogtk.mo +0 -0
- data/samples/locale/eo/LC_MESSAGES/hellotk.mo +0 -0
- data/samples/po/ca/hello.po +23 -0
- data/samples/po/ca/hello2.po +31 -0
- data/samples/po/ca/hello_noop.po +27 -0
- data/samples/po/ca/hello_plural.po +25 -0
- data/samples/po/ca/helloglade2.po +31 -0
- data/samples/po/ca/hellogtk.po +23 -0
- data/samples/po/ca/hellotk.po +23 -0
- data/samples/po/eo/hello.po +23 -0
- data/samples/po/eo/hello2.po +31 -0
- data/samples/po/eo/hello_noop.po +27 -0
- data/samples/po/eo/hello_plural.po +26 -0
- data/samples/po/eo/helloglade2.po +32 -0
- data/samples/po/eo/hellogtk.po +23 -0
- data/samples/po/eo/hellotk.po +24 -0
- data/samples/rails/app/views/blog/list.rhtml +0 -1
- data/samples/rails/config/environment.rb +2 -0
- data/samples/rails/db/schema.rb +0 -79
- data/samples/rails/lib/tasks/gettext.rake +2 -1
- data/samples/rails/locale/ca/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/cs/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/de/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/el/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/en/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/eo/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/es/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/fr/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/it/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/ja/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/ko/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/nl/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/pt_BR/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/ru/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/zh/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/zh_TW/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/po/blog.pot +106 -106
- data/samples/rails/po/ca/blog.po +105 -0
- data/samples/rails/po/cs/blog.po +107 -110
- data/samples/rails/po/de/blog.po +107 -107
- data/samples/rails/po/el/blog.po +105 -105
- data/samples/rails/po/en/blog.po +107 -107
- data/samples/rails/po/eo/blog.po +106 -0
- data/samples/rails/po/es/blog.po +105 -105
- data/samples/rails/po/fr/blog.po +105 -105
- data/samples/rails/po/it/blog.po +105 -105
- data/samples/rails/po/ja/blog.po +105 -105
- data/samples/rails/po/ko/blog.po +105 -105
- data/samples/rails/po/nl/blog.po +105 -105
- data/samples/rails/po/pt_BR/blog.po +105 -105
- data/samples/rails/po/ru/blog.po +105 -105
- data/samples/rails/po/zh/blog.po +105 -105
- data/samples/rails/po/zh_TW/blog.po +107 -107
- data/samples/rails/vendor/plugins/gettext/locale/ca/LC_MESSAGES/gettext_plugin.mo +0 -0
- data/samples/rails/vendor/plugins/gettext/po/ca/gettext_plugin.po +27 -0
- data/test/README +6 -0
- data/test/Rakefile +1 -1
- data/test/fixtures/book.rb +3 -0
- data/test/fixtures/user.rb +3 -0
- data/test/gettext_test_active_record.rb +347 -67
- data/test/gettext_test_cgi.rb +27 -2
- data/test/gettext_test_parser.rb +102 -4
- data/test/gettext_test_rails.rb +6 -1
- data/test/locale/ja/LC_MESSAGES/active_record.mo +0 -0
- data/test/po/ja/active_record.po +17 -17
- data/test/test.sh +1 -0
- data/test/test_rubyparser.rb +6 -4
- metadata +889 -795
- data/pkg/ruby-gettext-package-1.8.0/ext/gettext/extconf.rb +0 -20
data/lib/gettext/erb.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: erb.rb,v 1.
|
|
9
|
+
$Id: erb.rb,v 1.4 2006/12/06 16:39:58 mutoh Exp $
|
|
10
10
|
=end
|
|
11
11
|
|
|
12
12
|
require 'erb'
|
|
@@ -34,7 +34,7 @@ module GetText
|
|
|
34
34
|
# This module is an example for template engines such as ERB.
|
|
35
35
|
# You can implement another implementation easily to read gettext/erb.rb.
|
|
36
36
|
module ErbContainer
|
|
37
|
-
include
|
|
37
|
+
include GetText
|
|
38
38
|
|
|
39
39
|
# Evaluates ERB source(String) in the instance and returns the result HTML.
|
|
40
40
|
#
|
data/lib/gettext/locale.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: locale.rb,v 1.
|
|
9
|
+
$Id: locale.rb,v 1.13 2006/12/03 16:26:59 mutoh Exp $
|
|
10
10
|
=end
|
|
11
11
|
|
|
12
12
|
require 'gettext/locale_object'
|
|
@@ -56,14 +56,20 @@ module Locale
|
|
|
56
56
|
@@current = nil
|
|
57
57
|
|
|
58
58
|
module_function
|
|
59
|
-
# Sets the default locale (Locale::Object).
|
|
59
|
+
# Sets the default locale (Locale::Object or String(such as ja_JP.eucjP)).
|
|
60
60
|
#
|
|
61
61
|
# * locale: the default locale
|
|
62
62
|
# * Returns: self.
|
|
63
63
|
def set_default(locale)
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
if locale
|
|
65
|
+
if locale.kind_of? Locale::Object
|
|
66
|
+
@@default = locale
|
|
67
|
+
else
|
|
68
|
+
@@default = Locale::Object.new(locale)
|
|
69
|
+
end
|
|
70
|
+
@@default.charset ||= @@locale_system_module.get_charset(@@default)
|
|
71
|
+
else
|
|
72
|
+
@@default = nil
|
|
67
73
|
end
|
|
68
74
|
self
|
|
69
75
|
end
|
data/lib/gettext/locale_cgi.rb
CHANGED
|
@@ -6,13 +6,13 @@
|
|
|
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.
|
|
9
|
+
$Id: locale_cgi.rb,v 1.7 2006/12/14 16:35:57 mutoh Exp $
|
|
10
10
|
=end
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
module Locale
|
|
14
|
-
# Locale::System module for
|
|
15
|
-
# This is low-level class. Application shouldn't use this directly.
|
|
14
|
+
# Locale::System module for CGI.
|
|
15
|
+
# This is a low-level class. Application shouldn't use this directly.
|
|
16
16
|
module SystemCGI
|
|
17
17
|
@@default_locale = Locale::Object.new("en", nil, "UTF-8")
|
|
18
18
|
@@cgi = nil
|
data/lib/gettext/locale_posix.rb
CHANGED
|
@@ -6,13 +6,13 @@
|
|
|
6
6
|
You may redistribute it and/or modify it under the same
|
|
7
7
|
license terms as Ruby.
|
|
8
8
|
|
|
9
|
-
$Id: locale_posix.rb,v 1.
|
|
9
|
+
$Id: locale_posix.rb,v 1.5 2006/12/14 16:35:57 mutoh Exp $
|
|
10
10
|
=end
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
module Locale
|
|
14
14
|
# Locale::SystemPosix module for Posix OS (Unix)
|
|
15
|
-
# This is low-level class. Application shouldn't use this directly.
|
|
15
|
+
# This is a low-level class. Application shouldn't use this directly.
|
|
16
16
|
module SystemPosix
|
|
17
17
|
extend Locale::System
|
|
18
18
|
module_function
|
data/lib/gettext/locale_win32.rb
CHANGED
|
@@ -6,13 +6,14 @@
|
|
|
6
6
|
You may redistribute it and/or modify it under the same
|
|
7
7
|
license terms as Ruby.
|
|
8
8
|
|
|
9
|
-
$Id: locale_win32.rb,v 1.
|
|
9
|
+
$Id: locale_win32.rb,v 1.15 2006/12/14 16:35:57 mutoh Exp $
|
|
10
10
|
=end
|
|
11
11
|
|
|
12
12
|
require 'gettext/locale_table_win32'
|
|
13
13
|
|
|
14
14
|
module Locale
|
|
15
15
|
# Locale::SystemWin32 module for win32.
|
|
16
|
+
# This is a low-level class. Application shouldn't use this directly.
|
|
16
17
|
module SystemWin32
|
|
17
18
|
extend Locale::System
|
|
18
19
|
|
|
@@ -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: active_record.rb,v 1.
|
|
10
|
+
$Id: active_record.rb,v 1.5 2007/01/21 15:16:06 mutoh Exp $
|
|
11
11
|
=end
|
|
12
12
|
|
|
13
13
|
require 'gettext'
|
|
@@ -72,16 +72,17 @@ module GetText
|
|
|
72
72
|
end
|
|
73
73
|
|
|
74
74
|
def parse(file, targets = []) # :nodoc:
|
|
75
|
-
|
|
75
|
+
GetText.locale = "en"
|
|
76
|
+
old_constants = Object.constants
|
|
76
77
|
begin
|
|
77
|
-
eval(open(file).read)
|
|
78
|
+
eval(open(file).read, TOPLEVEL_BINDING)
|
|
78
79
|
rescue
|
|
79
80
|
$stderr.puts _("Ignored '%{file}'. Solve dependencies first.") % {:file => file}
|
|
80
81
|
$stderr.puts $!
|
|
81
82
|
end
|
|
82
|
-
loaded_constants = constants - old_constants
|
|
83
|
+
loaded_constants = Object.constants - old_constants
|
|
83
84
|
loaded_constants.each do |classname|
|
|
84
|
-
klass = eval(classname)
|
|
85
|
+
klass = eval(classname, TOPLEVEL_BINDING)
|
|
85
86
|
if klass.is_a?(Class) && klass < ActiveRecord::Base
|
|
86
87
|
unless klass.untranslate_all?
|
|
87
88
|
add_target(targets, file, ::Inflector.singularize(klass.table_name.gsub(/_/, " ")))
|
|
@@ -114,9 +115,10 @@ module GetText
|
|
|
114
115
|
end
|
|
115
116
|
|
|
116
117
|
def add_target(targets, file, msgid) # :nodoc:
|
|
118
|
+
file_lineno = "#{file}:-"
|
|
117
119
|
key_existed = targets.assoc(msgid)
|
|
118
|
-
if key_existed
|
|
119
|
-
targets[targets.index(key_existed)] = key_existed <<
|
|
120
|
+
if key_existed and ! targets[targets.index(key_existed)].include?(file_lineno)
|
|
121
|
+
targets[targets.index(key_existed)] = key_existed << file_lineno
|
|
120
122
|
else
|
|
121
123
|
targets << [msgid, "#{file}:-"]
|
|
122
124
|
end
|
|
@@ -132,12 +134,24 @@ module GetText
|
|
|
132
134
|
unless @@db_loaded
|
|
133
135
|
begin
|
|
134
136
|
require 'rubygems'
|
|
135
|
-
require_gem 'activerecord'
|
|
136
137
|
rescue LoadError
|
|
137
138
|
$stderr.puts _("rubygems are not found.") if $DEBUG
|
|
138
139
|
end
|
|
139
|
-
|
|
140
|
-
|
|
140
|
+
begin
|
|
141
|
+
ENV["RAILS_ENV"] = @config[:db_mode]
|
|
142
|
+
require 'config/boot.rb'
|
|
143
|
+
require 'config/environment.rb'
|
|
144
|
+
require 'app/controllers/application.rb'
|
|
145
|
+
rescue LoadError
|
|
146
|
+
require_rails 'rubygems'
|
|
147
|
+
if Kernel.respond_to? :gem
|
|
148
|
+
gem 'activerecord'
|
|
149
|
+
else
|
|
150
|
+
require_gem 'activerecord'
|
|
151
|
+
end
|
|
152
|
+
require_rails 'active_record'
|
|
153
|
+
require_rails 'gettext/active_record'
|
|
154
|
+
end
|
|
141
155
|
if @config[:adapter]
|
|
142
156
|
ActiveRecord::Base.establish_connection(@config)
|
|
143
157
|
else
|
|
@@ -146,10 +160,6 @@ module GetText
|
|
|
146
160
|
rescue
|
|
147
161
|
return false
|
|
148
162
|
end
|
|
149
|
-
ENV["RAILS_ENV"] = @config[:db_mode]
|
|
150
|
-
require_rails 'config/boot.rb'
|
|
151
|
-
require_rails 'config/environment.rb'
|
|
152
|
-
require_rails 'app/controllers/application.rb'
|
|
153
163
|
end
|
|
154
164
|
end
|
|
155
165
|
@@db_loaded = true
|
data/lib/gettext/parser/ruby.rb
CHANGED
|
@@ -9,73 +9,13 @@
|
|
|
9
9
|
You may redistribute it and/or modify it under the same
|
|
10
10
|
license terms as Ruby.
|
|
11
11
|
|
|
12
|
-
$Id: ruby.rb,v 1.
|
|
12
|
+
$Id: ruby.rb,v 1.9 2007/01/13 18:34:08 mutoh Exp $
|
|
13
13
|
=end
|
|
14
14
|
|
|
15
15
|
require 'irb/ruby-lex.rb'
|
|
16
16
|
require 'stringio'
|
|
17
17
|
|
|
18
18
|
class RubyLexX < RubyLex # :nodoc: all
|
|
19
|
-
|
|
20
|
-
def initialize
|
|
21
|
-
super
|
|
22
|
-
@prompt = nil
|
|
23
|
-
@here_header = nil
|
|
24
|
-
@lex_state = nil
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def read_escape
|
|
28
|
-
case ch = getc
|
|
29
|
-
when "\n", "\r", "\f"
|
|
30
|
-
when "\\", "n", "t", "r", "f", "v", "a", "e", "b" #"
|
|
31
|
-
return "\\".concat(ch)
|
|
32
|
-
when /[0-7]/
|
|
33
|
-
ungetc ch
|
|
34
|
-
3.times do
|
|
35
|
-
case ch = getc
|
|
36
|
-
when /[0-7]/
|
|
37
|
-
when nil
|
|
38
|
-
break
|
|
39
|
-
else
|
|
40
|
-
ungetc
|
|
41
|
-
break
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
when "x"
|
|
46
|
-
2.times do
|
|
47
|
-
case ch = getc
|
|
48
|
-
when /[0-9a-fA-F]/
|
|
49
|
-
when nil
|
|
50
|
-
break
|
|
51
|
-
else
|
|
52
|
-
ungetc
|
|
53
|
-
break
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
when "M"
|
|
58
|
-
if (ch = getc) != '-'
|
|
59
|
-
ungetc
|
|
60
|
-
else
|
|
61
|
-
if (ch = getc) == "\\" #"
|
|
62
|
-
read_escape
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
when "C", "c", "^"
|
|
67
|
-
if ch == "C" and (ch = getc) != "-"
|
|
68
|
-
ungetc
|
|
69
|
-
elsif (ch = getc) == "\\" #"
|
|
70
|
-
read_escape
|
|
71
|
-
end
|
|
72
|
-
when '#'
|
|
73
|
-
return ch
|
|
74
|
-
else
|
|
75
|
-
# other characters
|
|
76
|
-
end
|
|
77
|
-
end
|
|
78
|
-
|
|
79
19
|
# Parser#parse resemlbes RubyLex#lex
|
|
80
20
|
def parse
|
|
81
21
|
until ( (tk = token).kind_of?(RubyToken::TkEND_OF_SCRIPT) && !@continue or tk.nil? )
|
|
@@ -114,7 +54,6 @@ class RubyLexX < RubyLex # :nodoc: all
|
|
|
114
54
|
|
|
115
55
|
yield tk
|
|
116
56
|
end
|
|
117
|
-
|
|
118
57
|
return nil
|
|
119
58
|
end
|
|
120
59
|
|
|
@@ -185,7 +124,9 @@ module GetText
|
|
|
185
124
|
targets
|
|
186
125
|
end
|
|
187
126
|
rescue
|
|
188
|
-
$stderr.
|
|
127
|
+
$stderr.print "\n\nError: #{$!.inspect} "
|
|
128
|
+
$stderr.print " in #{file_name}:#{tk.line_no}\n\t #{lines[tk.line_no - 1]}" if tk
|
|
129
|
+
$stderr.print "\n"
|
|
189
130
|
exit
|
|
190
131
|
end
|
|
191
132
|
targets
|
data/lib/gettext/poparser.rb
CHANGED
|
@@ -20,7 +20,7 @@ module GetText
|
|
|
20
20
|
|
|
21
21
|
class PoParser < Racc::Parser
|
|
22
22
|
|
|
23
|
-
module_eval <<'..end src/poparser.ry modeval..
|
|
23
|
+
module_eval <<'..end src/poparser.ry modeval..idf3e4511031', 'src/poparser.ry', 90
|
|
24
24
|
include GetText
|
|
25
25
|
GetText.bindtextdomain("rgettext")
|
|
26
26
|
|
|
@@ -56,7 +56,7 @@ module_eval <<'..end src/poparser.ry modeval..id22a75cc2c8', 'src/poparser.ry',
|
|
|
56
56
|
@q.push [:PLURAL_NUM, $1]
|
|
57
57
|
str = $'
|
|
58
58
|
when /\A\#~(.*)/
|
|
59
|
-
$stderr.print _("Warning: obsolete msgid
|
|
59
|
+
$stderr.print _("Warning: obsolete msgid is existed.\n")
|
|
60
60
|
$stderr.print " #{$&}\n"
|
|
61
61
|
@q.push [:COMMENT, $&]
|
|
62
62
|
str = $'
|
|
@@ -103,7 +103,7 @@ module_eval <<'..end src/poparser.ry modeval..id22a75cc2c8', 'src/poparser.ry',
|
|
|
103
103
|
@comments << comment
|
|
104
104
|
end
|
|
105
105
|
|
|
106
|
-
..end src/poparser.ry modeval..
|
|
106
|
+
..end src/poparser.ry modeval..idf3e4511031
|
|
107
107
|
|
|
108
108
|
##### racc 1.4.4 generates ###
|
|
109
109
|
|
data/lib/gettext/rails.rb
CHANGED
|
@@ -6,11 +6,11 @@
|
|
|
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.
|
|
9
|
+
$Id: rails.rb,v 1.55 2007/01/21 15:16:06 mutoh Exp $
|
|
10
10
|
=end
|
|
11
11
|
|
|
12
12
|
require 'gettext/cgi'
|
|
13
|
-
require '
|
|
13
|
+
require 'action_controller'
|
|
14
14
|
|
|
15
15
|
module GetText
|
|
16
16
|
# GetText::Rails supports Ruby on Rails.
|
|
@@ -70,7 +70,6 @@ module GetText
|
|
|
70
70
|
end
|
|
71
71
|
end
|
|
72
72
|
|
|
73
|
-
|
|
74
73
|
module ActionController #:nodoc:
|
|
75
74
|
class Base
|
|
76
75
|
helper GetText::Rails
|
|
@@ -78,23 +77,21 @@ module ActionController #:nodoc:
|
|
|
78
77
|
|
|
79
78
|
@@gettext_domainnames = []
|
|
80
79
|
@@gettext_content_type = nil
|
|
81
|
-
|
|
80
|
+
|
|
82
81
|
prepend_before_filter :init_gettext
|
|
83
82
|
after_filter :init_content_type
|
|
84
|
-
|
|
85
|
-
|
|
83
|
+
|
|
86
84
|
def init_gettext_main(cgi) #:nodoc:
|
|
87
|
-
cgi.params["lang"] = [
|
|
85
|
+
cgi.params["lang"] = [params["lang"]] if params["lang"]
|
|
88
86
|
set_cgi(cgi)
|
|
89
87
|
set_locale_all(nil)
|
|
90
88
|
end
|
|
91
89
|
|
|
92
|
-
REGEXP_GETTEXT_CONTENT_TYPE = /javascript/ #:nodoc:
|
|
93
90
|
def init_content_type #:nodoc:
|
|
94
|
-
if
|
|
95
|
-
|
|
96
|
-
elsif !
|
|
97
|
-
|
|
91
|
+
if headers["Content-Type"] and /javascript/ =~ headers["Content-Type"]
|
|
92
|
+
headers["Content-Type"] = "text/javascript; charset=#{GetText.output_charset}"
|
|
93
|
+
elsif ! headers["Content-Type"]
|
|
94
|
+
headers["Content-Type"] = "#{@@gettext_content_type}; charset=#{GetText.output_charset}"
|
|
98
95
|
end
|
|
99
96
|
end
|
|
100
97
|
|
|
@@ -111,7 +108,7 @@ module ActionController #:nodoc:
|
|
|
111
108
|
def init_gettext # :nodoc:
|
|
112
109
|
cgi = nil
|
|
113
110
|
if defined? request.cgi
|
|
114
|
-
|
|
111
|
+
cgi = request.cgi
|
|
115
112
|
end
|
|
116
113
|
call_methods_around_init_gettext(@@before_init_gettext)
|
|
117
114
|
init_gettext_main(cgi) if @@gettext_domainnames.size > 0
|
|
@@ -170,7 +167,7 @@ module ActionController #:nodoc:
|
|
|
170
167
|
# * :content_type - the content type. Default is "text/html"
|
|
171
168
|
# * :locale_path - the path to locale directory. Default is {RAILS_ROOT}/locale or {plugin root directory}/locale.
|
|
172
169
|
#
|
|
173
|
-
# locale is searched the order by
|
|
170
|
+
# locale is searched the order by params["lang"] > "lang" value of QUERY_STRING >
|
|
174
171
|
# "lang" value of Cookie > HTTP_ACCEPT_LANGUAGE value > Default locale(en).
|
|
175
172
|
# And the charset is set order by "the argument of bindtextdomain" > HTTP_ACCEPT_CHARSET > Default charset(UTF-8).
|
|
176
173
|
#
|
|
@@ -192,14 +189,17 @@ module ActionController #:nodoc:
|
|
|
192
189
|
if options.kind_of? String
|
|
193
190
|
# For backward compatibility
|
|
194
191
|
opt.merge!(:charset => options, :content_type => content_type)
|
|
192
|
+
else
|
|
193
|
+
opt.merge!(options)
|
|
195
194
|
end
|
|
196
195
|
GetText.output_charset = opt[:charset]
|
|
197
196
|
@@gettext_content_type = opt[:content_type]
|
|
198
197
|
locale_path = opt[:locale_path]
|
|
199
198
|
unless locale_path
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
199
|
+
cal = caller[0]
|
|
200
|
+
if cal =~ /app.controllers/
|
|
201
|
+
locale_path = File.join(cal.split(/app.controllers/)[0] + "locale")
|
|
202
|
+
else
|
|
203
203
|
locale_path = File.join(RAILS_ROOT, "locale")
|
|
204
204
|
end
|
|
205
205
|
end
|
|
@@ -239,7 +239,10 @@ module ActionController #:nodoc:
|
|
|
239
239
|
class TestRequest < AbstractRequest #:nodoc:
|
|
240
240
|
@cgi = nil
|
|
241
241
|
def cgi
|
|
242
|
-
|
|
242
|
+
unless @cgi
|
|
243
|
+
ENV['REQUEST_URI'] ||= "http://localhost:3000/"
|
|
244
|
+
@cgi = CGI.new
|
|
245
|
+
end
|
|
243
246
|
@cgi
|
|
244
247
|
end
|
|
245
248
|
end
|
|
@@ -390,7 +393,7 @@ if defined? ActionMailer
|
|
|
390
393
|
include GetText::Rails
|
|
391
394
|
extend GetText::Rails
|
|
392
395
|
|
|
393
|
-
alias :
|
|
396
|
+
alias :create_without_gettext! :create! #:nodoc:
|
|
394
397
|
|
|
395
398
|
def base64(text, charset="iso-2022-jp", convert=true)
|
|
396
399
|
if convert
|
|
@@ -403,7 +406,7 @@ if defined? ActionMailer
|
|
|
403
406
|
end
|
|
404
407
|
|
|
405
408
|
def create!(*arg) #:nodoc:
|
|
406
|
-
|
|
409
|
+
create_without_gettext!(*arg)
|
|
407
410
|
if Locale.get.language == "ja"
|
|
408
411
|
require 'nkf'
|
|
409
412
|
@mail.subject = base64(@mail.subject)
|
data/lib/gettext/rgettext.rb
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
=begin
|
|
3
3
|
rgettext.rb - Generate a .pot file.
|
|
4
4
|
|
|
5
|
-
Copyright (C) 2003-
|
|
5
|
+
Copyright (C) 2003-2006 Masao Mutoh
|
|
6
6
|
Copyright (C) 2001,2002 Yasushi Shoji, Masao Mutoh
|
|
7
7
|
|
|
8
|
-
Yasushi Shoji <yashi
|
|
9
|
-
Masao Mutoh <mutoh
|
|
8
|
+
Yasushi Shoji <yashi at atmark-techno.com>
|
|
9
|
+
Masao Mutoh <mutoh at highway.ne.jp>
|
|
10
10
|
|
|
11
11
|
You may redistribute it and/or modify it under the same
|
|
12
12
|
license terms as Ruby.
|
|
@@ -25,7 +25,7 @@ module GetText
|
|
|
25
25
|
|
|
26
26
|
# constant values
|
|
27
27
|
VERSION = GetText::VERSION
|
|
28
|
-
DATE = %w($Date: 2006/
|
|
28
|
+
DATE = %w($Date: 2006/12/14 16:35:57 $)[1]
|
|
29
29
|
MAX_LINE_LEN = 70
|
|
30
30
|
|
|
31
31
|
@ex_parsers = []
|
|
@@ -156,12 +156,12 @@ msgstr ""
|
|
|
156
156
|
unless FileTest.exist? out
|
|
157
157
|
output = File.new(File.expand_path(out), "w+")
|
|
158
158
|
else
|
|
159
|
-
$stderr.puts(_("File '%s'
|
|
159
|
+
$stderr.puts(_("File '%s' already exists.") % out)
|
|
160
160
|
exit 1
|
|
161
161
|
end
|
|
162
162
|
end
|
|
163
163
|
|
|
164
|
-
opts.on("-r", "--require=
|
|
164
|
+
opts.on("-r", "--require=library", _("require the library before executing rgettext")) do |out|
|
|
165
165
|
require out
|
|
166
166
|
end
|
|
167
167
|
|