This repository has been archived by the owner on Jun 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathRakefile
98 lines (83 loc) · 2.34 KB
/
Rakefile
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
require 'peach'
require 'fileutils'
require 'rake/packagetask'
require 'tempfile'
require 'inifile'
task :default => [
# 'php:unit',
# 'jasmine:ci',
]
class PackageTask < Rake::PackageTask
def package_dir_path()
"#{package_dir}/#{@name}"
end
def package_name
@name
end
def basename
@version ? "#{@name}-#{@version}" : @name
end
def tar_bz2_file
"#{basename}.tar.bz2"
end
def tar_gz_file
"#{basename}.tar.gz"
end
def tgz_file
"#{basename}.tgz"
end
def zip_file
"#{basename}.zip"
end
def get_version()
ini = IniFile.load('plugin.ini')
section = ini['info']
version = section['version']
"#{version}"
end
end
PackageTask.new('NeatlineTime') do |p|
p.version = p.get_version()
p.need_tar_gz = true
p.need_zip = true
p.package_files.include('README.md')
p.package_files.include('LICENSE')
p.package_files.include('plugin.*')
p.package_files.include('**/*.php')
p.package_files.include('languages/*')
p.package_files.include('views/**/*.css')
p.package_files.include('views/**/*.gif')
p.package_files.include('views/**/*.js')
p.package_files.include('views/**/*.php')
p.package_files.include('views/**/*.png')
p.package_files.exclude('pkg')
end
desc 'Updates POT files.'
task :update_pot do
files = (Dir["*.{php,phtml}"] + Dir["**/*.{php,phtml}"]).select do |p|
! (p.start_with?("tests/") || p.start_with?("pkg/"))
end
puts files.inspect
lang_dir = "languages"
core_pot = "../../application/languages/Omeka.pot"
pot_file = "#{lang_dir}/template.pot"
pot_base = "#{lang_dir}/template.base.pot"
pot_temp = Tempfile.new(".pot")
pot_temp.close
pot_duplicates = Tempfile.new("-duplicates.pot")
pot_duplicates.close
sh %{xgettext -L php --from-code=utf-8 -k__ --flag=__:1:pass-php-format --omit-header -F -o #{pot_temp.path} #{files.join(' ')}}
sh %{msgcomm --omit-header -o #{pot_duplicates.path} #{pot_temp.path} #{core_pot}}
sh %{msgcomm -u -o #{pot_temp.path} #{pot_temp.path} #{pot_duplicates.path}}
sh %{msgcat -o #{pot_file} #{pot_base} #{pot_temp.path}}
pot_temp.close(true)
pot_duplicates.close(true)
end
desc 'Builds MO files from existing PO files.'
task :build_mo do
files = Dir["languages/*.{po}"]
files.pmap do |filename|
targetfile = filename.sub(/\.po$/,'.mo')
sh %{msgfmt -o #{targetfile} #{filename}}
end
end