/
thor.rb
33 lines (27 loc) · 1.01 KB
/
thor.rb
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
require 'thor'
require 'cldr'
module Cldr
class Thor < ::Thor
namespace 'cldr'
desc "download [--source=http://unicode.org/Public/cldr/2.0.1/core.zip] [--target=./vendor]",
"Download and extract CLDR data from source to target dir"
method_options %w(source -s) => :string,
%w(target -t) => :string
def download
require 'cldr/download'
Cldr.download(options['source'], options['target'])
end
desc "export [--locales=de fr en] [--components=numbers plurals] [--target=./data] [--merge]",
"Export CLDR data by locales and components to target dir"
method_options %w(locales -l) => :array,
%w(components -l) => :array,
%w(target -t) => :string,
%w(merge -m) => :boolean
def export
$stdout.sync
Cldr::Export.export(options.dup.symbolize_keys) { putc '.' }
puts
end
# TODO flatten task, e.g. flatten all plural locale files into one big file
end
end