Skip to content

Instantly share code, notes, and snippets.

@cybercent
Created December 4, 2014 08:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cybercent/4bf80953d4dba0c5ac9e to your computer and use it in GitHub Desktop.
Save cybercent/4bf80953d4dba0c5ac9e to your computer and use it in GitHub Desktop.
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(/&/,"&amp;")}</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