-
Notifications
You must be signed in to change notification settings - Fork 7
/
Rakefile
33 lines (26 loc) · 881 Bytes
/
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
# frozen_string_literal: true
require "bundler/gem_tasks"
require "rake/testtask"
require "rodauth"
require "yaml"
Rake::TestTask.new(:test) do |t|
t.libs << "test"
t.pattern = "test/**/*_test.rb"
t.warning = false
end
task :import do
translations = {}
Rodauth::Feature.prepend Module.new {
define_method :translatable_method do |meth, value|
super(meth, value)
translations[meth.to_s] = value
end
}
spec = Gem::Specification.find_by_name("rodauth")
features_pattern = File.join(spec.full_gem_path, "lib/rodauth/features/*.rb")
Dir[features_pattern].each { |path| load(path) }
translation_data = { "en" => { "rodauth" => translations.sort.to_h } }
locale_content = YAML.dump(translation_data, line_width: 1000)
locale_content = locale_content.split("\n", 2).last # exclude "---"
File.write("locales/en.yml", locale_content)
end