mutoh / gettext_rails

Ruby on Rails (>=2.3) localization support with Ruby-GetText-Package.

This URL has Read+Write access

gettext_rails / Rakefile
100644 131 lines (107 sloc) 3.5 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#
# Rakefile for gettext_rails.
#
# Use setup.rb or gem for installation.
# You don't need to use this file directly.
#
# Copyright(c) 2009 Masao Mutoh
#
# This program is licenced under the same licence as Ruby.
#
 
#make lib and paralel gettext checkout available
$LOAD_PATH.unshift "./lib"
gettext_path = File.join(ENV["GETTEXT_PATH"] || "../gettext/", "lib")
$LOAD_PATH.unshift gettext_path
 
require 'rubygems'
require 'rake'
require 'rake/packagetask'
require 'rake/gempackagetask'
require 'rake/rdoctask'
 
gettext_path = File.join(ENV["GETTEXT_PATH"] || "../gettext/", "lib")
$LOAD_PATH.unshift gettext_path
 
require 'gettext_rails/version'
 
PKG_VERSION = GetTextRails::VERSION
 
############################################################
# Manage po/mo files
############################################################
desc "Create *.mo from *.po"
task :makemo do
  $stderr.puts "Create active_record mo files."
  require 'gettext/tools'
  GetText.create_mofiles
 
  $stderr.puts "Create sample mo files."
  GetText.create_mofiles(:po_root => "sample/po",
                         :mo_root => "sample/locale")
 
  $stderr.puts "Create samples/rails plugin mo files."
  GetText.create_mofiles(:po_root => "sample/vendor/plugins/lang_helper/po",
                         :mo_root => "sample/vendor/plugins/lang_helper/locale")
 
  cd "test"
  sh "rake makemo"
  cd ".."
end
 
desc "Update pot/po files to match new version."
task :updatepo do
  require 'gettext/tools'
 
  GetText.update_pofiles("gettext_rails",
Dir.glob("lib/**/*.rb"),
"gettext_rails #{PKG_VERSION}")
 
end
 
 
############################################################
# Package tasks
############################################################
 
desc "Create gem and tar.gz"
spec = Gem::Specification.new do |s|
  s.name = 'gettext_rails'
  s.version = PKG_VERSION
  s.summary = 'Localization support for Ruby on Rails(>=2.3) by Ruby-GetText-Package.'
  s.author = 'Masao Mutoh'
  s.email = 'mutomasa at gmail.com'
  s.homepage = 'http://gettext.rubyforge.org/'
  s.rubyforge_project = "gettext"
  s.files = FileList['**/*'].to_a.select{|v| v !~ /pkg|git/}
  s.add_dependency('gettext_activerecord', '>= 2.0.4')
  s.add_dependency('locale_rails', '>= 2.0.4')
  s.add_dependency('rails', '>= 2.3.2')
  s.require_path = 'lib'
  s.has_rdoc = true
  s.description = 'Localization support for Ruby on Rails(>=2.3.2) by Ruby-GetText-Package.'
end
 
Rake::GemPackageTask.new(spec) do |p|
  p.gem_spec = spec
  p.need_tar_gz = false
  p.need_zip = false
end
 
task :package => [:makemo]
 
############################################################
# Misc tasks
############################################################
 
Rake::RDocTask.new { |rdoc|
  begin
    allison = `allison --path`.chop
  rescue
    allison = ''
  end
  rdoc.rdoc_dir = 'doc'
  rdoc.title = "gettext_rails API Reference"
  rdoc.options << '--line-numbers' << '--inline-source'
  rdoc.rdoc_files.include('README.rdoc', 'ChangeLog')
  rdoc.rdoc_files.include('lib/**/*.rb')
  rdoc.template = allison if allison.size > 0
}
 
desc "Publish the release files to RubyForge."
task :release => [ :package ] do
  require 'rubyforge'
 
  rubyforge = RubyForge.new
  rubyforge.configure
  rubyforge.login
  rubyforge.add_release("gettext", "gettext_rails",
                        PKG_VERSION,
                        "pkg/gettext_rails-#{PKG_VERSION}.gem")
end
 
# Run the unit tests
desc 'Run tests'
task :test do
  cd "test"
  sh $0 + " test"
  cd ".."
end