Created
July 13, 2017 13:22
-
-
Save rockbruno/354660cba37e5e49163760b1afe4e04f to your computer and use it in GitHub Desktop.
iOS Account Kit script to force localization
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
# 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