Created
December 4, 2014 08:40
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
namespace :ios do | |
desc "Export countries plist file" | |
task "countries:plist" => :environment do | |
plist = File.new("Countries.plist", "w") | |
plist.puts <<-eos | |
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
eos | |
I18n.available_locales.each do |locale| | |
I18n.locale = locale | |
plist.puts " <key>#{locale.to_s.first(2)}</key>" | |
plist.puts " <array>" | |
I18n.t("countries").sort.each do |iso, name| | |
plist.puts <<-eos | |
<dict> | |
<key>#{iso.to_s}</key> | |
<string>#{name.gsub(/&/,"&")}</string> | |
</dict> | |
eos | |
end | |
plist.puts " </array>" | |
end | |
plist.puts <<-eos | |
</dict> | |
</plist> | |
eos | |
plist.close | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment