Created
December 4, 2014 08:40
-
-
Save cybercent/4bf80953d4dba0c5ac9e to your computer and use it in GitHub Desktop.
This file contains 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