gettext 1.1.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) hide show
  1. data/ChangeLog +128 -0
  2. data/NEWS +10 -0
  3. data/README +21 -23
  4. data/Rakefile +39 -20
  5. data/bin/rgettext +1 -1
  6. data/bin/rmsgfmt +1 -1
  7. data/bin/rmsgmerge +1 -1
  8. data/data/locale/cs/LC_MESSAGES/rails.mo +0 -0
  9. data/data/locale/cs/LC_MESSAGES/rgettext.mo +0 -0
  10. data/data/locale/de/LC_MESSAGES/rails.mo +0 -0
  11. data/data/locale/de/LC_MESSAGES/rgettext.mo +0 -0
  12. data/data/locale/el/LC_MESSAGES/rails.mo +0 -0
  13. data/data/locale/el/LC_MESSAGES/rgettext.mo +0 -0
  14. data/data/locale/es/LC_MESSAGES/rails.mo +0 -0
  15. data/data/locale/es/LC_MESSAGES/rgettext.mo +0 -0
  16. data/data/locale/fr/LC_MESSAGES/rails.mo +0 -0
  17. data/data/locale/fr/LC_MESSAGES/rgettext.mo +0 -0
  18. data/data/locale/it/LC_MESSAGES/rgettext.mo +0 -0
  19. data/data/locale/ja/LC_MESSAGES/rails.mo +0 -0
  20. data/data/locale/ja/LC_MESSAGES/rgettext.mo +0 -0
  21. data/data/locale/ko/LC_MESSAGES/rails.mo +0 -0
  22. data/data/locale/ko/LC_MESSAGES/rgettext.mo +0 -0
  23. data/data/locale/nl/LC_MESSAGES/rails.mo +0 -0
  24. data/data/locale/nl/LC_MESSAGES/rgettext.mo +0 -0
  25. data/data/locale/pt_BR/LC_MESSAGES/rails.mo +0 -0
  26. data/data/locale/pt_BR/LC_MESSAGES/rgettext.mo +0 -0
  27. data/data/locale/sv/LC_MESSAGES/rgettext.mo +0 -0
  28. data/ext/gettext/extconf.rb +20 -0
  29. data/ext/gettext/{gettext/_locale.c → locale_system.c} +15 -19
  30. data/lib/gettext.rb +186 -38
  31. data/lib/gettext/cgi.rb +35 -69
  32. data/lib/gettext/container.rb +14 -5
  33. data/lib/gettext/erb.rb +30 -2
  34. data/lib/gettext/iconv.rb +19 -4
  35. data/lib/gettext/locale.rb +188 -39
  36. data/lib/gettext/locale_cgi.rb +102 -0
  37. data/lib/gettext/locale_object.rb +131 -0
  38. data/lib/gettext/locale_posix.rb +50 -0
  39. data/lib/gettext/locale_table_win32.rb +224 -182
  40. data/lib/gettext/locale_win32.rb +59 -35
  41. data/lib/gettext/mo.rb +2 -2
  42. data/lib/gettext/parser/activerecord.rb +19 -5
  43. data/lib/gettext/parser/erb.rb +6 -3
  44. data/lib/gettext/parser/glade.rb +5 -5
  45. data/lib/gettext/parser/ruby.rb +6 -6
  46. data/lib/gettext/poparser.rb +7 -6
  47. data/lib/gettext/rails.rb +122 -44
  48. data/lib/gettext/rgettext.rb +21 -8
  49. data/lib/gettext/rmsgfmt.rb +16 -8
  50. data/lib/gettext/rmsgmerge.rb +172 -50
  51. data/lib/gettext/string.rb +25 -3
  52. data/lib/gettext/textdomain.rb +89 -90
  53. data/lib/gettext/utils.rb +63 -3
  54. data/lib/gettext/version.rb +2 -2
  55. data/pkg/ruby-gettext-package-1.2.0/ext/gettext/extconf.rb +20 -0
  56. data/po/cs/rails.po +28 -28
  57. data/po/cs/rgettext.po +14 -14
  58. data/po/de/rails.po +29 -26
  59. data/po/de/rgettext.po +24 -17
  60. data/po/el/rails.po +26 -26
  61. data/po/el/rgettext.po +18 -15
  62. data/po/es/rails.po +26 -26
  63. data/po/es/rgettext.po +16 -16
  64. data/po/fr/rails.po +27 -27
  65. data/po/fr/rgettext.po +14 -14
  66. data/po/it/rgettext.po +14 -14
  67. data/po/ja/rails.po +24 -24
  68. data/po/ja/rgettext.po +14 -14
  69. data/po/ko/rails.po +24 -24
  70. data/po/ko/rgettext.po +17 -18
  71. data/po/nl/rails.po +27 -27
  72. data/po/nl/rgettext.po +18 -18
  73. data/po/pt_BR/rails.po +26 -26
  74. data/po/pt_BR/rgettext.po +14 -14
  75. data/po/rails.pot +26 -26
  76. data/po/rgettext.pot +14 -14
  77. data/po/sv/rgettext.po +14 -14
  78. data/post-setup.rb +8 -3
  79. data/pre-setup.rb +14 -1
  80. data/samples/cgi/http.rb +2 -1
  81. data/samples/makemo.rb +1 -1
  82. data/samples/rails/app/models/article.rb +15 -1
  83. data/samples/rails/locale/cs/LC_MESSAGES/blog.mo +0 -0
  84. data/samples/rails/locale/cs/LC_MESSAGES/gettext_plugin.mo +0 -0
  85. data/samples/rails/locale/de/LC_MESSAGES/blog.mo +0 -0
  86. data/samples/rails/locale/de/LC_MESSAGES/gettext_plugin.mo +0 -0
  87. data/samples/rails/locale/el/LC_MESSAGES/blog.mo +0 -0
  88. data/samples/rails/locale/el/LC_MESSAGES/gettext_plugin.mo +0 -0
  89. data/samples/rails/locale/en/LC_MESSAGES/blog.mo +0 -0
  90. data/samples/rails/locale/es/LC_MESSAGES/blog.mo +0 -0
  91. data/samples/rails/locale/es/LC_MESSAGES/gettext_plugin.mo +0 -0
  92. data/samples/rails/locale/fr/LC_MESSAGES/blog.mo +0 -0
  93. data/samples/rails/locale/fr/LC_MESSAGES/gettext_plugin.mo +0 -0
  94. data/samples/rails/locale/ja/LC_MESSAGES/blog.mo +0 -0
  95. data/samples/rails/locale/ja/LC_MESSAGES/gettext_plugin.mo +0 -0
  96. data/samples/rails/locale/ko/LC_MESSAGES/blog.mo +0 -0
  97. data/samples/rails/locale/ko/LC_MESSAGES/gettext_plugin.mo +0 -0
  98. data/samples/rails/locale/nl/LC_MESSAGES/blog.mo +0 -0
  99. data/samples/rails/locale/nl/LC_MESSAGES/gettext_plugin.mo +0 -0
  100. data/samples/rails/locale/pt_BR/LC_MESSAGES/blog.mo +0 -0
  101. data/samples/rails/locale/pt_BR/LC_MESSAGES/gettext_plugin.mo +0 -0
  102. data/samples/rails/po/blog.pot +1 -1
  103. data/samples/rails/po/cs/blog.po +1 -2
  104. data/samples/rails/po/cs/gettext_plugin.po +1 -1
  105. data/samples/rails/po/de/blog.po +1 -2
  106. data/samples/rails/po/de/gettext_plugin.po +1 -1
  107. data/samples/rails/po/el/blog.po +1 -1
  108. data/samples/rails/po/el/gettext_plugin.po +1 -1
  109. data/samples/rails/po/en/blog.po +1 -1
  110. data/samples/rails/po/es/blog.po +1 -2
  111. data/samples/rails/po/es/gettext_plugin.po +1 -1
  112. data/samples/rails/po/fr/blog.po +1 -1
  113. data/samples/rails/po/fr/gettext_plugin.po +1 -1
  114. data/samples/rails/po/gettext_plugin.pot +1 -1
  115. data/samples/rails/po/ja/blog.po +2 -1
  116. data/samples/rails/po/ja/gettext_plugin.po +1 -1
  117. data/samples/rails/po/ko/blog.po +1 -2
  118. data/samples/rails/po/ko/gettext_plugin.po +1 -1
  119. data/samples/rails/po/nl/blog.po +1 -3
  120. data/samples/rails/po/nl/gettext_plugin.po +1 -1
  121. data/samples/rails/po/pt_BR/blog.po +1 -1
  122. data/samples/rails/po/pt_BR/gettext_plugin.po +1 -1
  123. data/setup.rb +799 -574
  124. data/src/poparser.ry +6 -5
  125. data/test/gettext_runner.rb +3 -1
  126. data/test/gettext_test.rb +40 -24
  127. data/test/gettext_test_cgi.rb +60 -6
  128. data/test/gettext_test_locale.rb +136 -0
  129. data/test/gettext_test_parser.rb +12 -12
  130. data/test/locale/la/LC_MESSAGES/plural_error.mo +0 -0
  131. data/test/po/la/plural_error.po +21 -0
  132. data/test/test.bat +2 -0
  133. data/test/test.sh +2 -4
  134. data/test/{test_rubyparser_n.rb → test_rubyparser_n_.rb} +0 -0
  135. metadata +17 -12
  136. data/ext/gettext/gettext/MANIFEST +0 -3
  137. data/ext/gettext/gettext/extconf.rb +0 -20
  138. data/lib/gettext/locale_default.rb +0 -35
@@ -2,15 +2,37 @@
2
2
  =begin
3
3
  string.rb - Extension for String.
4
4
 
5
- Copyright (C) 2005 Masao Mutoh
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
@@ -1,7 +1,7 @@
1
1
  =begin
2
2
  textdomain.rb - GetText::Textdomain
3
3
 
4
- Copyright (C) 2001-2005 Masao Mutoh
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.8 2005/12/23 04:00:52 mutoh Exp $
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 :locales
29
+ attr_reader :current_locale
30
+ attr_reader :current_mo
25
31
 
26
- DEFAULT_LOCALE_DIRS = [
27
- "#{Config::CONFIG['datadir']}/locale/%s/LC_MESSAGES/%s.mo",
28
- "#{Config::CONFIG['prefix']}/share/locale/%s/LC_MESSAGES/%s.mo",
29
- "#{Config::CONFIG['prefix']}/local/share/locale/%s/LC_MESSAGES/%s.mo"
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
- def initialize(name, path, locale, charset)
33
- @name, @path = name, path
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
- @locale_dirs = []
56
+ @locale_paths = []
37
57
  if ENV["GETTEXT_PATH"]
38
58
  ENV["GETTEXT_PATH"].split(/,/).each {|i|
39
- @locale_dirs += ["#{i}/%s/LC_MESSAGES/%s.mo", "#{i}/%s/%s.mo"]
59
+ @locale_paths += ["#{i}/%{locale}/LC_MESSAGES/%{name}.mo", "#{i}/%{locale}/%{name}.mo"]
40
60
  }
41
- elsif path
42
- @locale_dirs += ["#{path}/%s/LC_MESSAGES/%s.mo", "#{path}/%s/%s.mo"]
61
+ elsif @topdir
62
+ @locale_paths += ["#{@topdir}/%{locale}/LC_MESSAGES/%{name}.mo", "#{@topdir}/%{locale}/%{name}.mo"]
43
63
  end
44
64
 
45
- unless path
46
- @locale_dirs += DEFAULT_LOCALE_DIRS
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
- @locale_dirs += [
52
- "#{$1}/data/locale/%s/LC_MESSAGES/%s.mo",
53
- "#{$1}/data/locale/%s/%s.mo",
54
- "#{$1}/locale/%s/%s.mo"]
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
- set_charset(charset, false)
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
- def set_locale(locale, reload = true)
69
- locale = "C" unless locale
70
- $stderr.puts "locale:#{locale}" if $DEBUG
71
- @locales = []
72
- matched = LOCALE_RE.match(locale)
73
- if matched and matched.size > 1
74
- matched = matched.to_a
75
- matched.shift
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 @mo
89
- if @mo[msgid]
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
- no_mo_file if $DEBUG
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 @mo
109
- plural = eval(@mo.plural)
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
- def no_mo_file
123
- $stderr.puts "\nMO file is not found in"
124
- @search_files.each do |fname|
125
- $stderr.puts "\t#{fname}"
126
- end
127
- end
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
- def set_charset(charset, reload = true)
134
- if charset and charset != ""
135
- @charset = charset
136
- else
137
- @charset = ENV["OUTPUT_CHARSET"] ? ENV["OUTPUT_CHARSET"] : Locale.codeset
138
- end
139
- $stderr.puts "GetText::TextDomain#set_charset: charset = #{charset}" if $DEBUG
140
- load_mo(false) if reload
141
- end
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
- @locale_dirs.each do |dir|
154
- @locales.each{|locale|
155
- fname = dir % [locale, @name]
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
- @mo = MOFile.open(fname, @charset)
160
- @mofiles[@locales[0]] = @mo
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 @mo
166
- @mofiles[@locales[0]] = :empty
164
+ unless @current_mo
165
+ @mofiles[@current_locale] = :empty
167
166
  end
168
- @mo
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
- def msgmerge(defpo, refpo, app_version)
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
- # updatepo("myapp", Dir.glob("lib/*.rb"), "myapp 1.0.0")
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)
@@ -2,11 +2,11 @@
2
2
  =begin
3
3
  version - version information of Ruby-GetText-Package
4
4
 
5
- Copyright (C) 2005,2006 Masao Mutoh
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.1.1"
11
+ VERSION = "1.2.0"
12
12
  end
@@ -0,0 +1,20 @@
1
+ =begin
2
+ extconf.rb
3
+
4
+ Copyright (C) 2002-2006 Masao Mutoh <mutoh@highway.ne.jp>
5
+
6
+ You may redistribute it and/or modify it under the same
7
+ license terms as Ruby.
8
+
9
+ $Id: extconf.rb,v 1.1 2006/02/07 00:24:45 mutoh Exp $
10
+ =end
11
+
12
+ require 'mkmf'
13
+
14
+ if RUBY_PLATFORM =~ /cygwin|mingw|mswin32|bccwin32/
15
+ have_header 'windows.h'
16
+ else
17
+ have_func 'setlocale'
18
+ have_func 'nl_langinfo'
19
+ end
20
+ create_makefile 'locale_system'
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.1.0\n"
12
- "POT-Creation-Date: 2005-12-20 03:03+0900\n"
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:100
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:101
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:102
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:103
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:104
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:105
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:106
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:107
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:108
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:109
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:110
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:111
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:"