Created
August 3, 2009 17:29
-
-
Save dmerrick/160703 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby -wKU | |
require 'pp' | |
require 'open-uri' | |
# the page that holds the registry (updated often) | |
registry = 'http://www.iana.org/assignments/language-subtag-registry' | |
culture_codes = Hash.new('') | |
current = "" | |
skip_these = %w[%% Added Type Scope Suppress-Script Macrolanguage Deprecated Comments Preferred-Value Macrolanguage Prefix] | |
open(registry) do |file| | |
file.readlines.each do |line| | |
# skip the line if it holds data we dont care about | |
if skip_these.any? {|skip| line =~ /#{skip}/} | |
next | |
# save the culture code of the current locale | |
elsif line =~ /Subtag/ | |
current = line.sub(/Subtag: /,'').chomp.to_sym | |
next | |
else | |
line.sub!(/Description: /,'') | |
culture_codes[current] += line | |
end | |
end | |
end | |
pp culture_codes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment