gettext_activerecord 2.0.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.
Files changed (96) hide show
  1. data/COPYING +55 -0
  2. data/ChangeLog +4 -0
  3. data/README.rdoc +172 -0
  4. data/Rakefile +110 -0
  5. data/data/locale/bg/LC_MESSAGES/gettext_activerecord.mo +0 -0
  6. data/data/locale/bs/LC_MESSAGES/gettext_activerecord.mo +0 -0
  7. data/data/locale/ca/LC_MESSAGES/gettext_activerecord.mo +0 -0
  8. data/data/locale/cs/LC_MESSAGES/gettext_activerecord.mo +0 -0
  9. data/data/locale/de/LC_MESSAGES/gettext_activerecord.mo +0 -0
  10. data/data/locale/el/LC_MESSAGES/gettext_activerecord.mo +0 -0
  11. data/data/locale/eo/LC_MESSAGES/gettext_activerecord.mo +0 -0
  12. data/data/locale/es/LC_MESSAGES/gettext_activerecord.mo +0 -0
  13. data/data/locale/et/LC_MESSAGES/gettext_activerecord.mo +0 -0
  14. data/data/locale/fr/LC_MESSAGES/gettext_activerecord.mo +0 -0
  15. data/data/locale/hr/LC_MESSAGES/gettext_activerecord.mo +0 -0
  16. data/data/locale/hu/LC_MESSAGES/gettext_activerecord.mo +0 -0
  17. data/data/locale/it/LC_MESSAGES/gettext_activerecord.mo +0 -0
  18. data/data/locale/ja/LC_MESSAGES/gettext_activerecord.mo +0 -0
  19. data/data/locale/ko/LC_MESSAGES/gettext_activerecord.mo +0 -0
  20. data/data/locale/lv/LC_MESSAGES/gettext_activerecord.mo +0 -0
  21. data/data/locale/nb/LC_MESSAGES/gettext_activerecord.mo +0 -0
  22. data/data/locale/nl/LC_MESSAGES/gettext_activerecord.mo +0 -0
  23. data/data/locale/pt_BR/LC_MESSAGES/gettext_activerecord.mo +0 -0
  24. data/data/locale/ru/LC_MESSAGES/gettext_activerecord.mo +0 -0
  25. data/data/locale/sr/LC_MESSAGES/gettext_activerecord.mo +0 -0
  26. data/data/locale/ua/LC_MESSAGES/gettext_activerecord.mo +0 -0
  27. data/data/locale/vi/LC_MESSAGES/gettext_activerecord.mo +0 -0
  28. data/data/locale/zh/LC_MESSAGES/gettext_activerecord.mo +0 -0
  29. data/data/locale/zh_TW/LC_MESSAGES/gettext_activerecord.mo +0 -0
  30. data/lib/gettext_activerecord/base.rb +66 -0
  31. data/lib/gettext_activerecord/i18n.rb +27 -0
  32. data/lib/gettext_activerecord/migration.rb +16 -0
  33. data/lib/gettext_activerecord/parser.rb +216 -0
  34. data/lib/gettext_activerecord/schema_definitions.rb +28 -0
  35. data/lib/gettext_activerecord/tools.rb +25 -0
  36. data/lib/gettext_activerecord/validations.rb +189 -0
  37. data/lib/gettext_activerecord/version.rb +12 -0
  38. data/lib/gettext_activerecord.rb +19 -0
  39. data/po/bg/gettext_activerecord.po +115 -0
  40. data/po/bs/gettext_activerecord.po +125 -0
  41. data/po/ca/gettext_activerecord.po +116 -0
  42. data/po/cs/gettext_activerecord.po +124 -0
  43. data/po/de/gettext_activerecord.po +117 -0
  44. data/po/el/gettext_activerecord.po +115 -0
  45. data/po/eo/gettext_activerecord.po +116 -0
  46. data/po/es/gettext_activerecord.po +116 -0
  47. data/po/et/gettext_activerecord.po +116 -0
  48. data/po/fr/gettext_activerecord.po +118 -0
  49. data/po/gettext_activerecord.pot +113 -0
  50. data/po/hr/gettext_activerecord.po +125 -0
  51. data/po/hu/gettext_activerecord.po +116 -0
  52. data/po/it/gettext_activerecord.po +122 -0
  53. data/po/ja/gettext_activerecord.po +116 -0
  54. data/po/ko/gettext_activerecord.po +123 -0
  55. data/po/lv/gettext_activerecord.po +116 -0
  56. data/po/nb/gettext_activerecord.po +117 -0
  57. data/po/nl/gettext_activerecord.po +123 -0
  58. data/po/pt_BR/gettext_activerecord.po +117 -0
  59. data/po/ru/gettext_activerecord.po +117 -0
  60. data/po/sr/gettext_activerecord.po +117 -0
  61. data/po/test.rb +8 -0
  62. data/po/ua/gettext_activerecord.po +120 -0
  63. data/po/vi/gettext_activerecord.po +116 -0
  64. data/po/zh/gettext_activerecord.po +119 -0
  65. data/po/zh_TW/gettext_activerecord.po +119 -0
  66. data/replace.rb +21 -0
  67. data/sample/README.rdoc +9 -0
  68. data/sample/Rakefile +32 -0
  69. data/sample/book.rb +3 -0
  70. data/sample/config/database.yml +3 -0
  71. data/sample/data/locale/ja/LC_MESSAGES/sample_ar.mo +0 -0
  72. data/sample/db/development.sqlite3 +0 -0
  73. data/sample/db/schema.rb +5 -0
  74. data/sample/locale/ja/LC_MESSAGES/sample_ar.mo +0 -0
  75. data/sample/po/ja/sample_ar.po +29 -0
  76. data/sample/po/sample_ar.pot +29 -0
  77. data/sample/sample.rb +22 -0
  78. data/test/Rakefile +43 -0
  79. data/test/db/migrate.rb +41 -0
  80. data/test/db/sqlite.rb +8 -0
  81. data/test/helper.rb +38 -0
  82. data/test/locale/ja/LC_MESSAGES/active_record.mo +0 -0
  83. data/test/models/book.rb +3 -0
  84. data/test/models/developer.rb +5 -0
  85. data/test/models/inept_wizard.rb +3 -0
  86. data/test/models/reply.rb +40 -0
  87. data/test/models/topic.rb +68 -0
  88. data/test/models/user.rb +3 -0
  89. data/test/models/wizard.rb +5 -0
  90. data/test/po/active_record.pot +388 -0
  91. data/test/po/ja/active_record.po +387 -0
  92. data/test/test_parser.rb +95 -0
  93. data/test/test_validations.rb +2575 -0
  94. data/test/vendor/repair_helper.rb +50 -0
  95. data/test.rb +2 -0
  96. metadata +268 -0
data/COPYING ADDED
@@ -0,0 +1,55 @@
1
+ You can redistribute this program and/or modify it under either the terms of
2
+ the LGPL (see the file LGPL), or the conditions below:
3
+
4
+ 1. You may make and give away verbatim copies of the source form of the
5
+ software without restriction, provided that you duplicate all of the
6
+ original copyright notices and associated disclaimers.
7
+
8
+ 2. You may modify your copy of the software in any way, provided that
9
+ you do at least ONE of the following:
10
+
11
+ a) place your modifications in the Public Domain or otherwise
12
+ make them Freely Available, such as by posting said
13
+ modifications to Usenet or an equivalent medium, or by allowing
14
+ the author to include your modifications in the software.
15
+
16
+ b) use the modified software only within your corporation or
17
+ organization.
18
+
19
+ c) rename any non-standard executables so the names do not conflict
20
+ with standard executables, which must also be provided.
21
+
22
+ d) make other distribution arrangements with the author.
23
+
24
+ 3. You may distribute the software in object code or executable
25
+ form, provided that you do at least ONE of the following:
26
+
27
+ a) distribute the executables and library files of the software,
28
+ together with instructions (in the manual page or equivalent)
29
+ on where to get the original distribution.
30
+
31
+ b) accompany the distribution with the machine-readable source of
32
+ the software.
33
+
34
+ c) give non-standard executables non-standard names, with
35
+ instructions on where to get the original software distribution.
36
+
37
+ d) make other distribution arrangements with the author.
38
+
39
+ 4. You may modify and include the part of the software into any other
40
+ software (possibly commercial). But some files in the distribution
41
+ are not written by the author, so that they are not under these terms.
42
+
43
+ For the list of those files and their copying conditions, see the
44
+ file LEGAL.
45
+
46
+ 5. The scripts and library files supplied as input to or produced as
47
+ output from the software do not automatically fall under the
48
+ copyright of the software, but belong to whomever generated them,
49
+ and may be sold commercially, and may be aggregated with this
50
+ software.
51
+
52
+ 6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
53
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
54
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
55
+ PURPOSE.
data/ChangeLog ADDED
@@ -0,0 +1,4 @@
1
+ = gettext_activerecord-2.0.0 (2009-03-22)
2
+
3
+ * Separated from Ruby-GetText-Package-1.93.0.
4
+ * Support activerecord-2.3.2.
data/README.rdoc ADDED
@@ -0,0 +1,172 @@
1
+ = gettext_activerecord
2
+
3
+ gettext_activerecord provides the localization for ActiveRecord-2.2 or later
4
+ using Ruby-GetText-Package.
5
+
6
+ * Validation messages translation
7
+ * Model translation
8
+ * extract messages from models with the rake task.
9
+
10
+ == Website
11
+ * homepage[http://www.yotabanana.com/hiki/ruby-gettext.html]
12
+ * on rubyforge[http://gettext/rubyforge.org/]
13
+ * on github[http://github.com/gettext_activerecord/]
14
+
15
+ == Requirements
16
+ * {Ruby 1.8.3 or later}[http://www.ruby-lang.org]
17
+ * {Rubygems}[http://www.rubygems.org/]
18
+ * {locale gem}[http://rubyforge.org/projects/locale/]
19
+ * $ gem install locale
20
+ * {gettext gem}[http://rubyforge.org/projects/gettext/]
21
+ * $ gem install gettext
22
+
23
+ == Install
24
+ #Uninstall old gettext if exists.
25
+ (sudo/su on POSIX system)
26
+ gem uninstall gettext
27
+
28
+ #from github (edge/unstable)
29
+ (sudo/su on POSIX system)
30
+ gem install locale
31
+ gem install mutoh-gettext -s http://gems.github.com/
32
+
33
+ #from rubyforge (stable)
34
+ (sudo/su on POSIX system)
35
+ gem install locale
36
+ gem install gettext
37
+
38
+ == Usage
39
+ === without Rails
40
+ ==== Rakefile
41
+ require 'rubygems'
42
+
43
+ desc "Create mo files"
44
+ task :makemo do
45
+ require 'gettext_activerecord/tools'
46
+ GetText.create_mofiles
47
+ end
48
+
49
+ task :updatepo do
50
+ require 'gettext_activerecord/tools'
51
+ # Need to access DB to find Model table/column names.
52
+ # Use config/database.yml which is the same style with rails.
53
+ GetText.update_pofiles("sample_ar", ["topic.rb"], "sample AR 1.0.0")
54
+ end
55
+
56
+ ==== topic.rb
57
+ class Topic < ActiveRecord::Base
58
+ validates_length_of :title, :minimum => 10
59
+ end
60
+
61
+ ==== sample.rb
62
+ require 'gettext_activerecord'
63
+ require 'topic'
64
+
65
+ # Use config/database.yml which is the same style with rails.
66
+ config = YAML.load(IO.read("config/database.yml"))["development"]
67
+ ActiveRecord::Base.establish_connection(config)
68
+
69
+ GetText.bindtextdomain_to(ActiveRecord, "sample_ar", :path => "locale")
70
+
71
+ GetText.set_locale "ja_JP.UTF-8"
72
+ a = Topic.new
73
+ a.title = "Foo"
74
+ a.save
75
+ puts a.errors.full_messages #puts Japanese error message.
76
+
77
+ ==== Then ...
78
+ $ rake updatepo
79
+ $ cd po
80
+ $ mkdir ja
81
+ $ msginit -l ja_JP.UTF-8 -i sample_ar.pot -o ja/sample_ar.po
82
+ $ Edit ja/sample_ar.po
83
+ $ cd ../../
84
+ $ rake makemo
85
+ $ ruby sample.rb
86
+
87
+ === with Rails
88
+ See gettext_rails [http://github.com/mutoh/gettext_rails/tree/master]
89
+
90
+ == Support matrix
91
+ * gettext_activerecord-2.0.0 - rails-2.3.2
92
+
93
+ == License
94
+ This program is licenced under the same licence as Ruby.
95
+ (See the file 'COPYING'.)
96
+
97
+ * Copyright (C) 2001-2009 Masao Mutoh <mutoh at highwhay.ne.jp>
98
+ == Translators
99
+ * Bosnian(bs) - Sanjin Sehic <saserr at gmail.com>
100
+ * Bulgarian(bg) - Sava Chankov <sava.chankov at gmail.com>
101
+ * Catalan(ca) - Ramon Salvadó <rsalvado at gnuine.com>
102
+ * Chinese(Simplified)(zh_CN)
103
+ * Yang Bob <bob.yang.dev at gmail.com> (current)
104
+ * Yingfeng <blogyingfeng at gmail.com>
105
+ * Chinese(Traditional)(zh_TW)
106
+ * Yang Bob <bob.yang.dev at gmail.com> (current)
107
+ * LIN CHUNG-YI <xmarsh at gmail.com>
108
+ * Croatian(hr) - Sanjin Sehic <saserr at gmail.com>
109
+ * Czech(cs) - Karel Miarka <kajism at yahoo.com>
110
+ * Dutch(nl) - Menno Jonkers <ruby-gettext at jonkers.com>
111
+ * Esperanto(eo) - Malte Milatz <malte at gmx-topmail.de>
112
+ * Estonian(et) - Erkki Eilonen <erkki at itech.ee>
113
+ * French(fr)
114
+ * Vincent Isambart <vincent.isambart at gmail.com> (current)
115
+ * David Sulc <davidsulc at gmail.com>
116
+ * David Sulc <davidsulc at gmail.com>
117
+ * Laurent Sansonetti <laurent.sansonetti at gmail.com>
118
+ * German(de)
119
+ * Patrick Lenz <patrick at limited-overload.de> (current)
120
+ * Detlef Reichl <detlef.reichl at gmx.org>
121
+ * Sven Herzberg <herzi at abi02.de>
122
+ * Sascha Ebach <se at digitale-wertschoepfung.de>
123
+ * Greek(el) - Vassilis Rizopoulos <damphyr at gmx.net>
124
+ * Hungarian(hu) - Tamás Tompa <tompata at gmail.com>
125
+ * Italian(it)
126
+ * Marco Lazzeri <marco.lazzeri at gmail.com>
127
+ * Gabriele Renzi <surrender_it at yahoo.it>
128
+ * Japanese(ja) - Masao Mutoh <mutomasa at gmail.com>
129
+ * Korean(ko) - Gyoung-Yoon Noh <nohmad at gmail.com>
130
+ * Latvian(lv) - Aivars Akots <aivars.akots at gmail.com>
131
+ * Norwegian(nb) - Runar Ingebrigtsen <runar at mopo.no>
132
+ * Portuguese(Brazil)(pt_BR)
133
+ * Antonio S. de A. Terceiro <terceiro at softwarelivre.org> (current)
134
+ * Joao Pedrosa <joaopedrosa at gmail.com>
135
+ * Russian(ru) - Yuri Kozlov <kozlov.y at gmail.com>
136
+ * Serbian(sr) - Slobodan Paunović" <slobodan.paunovic at gmail.com>
137
+ * Spanish(es)
138
+ * David Espada <davinci at escomposlinux.org> (current)
139
+ * David Moreno Garza <damog at damog.net>
140
+ * Ukrainian(ua) - Alex Rootoff <rootoff at pisem.net>
141
+ * Vietnamese(vi) - Ngoc Dao Thanh <ngocdaothanh at gmail.com>
142
+
143
+ == Status of translations
144
+ * Bosnian(bs) - 1.90.0 (old)
145
+ * Bulgarian(bg) - 2.0.0
146
+ * Catalan(ca) - 2.0.0
147
+ * Croatian(hr) - 1.90.0 (old)
148
+ * Chinese(zh_CN) - 2.0.0
149
+ * Chinese(zh_TW) - 2.0.0
150
+ * Czech(cs) - 1.9.0 (old)
151
+ * Dutch(nl) - 1.90.0 (old)
152
+ * English(default) - 1.90.0 (old)
153
+ * Esperanto(eo) - 2.0.0
154
+ * Estonian(et) - 2.0.0
155
+ * French(fr) - 2.0.0
156
+ * German(de) - 2.0.0
157
+ * Greek(el) - 2.0.0
158
+ * Hungarian(hu) - 2.0.0
159
+ * Italian(it) - 1.6.0 (old)
160
+ * Japanese(ja) - 2.0.0
161
+ * Korean(ko) - 1.9.0 (old)
162
+ * Latvian(lv) - 2.0.0
163
+ * Norwegian(nb) - 2.0.0
164
+ * Portuguese(Brazil)(pt_BR) - 2.0.0
165
+ * Russian(ru) - 2.0.0
166
+ * Serbian(sr) - 1.91.0 (old)
167
+ * Spanish(es) - 2.0.0
168
+ * Ukrainian(ua) - 2.0.0
169
+ * Vietnamese(vi) - 2.0.0
170
+
171
+ == Maintainer
172
+ Masao Mutoh <mutomasa at gmail.com>
data/Rakefile ADDED
@@ -0,0 +1,110 @@
1
+ #
2
+ # Rakefile for gettext_activerecord.
3
+ #
4
+ # Use setup.rb or gem for installation.
5
+ # You don't need to use this file directly.
6
+ #
7
+ # Copyright(c) 2009 Masao Mutoh
8
+ #
9
+ # This program is licenced under the same licence as Ruby.
10
+ #
11
+
12
+ #make lib and paralel gettext checkout available
13
+ $LOAD_PATH.unshift "./lib"
14
+ gettext_path = File.join(ENV["GETTEXT_PATH"] || "../gettext/", "lib")
15
+ $LOAD_PATH.unshift gettext_path
16
+
17
+ require 'rubygems'
18
+ require 'rake'
19
+ require 'rake/packagetask'
20
+ require 'rake/gempackagetask'
21
+ require 'rake/rdoctask'
22
+
23
+ gettext_path = File.join(ENV["GETTEXT_PATH"] || "../gettext/", "lib")
24
+ $LOAD_PATH.unshift gettext_path
25
+
26
+ require 'gettext_activerecord/version'
27
+
28
+ PKG_VERSION = GetTextActiveRecord::VERSION
29
+
30
+ task :default => [:makemo]
31
+
32
+ ############################################################
33
+ # Manage po/mo files
34
+ ############################################################
35
+ desc "Create *.mo from *.po"
36
+ task :makemo do
37
+ $stderr.puts "Create active_record mo files."
38
+ require 'gettext/tools'
39
+ GetText.create_mofiles
40
+ end
41
+
42
+ desc "Update pot/po files to match new version."
43
+ task :updatepo do
44
+ require 'gettext/tools'
45
+
46
+ GetText.update_pofiles("gettext_activerecord",
47
+ Dir.glob("lib/**/*.rb"),
48
+ "gettext_activerecord #{PKG_VERSION}")
49
+
50
+ end
51
+
52
+ ############################################################
53
+ # Package tasks
54
+ ############################################################
55
+
56
+ desc "Create gem and tar.gz"
57
+ spec = Gem::Specification.new do |s|
58
+ s.name = 'gettext_activerecord'
59
+ s.version = PKG_VERSION
60
+ s.summary = 'Localization support for ActiveRecord by Ruby-GetText-Package.'
61
+ s.author = 'Masao Mutoh'
62
+ s.email = 'mutomasa at gmail.com'
63
+ s.homepage = 'http://gettext.rubyforge.org/'
64
+ s.rubyforge_project = "gettext"
65
+ s.files = FileList['**/*'].to_a.select{|v| v !~ /pkg|git/}
66
+ s.require_path = 'lib'
67
+ s.add_dependency('gettext', '>= 2.0.0')
68
+ s.add_dependency('activerecord', '>= 2.3.2')
69
+ s.has_rdoc = true
70
+ s.description = 'Localization support for ActiveRecord by Ruby-GetText-Package.'
71
+ end
72
+
73
+ Rake::PackageTask.new("gettext_activerecord", PKG_VERSION) do |o|
74
+ o.package_files = FileList['**/*'].to_a.select{|v| v !~ /pkg|git/}
75
+ o.need_tar_gz = true
76
+ o.need_zip = false
77
+ end
78
+
79
+ Rake::GemPackageTask.new(spec) do |p|
80
+ p.gem_spec = spec
81
+ p.need_tar_gz = false
82
+ p.need_zip = false
83
+ end
84
+
85
+ ############################################################
86
+ # Misc tasks
87
+ ############################################################
88
+
89
+ Rake::RDocTask.new { |rdoc|
90
+ allison = `allison --path`.chop
91
+ rdoc.rdoc_dir = 'doc'
92
+ rdoc.title = "gettext_activerecord API Reference"
93
+ rdoc.options << '--line-numbers' << '--inline-source'
94
+ rdoc.rdoc_files.include('README', 'ChangeLog')
95
+ rdoc.rdoc_files.include('lib/**/*.rb')
96
+ rdoc.template = allison if allison.size > 0
97
+ }
98
+
99
+ desc "Publish the release files to RubyForge."
100
+ task :release => [ :package ] do
101
+ require 'rubyforge'
102
+
103
+ rubyforge = RubyForge.new
104
+ rubyforge.configure
105
+ rubyforge.login
106
+ rubyforge.add_release("gettext", "gettext_activerecord",
107
+ PKG_VERSION,
108
+ "pkg/gettext_activerecord-#{PKG_VERSION}.gem",
109
+ "pkg/gettext_activerecord-#{PKG_VERSION}.tar.gz")
110
+ end
@@ -0,0 +1,66 @@
1
+ =begin
2
+ lib/gettext_activerecord/base.rb - GetText for ActiveRecord::Base
3
+
4
+ Copyright (C) 2009 Masao Mutoh
5
+
6
+ You may redistribute it and/or modify it under the same
7
+ license terms as Ruby.
8
+
9
+ $Id$
10
+ =end
11
+
12
+ module ActiveRecord #:nodoc:
13
+ class Base
14
+ include GetText
15
+ include Validations
16
+
17
+ @@gettext_untranslate = Hash.new(false)
18
+ @@gettext_untranslate_columns = {}
19
+
20
+ class << self
21
+ # Untranslate all of the tablename/fieldnames in this model class.
22
+ def untranslate_all
23
+ @@gettext_untranslate[self] = true
24
+ end
25
+
26
+ # Returns true if "untranslate_all" is called. Otherwise false.
27
+ def untranslate_all?
28
+ @@gettext_untranslate[self]
29
+ end
30
+
31
+ # Sets the untranslate columns.
32
+ # (e.g.) untranslate :foo, :bar, :baz
33
+ def untranslate(*w)
34
+ ary = @@gettext_untranslate_columns[self] || []
35
+ ary += w.collect{|v| v.to_s}
36
+ @@gettext_untranslate_columns[self] = ary
37
+ end
38
+
39
+ # Returns true if the column is set "untranslate".
40
+ # (e.g.) untranslate? :foo
41
+ def untranslate?(columnname)
42
+ ary = @@gettext_untranslate_columns[self] || []
43
+ ary.include?(columnname)
44
+ end
45
+
46
+ def untranslate_data #:nodoc:
47
+ [@@gettext_untranslate[self], @@gettext_untranslate_columns[self] || []]
48
+ end
49
+
50
+ def columns_with_gettext_activerecord
51
+ unless defined? @columns
52
+ @columns = nil
53
+ end
54
+ unless @columns
55
+ @columns = columns_without_gettext_activerecord
56
+ @columns.each {|column|
57
+ column.table_class = self
58
+ }
59
+ end
60
+ @columns
61
+ end
62
+ alias_method_chain :columns, :gettext_activerecord
63
+ end
64
+ end
65
+
66
+ end
@@ -0,0 +1,27 @@
1
+ =begin
2
+ lib/gettext_activerecord/i18n.rb - GetText for ActiveRecord's I18n.
3
+
4
+ Copyright (C) 2009 Masao Mutoh
5
+
6
+ You may redistribute it and/or modify it under the same
7
+ license terms as Ruby.
8
+ =end
9
+
10
+ module I18n #:nodoc:
11
+ class << self
12
+ include GetText
13
+ # gettext_activerecord doesn't define backend. So it can be used with another backend.
14
+ def translate_with_gettext_activerecord(key, options = {}) #:nodoc:
15
+ if options[:scope] == [:activerecord, :errors]
16
+ options[:attribute] = key.to_s.split(".")[3]
17
+ options # This value will be used in ActiveRecord::Base::Errors.localize_error_messages
18
+ else
19
+ translate_without_gettext_activerecord(key, options)
20
+ end
21
+ end
22
+ alias_method_chain :translate, :gettext_activerecord #:nodoc:
23
+ alias_method :t_with_gettext_activerecord, :translate_with_gettext_activerecord #:nodoc:
24
+ alias_method_chain :t, :gettext_activerecord #:nodoc:
25
+
26
+ end
27
+ end
@@ -0,0 +1,16 @@
1
+ =begin
2
+ lib/gettext_activerecord/migration.rb - GetText for ActiveRecord::Migration
3
+
4
+ Copyright (C) 2009 Masao Mutoh
5
+
6
+ You may redistribute it and/or modify it under the same
7
+ license terms as Ruby.
8
+
9
+ =end
10
+
11
+ module ActiveRecord #:nodoc:
12
+ class Migration
13
+ extend GetText
14
+ include GetText
15
+ end
16
+ end