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
|
# File 'lib/i18n_po_tools/cli.rb', line 6
def parse_options(options)
opt_parser = OptionParser.new do |opt|
opt.banner = "Usage: i18n-po [OPTIONS]"
opt.separator ""
opt.separator "Utils to convert translations from source formats to PO/POT Gettex and vise"
opt.separator "versa. It allows to separate translations from development of apps."
opt.separator ""
opt.separator "Supported input/output formats:"
opt.separator "* iOS and OS X String Resources"
opt.separator "* Android String XML"
opt.separator "* Gettext PO/POT"
opt.separator "* Rails YAML"
opt.separator "* Basic flat YAML"
opt.separator "* Java properties"
opt.separator "* CVS for easy exchange with other apps"
opt.separator ""
opt.separator "Direct converation between any formats supported."
opt.separator ""
opt.separator "Rails YAML and PO supports plural forms of messages."
opt.separator ""
opt.separator ""
opt.separator "Options"
opt.on("-i","--input FILENAME","input filename (default STDIN)") do |input_filename|
options[:input_filename] = input_filename
end
opt.on("-b","--base FILENAME","base language input filename (only for po output mode)") do |base_filename|
options[:base_filename] = base_filename
end
opt.on("-o","--output FILENAME","output filename (default STDOUT)") do |output_filename|
options[:output_filename] = output_filename
end
opt.on("-f","--from FORMAT", FORMATS, "input file format (default is autodetect by ext)", "(#{FORMATS.join(', ')})") do |input_format|
options[:input_format] = input_format
end
opt.on("-t","--to FORMAT", FORMATS, "output file format (default is autodetect by ext)", "(#{FORMATS.join(', ')})") do |output_format|
options[:output_format] = output_format
end
opt.on("-l","--language LANGUAGE","input file language (only for po or rails_yaml output mode)") do |language|
options[:language] = language
end
opt.on("-h","--help","help") do
puts opt_parser
exit(0)
end
opt.separator ""
opt.separator "Examples:"
opt.separator "1) First import (generation of PO file) from Rails YAML file:"
opt.separator "i18n-po --input ~/projects/rails_app/config/locales/devise.en.yml --language en \\"
opt.separator " --base ~/projects/rails_app/config/locales/devise.ru.yml \\"
opt.separator " --output ~/projects/translations/rails_app/devise.en.po"
opt.separator ""
opt.separator "2) Generation of translation template (POT file) from Rails YAML file:"
opt.separator "i18n-po --input ~/projects/rails_app/config/locales/devise.ru.yml \\"
opt.separator " --output ~/projects/translations/rails_app/devise.en.pot"
opt.separator ""
opt.separator "3) Generation of Rails YAML file from PO file:"
opt.separator "i18n-po --input ~/projects/translations/rails_app/devise.en.po --language en \\"
opt.separator " --output ~/projects/rails_app/config/locales/devise.en.yml"
opt.separator ""
opt.separator "4) Translation convertation from iOS to Android format:"
opt.separator "i18n-po --input ~/projects/ios_app/Localizable.strings \\"
opt.separator " --output ~/projects/android_app/en/strings.xml"
opt.separator ""
opt.separator "Homepage: http://github.com/stepin/i18n-po-tools"
opt.separator ""
end
opt_parser.parse!
if options.count == 0
puts opt_parser
exit(1)
end
end
|