in lib/twitter_cldr/resources/hyphenation_importer.rb [30:69]
def import_dictionary(path, locale)
options = {}
rules = []
File.foreach(path).with_index do |line, idx|
if options[:encoding]
line.force_encoding(options[:encoding])
line.encode(Encoding::UTF_8)
end
line.strip!
if idx == 0
options[:encoding] = lookup_encoding(line)
next
end
next if line.empty?
next if line.start_with?('%') || line.start_with?('#')
if line =~ /\A[A-Z]+/
option, value = line.split(' ')
options[option.downcase.to_sym] = value
next
end
rules << line
end
options.delete(:encoding)
File.write(
File.join(output_path, "#{locale}.yml"),
YAML.dump({ options: options, rules: rules })
)
end