Skip to content

Instantly share code, notes, and snippets.

@rockbruno
Created July 13, 2017 13:22
Show Gist options
  • Save rockbruno/354660cba37e5e49163760b1afe4e04f to your computer and use it in GitHub Desktop.
Save rockbruno/354660cba37e5e49163760b1afe4e04f to your computer and use it in GitHub Desktop.
iOS Account Kit script to force localization
# Bruno Rocha
# Add this file to your {SRCROOT}/bin, change ptProj to your desired locale
# and then add a Run Script at Xcode with this:
# ruby $SRCROOT/bin/AccountKitForceLocalization.rb
require 'find'
require 'uri'
require 'fileutils'
$scriptPath = File.dirname(__FILE__)
$akPath = $scriptPath + '/../Pods/AccountKit/AccountKitStrings.bundle/Resources/'
$ptProj = "pt.lproj"
$enProj = "en.lproj"
def changesAreNecessary
count = 0
Find.find($akPath) { |e|
if File.directory?(e) && e[-1, 1] != "/" && URI(e).path.split('/').last != $ptProj then
count += 1
if count > 1 then
return true
end
end
}
return false
end
def deleteLocalizations()
Find.find($akPath) { |e|
if File.directory?(e) && e[-1, 1] != "/" && URI(e).path.split('/').last != $ptProj then
FileUtils.remove_dir(e)
end
}
FileUtils.mv($akPath + $ptProj, $akPath + $enProj)
end
if changesAreNecessary then
puts "AccountKit Tool: Pod installation changed, deleting localizations..."
deleteLocalizations()
else
puts "AccountKit Tool: No changes are needed."
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment