gettext 1.1.1-mswin32 → 1.2.0-mswin32
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 +128 -0
- data/NEWS +10 -0
- data/README +21 -23
- data/Rakefile +40 -21
- data/bin/rgettext +1 -1
- data/bin/rmsgfmt +1 -1
- data/bin/rmsgmerge +1 -1
- 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/es/LC_MESSAGES/rails.mo +0 -0
- data/data/locale/es/LC_MESSAGES/rgettext.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/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/sv/LC_MESSAGES/rgettext.mo +0 -0
- data/ext/gettext/{gettext/Makefile → Makefile} +3 -3
- data/ext/gettext/extconf.rb +20 -0
- data/ext/gettext/locale_system-i386-mswin32.def +2 -0
- data/ext/gettext/{gettext/_locale.c → locale_system.c} +15 -19
- data/ext/gettext/locale_system.exp +0 -0
- data/ext/gettext/locale_system.lib +0 -0
- data/ext/gettext/locale_system.obj +0 -0
- data/ext/gettext/{gettext/_locale.pdb → locale_system.pdb} +0 -0
- data/ext/gettext/locale_system.so +0 -0
- data/ext/gettext/mkmf.log +10 -0
- data/ext/gettext/{gettext/vc70.pdb → vc70.pdb} +0 -0
- data/lib/gettext.rb +186 -38
- data/lib/gettext/cgi.rb +35 -69
- data/lib/gettext/container.rb +14 -5
- data/lib/gettext/erb.rb +30 -2
- data/lib/gettext/iconv.rb +19 -4
- data/lib/gettext/locale.rb +188 -39
- data/lib/gettext/locale_cgi.rb +102 -0
- data/lib/gettext/locale_object.rb +131 -0
- data/lib/gettext/locale_posix.rb +50 -0
- data/lib/gettext/locale_table_win32.rb +224 -182
- data/lib/gettext/locale_win32.rb +59 -35
- data/lib/gettext/mo.rb +2 -2
- data/lib/gettext/parser/activerecord.rb +19 -5
- data/lib/gettext/parser/erb.rb +6 -3
- data/lib/gettext/parser/glade.rb +5 -5
- data/lib/gettext/parser/ruby.rb +6 -6
- data/lib/gettext/poparser.rb +298 -297
- data/lib/gettext/rails.rb +122 -44
- data/lib/gettext/rgettext.rb +21 -8
- data/lib/gettext/rmsgfmt.rb +16 -8
- data/lib/gettext/rmsgmerge.rb +172 -50
- data/lib/gettext/string.rb +25 -3
- data/lib/gettext/textdomain.rb +89 -90
- data/lib/gettext/utils.rb +63 -3
- data/lib/gettext/version.rb +2 -2
- data/lib/locale_system.so +0 -0
- data/po/cs/rails.po +28 -28
- data/po/cs/rgettext.po +14 -14
- data/po/de/rails.po +29 -26
- data/po/de/rgettext.po +24 -17
- data/po/el/rails.po +26 -26
- data/po/el/rgettext.po +18 -15
- data/po/es/rails.po +26 -26
- data/po/es/rgettext.po +16 -16
- data/po/fr/rails.po +27 -27
- data/po/fr/rgettext.po +14 -14
- data/po/it/rgettext.po +14 -14
- data/po/ja/rails.po +24 -24
- data/po/ja/rgettext.po +14 -14
- data/po/ko/rails.po +24 -24
- data/po/ko/rgettext.po +17 -18
- data/po/nl/rails.po +27 -27
- data/po/nl/rgettext.po +18 -18
- data/po/pt_BR/rails.po +26 -26
- data/po/pt_BR/rgettext.po +14 -14
- data/po/rails.pot +26 -26
- data/po/rgettext.pot +14 -14
- data/po/sv/rgettext.po +14 -14
- data/post-setup.rb +8 -3
- data/pre-setup.rb +14 -1
- data/samples/cgi/http.rb +2 -1
- data/samples/makemo.rb +1 -1
- data/samples/rails/app/models/article.rb +15 -1
- data/samples/rails/config/database.yml +1 -1
- data/samples/rails/locale/cs/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/cs/LC_MESSAGES/gettext_plugin.mo +0 -0
- data/samples/rails/locale/de/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/de/LC_MESSAGES/gettext_plugin.mo +0 -0
- data/samples/rails/locale/el/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/el/LC_MESSAGES/gettext_plugin.mo +0 -0
- data/samples/rails/locale/en/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/es/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/es/LC_MESSAGES/gettext_plugin.mo +0 -0
- data/samples/rails/locale/fr/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/fr/LC_MESSAGES/gettext_plugin.mo +0 -0
- data/samples/rails/locale/ja/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/ja/LC_MESSAGES/gettext_plugin.mo +0 -0
- data/samples/rails/locale/ko/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/ko/LC_MESSAGES/gettext_plugin.mo +0 -0
- data/samples/rails/locale/nl/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/nl/LC_MESSAGES/gettext_plugin.mo +0 -0
- data/samples/rails/locale/pt_BR/LC_MESSAGES/blog.mo +0 -0
- data/samples/rails/locale/pt_BR/LC_MESSAGES/gettext_plugin.mo +0 -0
- data/samples/rails/po/blog.pot +1 -1
- data/samples/rails/po/cs/blog.po +1 -2
- data/samples/rails/po/cs/gettext_plugin.po +1 -1
- data/samples/rails/po/de/blog.po +1 -2
- data/samples/rails/po/de/gettext_plugin.po +1 -1
- data/samples/rails/po/el/blog.po +1 -1
- data/samples/rails/po/el/gettext_plugin.po +1 -1
- data/samples/rails/po/en/blog.po +1 -1
- data/samples/rails/po/es/blog.po +1 -2
- data/samples/rails/po/es/gettext_plugin.po +1 -1
- data/samples/rails/po/fr/blog.po +1 -1
- data/samples/rails/po/fr/gettext_plugin.po +1 -1
- data/samples/rails/po/gettext_plugin.pot +1 -1
- data/samples/rails/po/ja/blog.po +2 -1
- data/samples/rails/po/ja/gettext_plugin.po +1 -1
- data/samples/rails/po/ko/blog.po +1 -2
- data/samples/rails/po/ko/gettext_plugin.po +1 -1
- data/samples/rails/po/nl/blog.po +1 -3
- data/samples/rails/po/nl/gettext_plugin.po +1 -1
- data/samples/rails/po/pt_BR/blog.po +1 -1
- data/samples/rails/po/pt_BR/gettext_plugin.po +1 -1
- data/setup.rb +799 -574
- data/src/poparser.ry +6 -5
- data/test/gettext_runner.rb +3 -1
- data/test/gettext_test.rb +40 -24
- data/test/gettext_test_cgi.rb +60 -6
- data/test/gettext_test_locale.rb +136 -0
- data/test/gettext_test_parser.rb +12 -12
- data/test/locale/la/LC_MESSAGES/plural_error.mo +0 -0
- data/test/po/la/plural_error.po +21 -0
- data/test/test.bat +2 -0
- data/test/test.sh +2 -4
- data/test/test_rubyparser_n_.rb +64 -0
- metadata +24 -21
- data/ext/gettext/gettext/MANIFEST +0 -3
- data/ext/gettext/gettext/_locale-i386-mswin32.def +0 -2
- data/ext/gettext/gettext/_locale.exp +0 -0
- data/ext/gettext/gettext/_locale.lib +0 -0
- data/ext/gettext/gettext/_locale.obj +0 -0
- data/ext/gettext/gettext/_locale.so +0 -0
- data/ext/gettext/gettext/extconf.rb +0 -20
- data/ext/gettext/gettext/mkmf.log +0 -16
- data/lib/_locale.so +0 -0
- data/lib/gettext/locale_default.rb +0 -35
- data/po/it/messages.mo +0 -0
- data/samples/cgi/po/it/messages.mo +0 -0
data/lib/gettext/string.rb
CHANGED
@@ -2,15 +2,37 @@
|
|
2
2
|
=begin
|
3
3
|
string.rb - Extension for String.
|
4
4
|
|
5
|
-
Copyright (C) 2005
|
5
|
+
Copyright (C) 2005,2006 Masao Mutoh
|
6
6
|
|
7
7
|
You may redistribute it and/or modify it under the same
|
8
8
|
license terms as Ruby.
|
9
9
|
=end
|
10
10
|
|
11
|
+
# = Extension for String class.
|
12
|
+
# String#% method which accept "named argument". The translator can know
|
13
|
+
# the meaning of the msgids using "named argument" instead of %s/%d style.
|
11
14
|
class String
|
12
|
-
alias :_old_format_m :%
|
13
|
-
|
15
|
+
alias :_old_format_m :% # :nodoc:
|
16
|
+
|
17
|
+
# call-seq:
|
18
|
+
# %(arg)
|
19
|
+
# %(hash)
|
20
|
+
#
|
21
|
+
# Format - Uses str as a format specification, and returns the result of applying it to arg.
|
22
|
+
# If the format specification contains more than one substitution, then arg must be
|
23
|
+
# an Array containing the values to be substituted. See Kernel::sprintf for details of the
|
24
|
+
# format string. This is the default behavior of the String class.
|
25
|
+
# * arg: an Array or other class except Hash.
|
26
|
+
# * Returns: formatted String
|
27
|
+
#
|
28
|
+
# (e.g.) "%s, %s" % ["Masao", "Mutoh"]
|
29
|
+
#
|
30
|
+
# Also you can use a Hash as the "named argument". This is recommanded way for Ruby-GetText
|
31
|
+
# because the translators can understand the meanings of the msgids easily.
|
32
|
+
# * hash: {:key1 => value1, :key2 => value2, ... }
|
33
|
+
# * Returns: formatted String
|
34
|
+
#
|
35
|
+
# (e.g.) "%{firstname}, %{familyname}" % {:firstname => "Masao", :familyname => "Mutoh"}
|
14
36
|
def %(args)
|
15
37
|
if args.kind_of?(Hash)
|
16
38
|
ret = dup
|
data/lib/gettext/textdomain.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
=begin
|
2
2
|
textdomain.rb - GetText::Textdomain
|
3
3
|
|
4
|
-
Copyright (C) 2001-
|
4
|
+
Copyright (C) 2001-2006 Masao Mutoh
|
5
5
|
Copyright (C) 2001-2003 Masahiro Sakai
|
6
6
|
|
7
7
|
Masahiro Sakai <s01397ms@sfc.keio.ac.jp>
|
@@ -10,94 +10,103 @@
|
|
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.
|
13
|
+
$Id: textdomain.rb,v 1.14 2006/02/23 14:53:59 mutoh Exp $
|
14
14
|
=end
|
15
15
|
|
16
|
+
require 'gettext/string'
|
16
17
|
require 'rbconfig'
|
17
18
|
|
18
19
|
module GetText
|
20
|
+
# GetText::TextDomain class manages mo-files of a textdomain.
|
21
|
+
#
|
22
|
+
# Usually, you don't need to use this class directly.
|
23
|
+
#
|
24
|
+
# Notice: This class is unstable. APIs will be changed.
|
19
25
|
class TextDomain
|
20
26
|
|
21
|
-
GEM_PATH_RE = /(.*)\/lib$/
|
22
|
-
LOCALE_RE = /^([A-Za-z]+)(_[A-Za-z]+)?(\.\S+)?((?:@[^@]*)*)/
|
27
|
+
GEM_PATH_RE = /(.*)\/lib$/ # :nodoc:
|
23
28
|
|
24
|
-
attr_reader :
|
29
|
+
attr_reader :current_locale
|
30
|
+
attr_reader :current_mo
|
25
31
|
|
26
|
-
|
27
|
-
|
28
|
-
"#{Config::CONFIG['
|
29
|
-
"#{Config::CONFIG['prefix']}/
|
32
|
+
# The default locale paths.
|
33
|
+
DEFAULT_LOCALE_PATHS = [
|
34
|
+
"#{Config::CONFIG['datadir']}/locale/%{locale}/LC_MESSAGES/%{name}.mo",
|
35
|
+
"#{Config::CONFIG['prefix']}/share/locale/%{locale}/LC_MESSAGES/%{name}.mo",
|
36
|
+
"#{Config::CONFIG['prefix']}/local/share/locale/%{locale}/LC_MESSAGES/%{name}.mo"
|
30
37
|
].uniq
|
31
38
|
|
32
|
-
|
33
|
-
|
39
|
+
# Add default locale path. Usually you should use GetText.add_default_locale_path instead.
|
40
|
+
# * path: a new locale path. (e.g.) "/usr/share/locale/%{locale}/LC_MESSAGES/%{name}.mo"
|
41
|
+
# ('locale' => "ja_JP", 'name' => "textdomain")
|
42
|
+
# * Returns: the new DEFAULT_LOCALE_PATHS
|
43
|
+
def self.add_default_locale_path(path)
|
44
|
+
DEFAULT_LOCALE_PATHS << path
|
45
|
+
end
|
46
|
+
|
47
|
+
# Creates a new GetText::TextDomain.
|
48
|
+
# * name: the textdomain name.
|
49
|
+
# * topdir: the top directory of mo files or nil.
|
50
|
+
# * locale: the Locale::Object or nil.
|
51
|
+
# * Returns: a newly created GetText::TextDomain object.
|
52
|
+
def initialize(name, topdir = nil, locale = nil)
|
53
|
+
@name, @topdir = name, topdir
|
34
54
|
@search_files = Array.new
|
35
55
|
|
36
|
-
@
|
56
|
+
@locale_paths = []
|
37
57
|
if ENV["GETTEXT_PATH"]
|
38
58
|
ENV["GETTEXT_PATH"].split(/,/).each {|i|
|
39
|
-
@
|
59
|
+
@locale_paths += ["#{i}/%{locale}/LC_MESSAGES/%{name}.mo", "#{i}/%{locale}/%{name}.mo"]
|
40
60
|
}
|
41
|
-
elsif
|
42
|
-
@
|
61
|
+
elsif @topdir
|
62
|
+
@locale_paths += ["#{@topdir}/%{locale}/LC_MESSAGES/%{name}.mo", "#{@topdir}/%{locale}/%{name}.mo"]
|
43
63
|
end
|
44
64
|
|
45
|
-
unless
|
46
|
-
@
|
65
|
+
unless @topdir
|
66
|
+
@locale_paths += DEFAULT_LOCALE_PATHS
|
47
67
|
|
48
68
|
if defined? Gem
|
49
69
|
$:.each do |path|
|
50
70
|
if GEM_PATH_RE =~ path
|
51
|
-
@
|
52
|
-
"#{$1}/data/locale/%
|
53
|
-
"#{$1}/data/locale/%
|
54
|
-
"#{$1}/locale/%
|
71
|
+
@locale_paths += [
|
72
|
+
"#{$1}/data/locale/%{locale}/LC_MESSAGES/%{name}.mo",
|
73
|
+
"#{$1}/data/locale/%{locale}/%{name}.mo",
|
74
|
+
"#{$1}/locale/%{locale}/%{name}.mo"]
|
55
75
|
end
|
56
76
|
end
|
57
77
|
end
|
58
78
|
end
|
59
79
|
|
60
80
|
@mofiles = Hash.new
|
61
|
-
|
62
|
-
set_locale(locale, false)
|
63
|
-
load_mo
|
64
|
-
|
65
|
-
$stderr.puts "Search path:#{@locale_dirs.inspect}" if $DEBUG
|
81
|
+
set_locale(locale)
|
66
82
|
end
|
67
83
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
while not matched.empty?
|
77
|
-
@locales.push(matched.join(''))
|
78
|
-
matched.pop
|
79
|
-
end
|
80
|
-
@locales.uniq!
|
81
|
-
else
|
82
|
-
@locales.push(locale)
|
83
|
-
end
|
84
|
-
load_mo(false) if reload
|
84
|
+
# Sets a new Locale::Object.
|
85
|
+
# * locale: a Locale::Object
|
86
|
+
# * reload: true if the mo-file is reloaded forcely
|
87
|
+
# * Returns: self
|
88
|
+
def set_locale(locale, reload = false)
|
89
|
+
@current_locale = locale
|
90
|
+
load_mo(reload)
|
91
|
+
self
|
85
92
|
end
|
86
|
-
|
93
|
+
|
94
|
+
# Gets the translated string.
|
95
|
+
# * msgid: the original message.
|
96
|
+
# * Returns: the translated string.
|
87
97
|
def gettext(msgid)
|
88
|
-
if @
|
89
|
-
|
90
|
-
result = @mo[msgid].size > 0 ? @mo[msgid] : msgid
|
91
|
-
else
|
92
|
-
result = msgid
|
93
|
-
end
|
98
|
+
if @current_mo and @current_mo[msgid] and (@current_mo[msgid].size > 0)
|
99
|
+
@current_mo[msgid]
|
94
100
|
else
|
95
|
-
|
96
|
-
result = msgid
|
101
|
+
msgid
|
97
102
|
end
|
98
|
-
result
|
99
103
|
end
|
100
104
|
|
105
|
+
# Gets the translated string.
|
106
|
+
# * msgid: the original message(single).
|
107
|
+
# * msgid: the original message(plural).
|
108
|
+
# * n: the number
|
109
|
+
# * Returns: the translated string.
|
101
110
|
def ngettext(msgid, msgid_plural, n)
|
102
111
|
key = msgid + "\000" + msgid_plural
|
103
112
|
msg = gettext(key)
|
@@ -105,8 +114,8 @@ module GetText
|
|
105
114
|
msg = n == 1 ? msgid : msgid_plural
|
106
115
|
elsif msg.include?("\000")
|
107
116
|
ary = msg.split("\000")
|
108
|
-
if @
|
109
|
-
plural = eval(@
|
117
|
+
if @current_mo
|
118
|
+
plural = eval(@current_mo.plural)
|
110
119
|
if plural.kind_of?(Numeric)
|
111
120
|
msg = ary[plural]
|
112
121
|
else
|
@@ -119,53 +128,43 @@ module GetText
|
|
119
128
|
msg
|
120
129
|
end
|
121
130
|
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
def same_property?(name, path, locale, charset)
|
130
|
-
@name == name and @path == path and @locales.include?(locale) and @charset == charset
|
131
|
+
# Compare this object has the same name, topdir and locale.
|
132
|
+
# * name: the textdomain name
|
133
|
+
# * topdir: the top directory of mo files or nil.
|
134
|
+
# * locale: the Locale::Object or nil.
|
135
|
+
# * Returns: true if this object has all of the same name, topdir and locale.
|
136
|
+
def same_property?(name, topdir, locale)
|
137
|
+
@name == name and @topdir == topdir and @current_locale == locale
|
131
138
|
end
|
132
139
|
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
attr_reader :charset
|
144
|
-
|
145
|
-
def load_mo(cache = true)
|
146
|
-
@mo = nil
|
147
|
-
if cache
|
148
|
-
@mo = @mofiles[@locales[0]]
|
149
|
-
if @mo
|
150
|
-
return @mo == :empty ? nil : @mo
|
140
|
+
private
|
141
|
+
def load_mo(reload = false)
|
142
|
+
@current_mo = nil
|
143
|
+
return @current_mo unless @current_locale
|
144
|
+
unless reload
|
145
|
+
@current_mo = @mofiles[@current_locale]
|
146
|
+
if @current_mo
|
147
|
+
@current_mo = (@current_mo == :empty) ? nil : @current_mo
|
148
|
+
return @current_mo
|
151
149
|
end
|
152
150
|
end
|
153
|
-
@
|
154
|
-
|
155
|
-
|
151
|
+
locales = [@current_locale.orig_str, @current_locale.to_posix, @current_locale.language]
|
152
|
+
@locale_paths.each do |dir|
|
153
|
+
locales.each{|locale|
|
154
|
+
fname = dir % {:locale => locale, :name => @name}
|
156
155
|
@search_files << fname
|
157
156
|
if File.exist?(fname)
|
158
157
|
$stderr.puts "GetText::TextDomain#load_mo: mo file is #{fname}" if $DEBUG
|
159
|
-
@
|
160
|
-
@mofiles[@
|
158
|
+
@current_mo = MOFile.open(fname, @current_locale.charset)
|
159
|
+
@mofiles[@current_locale] = @current_mo
|
161
160
|
break
|
162
161
|
end
|
163
162
|
}
|
164
163
|
end
|
165
|
-
unless @
|
166
|
-
@mofiles[@
|
164
|
+
unless @current_mo
|
165
|
+
@mofiles[@current_locale] = :empty
|
167
166
|
end
|
168
|
-
@
|
167
|
+
@current_mo
|
169
168
|
end
|
170
169
|
end
|
171
170
|
end
|
data/lib/gettext/utils.rb
CHANGED
@@ -13,7 +13,28 @@ require 'fileutils'
|
|
13
13
|
|
14
14
|
module GetText
|
15
15
|
module_function
|
16
|
-
|
16
|
+
|
17
|
+
# Merges two Uniforum style .po files together.
|
18
|
+
#
|
19
|
+
# *Note* "msgmerge" tool is included in GNU GetText. So you need to install GNU GetText.
|
20
|
+
#
|
21
|
+
# The def.po file is an existing PO file with translations which will be taken
|
22
|
+
# over to the newly created file as long as they still match; comments will be preserved,
|
23
|
+
# but extracted comments and file positions will be discarded.
|
24
|
+
#
|
25
|
+
# The ref.pot file is the last created PO file with up-to-date source references but
|
26
|
+
# old translations, or a PO Template file (generally created by rgettext);
|
27
|
+
# any translations or comments in the file will be discarded, however dot
|
28
|
+
# comments and file positions will be preserved. Where an exact match
|
29
|
+
# cannot be found, fuzzy matching is used to produce better results.
|
30
|
+
#
|
31
|
+
# Usually you don't need to call this function directly. Use GetText.update_pofiles instead.
|
32
|
+
#
|
33
|
+
# * defpo: a po-file. translations referring to old sources
|
34
|
+
# * refpo: a po-file. references to new sources
|
35
|
+
# * app_version: the application information which appears "Project-Id-Version: #{app_version}" in the pot/po-files.
|
36
|
+
# * Returns: self
|
37
|
+
def msgmerge(defpo, refpo, app_version)
|
17
38
|
$stderr.puts defpo
|
18
39
|
cmd = ENV["MSGMERGE_PATH"]
|
19
40
|
cmd ||= "msgmerge"
|
@@ -30,9 +51,10 @@ module GetText
|
|
30
51
|
File.open(defpo, "w") do |out|
|
31
52
|
out.write(cont)
|
32
53
|
end
|
54
|
+
self
|
33
55
|
end
|
34
56
|
|
35
|
-
def msgmerge_all(textdomain, app_version, po_root = "po", refpot = "tmp.pot")
|
57
|
+
def msgmerge_all(textdomain, app_version, po_root = "po", refpot = "tmp.pot") # :nodoc:
|
36
58
|
FileUtils.mkdir_p(po_root) unless FileTest.exist? po_root
|
37
59
|
msgmerge("#{po_root}/#{textdomain}.pot", refpot, app_version)
|
38
60
|
|
@@ -42,7 +64,45 @@ module GetText
|
|
42
64
|
}
|
43
65
|
end
|
44
66
|
|
45
|
-
#
|
67
|
+
# Creates mo-files using #{po_root}/#{lang}/*.po an put them to
|
68
|
+
# #{targetdir}/#{targetpath_rule}/.
|
69
|
+
#
|
70
|
+
# This is a convenience function of GetText.rmsgfmt for plural target files.
|
71
|
+
# * verbose: true if verbose mode, otherwise false
|
72
|
+
# * po_root: the root directory of po-files.
|
73
|
+
# * targetdir: the target root directory where the mo-files are stored.
|
74
|
+
# * targetpath_rule: the target directory for each mo-files. "%s" becomes "#{lang}" under po_root.
|
75
|
+
def create_mofiles(verbose = false,
|
76
|
+
podir = "./po", targetdir = "./data/locale",
|
77
|
+
targetpath_rule = "%s/LC_MESSAGES")
|
78
|
+
|
79
|
+
modir = File.join(targetdir, targetpath_rule)
|
80
|
+
Dir.glob(File.join(podir, "*/*.po")) do |file|
|
81
|
+
lang, basename = /\/([^\/]+?)\/(.*)\.po/.match(file[podir.size..-1]).to_a[1,2]
|
82
|
+
outdir = modir % lang
|
83
|
+
FileUtils.mkdir_p(outdir) unless File.directory?(outdir)
|
84
|
+
rmsgfmt(file, File.join(outdir, "#{basename}.mo"))
|
85
|
+
if verbose
|
86
|
+
$stderr.puts %Q[#{file} -> #{File.join(outdir, "#{basename}.mo")}]
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
|
92
|
+
# At first, this creates the #{po_root}/#{domainname}.pot file using GetText.rgettext.
|
93
|
+
# Since 2nd time, this updates(merges) the #{po_root}/#{domainname}.pot and all of the
|
94
|
+
# #{po_root}/#{lang}/#{domainname}.po files under "po_root" using "msgmerge".
|
95
|
+
#
|
96
|
+
# *Note* "msgmerge" tool is included in GNU GetText. So you need to install GNU GetText.
|
97
|
+
#
|
98
|
+
# See <HOWTO maintain po/mo files(http://www.yotabanana.com/hiki/ruby-gettext-howto-manage.html)> for more detals.
|
99
|
+
# * domainname: the textdomain name.
|
100
|
+
# * targetfiles: An Array of target files or nil (See GetText.rgettext for more details).
|
101
|
+
# * app_version: the application information which appears "Project-Id-Version: #{app_version}" in the pot/po-files.
|
102
|
+
# * po_root: the root directory of po-files.
|
103
|
+
# * refpot: set the temporary file name. You shouldn't use this(It will be removed).
|
104
|
+
#
|
105
|
+
# (e.g.) GetText.update_pofiles("myapp", Dir.glob("lib/*.rb"), "myapp 1.0.0")
|
46
106
|
def update_pofiles(textdomain, files, app_version, po_root = "po", refpot = "tmp.pot")
|
47
107
|
rgettext(files, refpot)
|
48
108
|
msgmerge_all(textdomain, app_version, po_root, refpot)
|
data/lib/gettext/version.rb
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
=begin
|
3
3
|
version - version information of Ruby-GetText-Package
|
4
4
|
|
5
|
-
Copyright (C) 2005,2006
|
5
|
+
Copyright (C) 2005,2006 Masao Mutoh
|
6
6
|
|
7
7
|
You may redistribute it and/or modify it under the same
|
8
8
|
license terms as Ruby.
|
9
9
|
=end
|
10
10
|
module GetText
|
11
|
-
VERSION = "1.
|
11
|
+
VERSION = "1.2.0"
|
12
12
|
end
|
Binary file
|
data/po/cs/rails.po
CHANGED
@@ -8,8 +8,8 @@
|
|
8
8
|
#
|
9
9
|
msgid ""
|
10
10
|
msgstr ""
|
11
|
-
"Project-Id-Version: ruby-gettext 1.
|
12
|
-
"POT-Creation-Date:
|
11
|
+
"Project-Id-Version: ruby-gettext 1.2.0\n"
|
12
|
+
"POT-Creation-Date: 2006-02-23 00:44+0900\n"
|
13
13
|
"PO-Revision-Date: 2005-12-17 21:43+0100\n"
|
14
14
|
"Last-Translator: Karel Miarka <kajism@yahoo.com>\n"
|
15
15
|
"Language-Team: Czech\n"
|
@@ -20,64 +20,64 @@ msgstr ""
|
|
20
20
|
"10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n"
|
21
21
|
"X-Poedit-Language: Czech\n"
|
22
22
|
|
23
|
-
#: lib/gettext/rails.rb:
|
23
|
+
#: lib/gettext/rails.rb:117
|
24
|
+
msgid "%{num} error prohibited this %{record} from being saved"
|
25
|
+
msgid_plural "%{num} errors prohibited this %{record} from being saved"
|
26
|
+
msgstr[0] "%{num} chyba znemožnila uložení záznamu %{record} "
|
27
|
+
msgstr[1] "%{num} chyby znemožnily uložení záznamu %{record} "
|
28
|
+
msgstr[2] "%{num} chyb znemožnilo uložení záznamu %{record} "
|
29
|
+
|
30
|
+
#: lib/gettext/rails.rb:123
|
31
|
+
msgid "There was a problem with the following field:"
|
32
|
+
msgid_plural "There were problems with the following fields:"
|
33
|
+
msgstr[0] "Problémy jsou s následujícím polem:"
|
34
|
+
msgstr[1] "Problémy jsou s následujícími poli:"
|
35
|
+
msgstr[2] "Problémy jsou s následujícími poli:"
|
36
|
+
|
37
|
+
#: lib/gettext/rails.rb:135
|
24
38
|
msgid "%{fn} is not included in the list"
|
25
39
|
msgstr "%{fn} není obsaženo v seznamu možností"
|
26
40
|
|
27
|
-
#: lib/gettext/rails.rb:
|
41
|
+
#: lib/gettext/rails.rb:136
|
28
42
|
msgid "%{fn} is reserved"
|
29
43
|
msgstr "%{fn} je rezervováno a nemůže být zvoleno"
|
30
44
|
|
31
|
-
#: lib/gettext/rails.rb:
|
45
|
+
#: lib/gettext/rails.rb:137
|
32
46
|
msgid "%{fn} is invalid"
|
33
47
|
msgstr "%{fn} je chybné"
|
34
48
|
|
35
|
-
#: lib/gettext/rails.rb:
|
49
|
+
#: lib/gettext/rails.rb:138
|
36
50
|
msgid "%{fn} doesn't match confirmation"
|
37
51
|
msgstr "%{fn} není shodné s potvrzením"
|
38
52
|
|
39
|
-
#: lib/gettext/rails.rb:
|
53
|
+
#: lib/gettext/rails.rb:139
|
40
54
|
msgid "%{fn} must be accepted"
|
41
55
|
msgstr "%{fn} musí být zaškrtnuto"
|
42
56
|
|
43
|
-
#: lib/gettext/rails.rb:
|
57
|
+
#: lib/gettext/rails.rb:140
|
44
58
|
msgid "%{fn} can't be empty"
|
45
59
|
msgstr "%{fn} musí být vyplněno"
|
46
60
|
|
47
|
-
#: lib/gettext/rails.rb:
|
61
|
+
#: lib/gettext/rails.rb:141
|
48
62
|
msgid "%{fn} can't be blank"
|
49
63
|
msgstr "%{fn} musí být vyplněno"
|
50
64
|
|
51
|
-
#: lib/gettext/rails.rb:
|
65
|
+
#: lib/gettext/rails.rb:142
|
52
66
|
msgid "%{fn} is too long (max is %d characters)"
|
53
67
|
msgstr "%{fn} je příliš dlouhé (maximum je %d znaků)"
|
54
68
|
|
55
|
-
#: lib/gettext/rails.rb:
|
69
|
+
#: lib/gettext/rails.rb:143
|
56
70
|
msgid "%{fn} is too short (min is %d characters)"
|
57
71
|
msgstr "%{fn} je příliš krátké (minimum je %d znaků)"
|
58
72
|
|
59
|
-
#: lib/gettext/rails.rb:
|
73
|
+
#: lib/gettext/rails.rb:144
|
60
74
|
msgid "%{fn} is the wrong length (should be %d characters)"
|
61
75
|
msgstr "%{fn} má nesprávnou délku (musí mít %d znaků)"
|
62
76
|
|
63
|
-
#: lib/gettext/rails.rb:
|
77
|
+
#: lib/gettext/rails.rb:145
|
64
78
|
msgid "%{fn} has already been taken"
|
65
79
|
msgstr "%{fn} je již použito"
|
66
80
|
|
67
|
-
#: lib/gettext/rails.rb:
|
81
|
+
#: lib/gettext/rails.rb:146
|
68
82
|
msgid "%{fn} is not a number"
|
69
83
|
msgstr "%{fn} není správné číslo"
|
70
|
-
|
71
|
-
#: lib/gettext/rails.rb:176
|
72
|
-
msgid "%{num} error prohibited this %{record} from being saved"
|
73
|
-
msgid_plural "%{num} errors prohibited this %{record} from being saved"
|
74
|
-
msgstr[0] "%{num} chyba znemožnila uložení záznamu %{record} "
|
75
|
-
msgstr[1] "%{num} chyby znemožnily uložení záznamu %{record} "
|
76
|
-
msgstr[2] "%{num} chyb znemožnilo uložení záznamu %{record} "
|
77
|
-
|
78
|
-
#: lib/gettext/rails.rb:179
|
79
|
-
msgid "There were problems with the following field:"
|
80
|
-
msgid_plural "There were problems with the following fields:"
|
81
|
-
msgstr[0] "Problémy jsou s následujícím polem:"
|
82
|
-
msgstr[1] "Problémy jsou s následujícími poli:"
|
83
|
-
msgstr[2] "Problémy jsou s následujícími poli:"
|