Skip to content

Commit

Permalink
CheckLocalizations: use NSUserDefaults to read args
Browse files Browse the repository at this point in the history
  • Loading branch information
kainjow committed Jul 10, 2015
1 parent 0d9597c commit 14fe42e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ ci:

check-localizations:
xcrun swiftc -sdk `xcrun --show-sdk-path` -o "$(TMPDIR)/CheckLocalizations" Sparkle/CheckLocalizations.swift
"$(TMPDIR)/CheckLocalizations" . "$(TMPDIR)/LocalizationsReport.htm"
"$(TMPDIR)/CheckLocalizations" -root . -htmlPath "$(TMPDIR)/LocalizationsReport.htm"
open "$(TMPDIR)/LocalizationsReport.htm"
14 changes: 7 additions & 7 deletions Sparkle/CheckLocalizations.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,21 @@ func escapeHTML(str: String) -> String {
die("NSXMLNode failure"); return ""
}

let args = NSProcessInfo.processInfo().arguments
if args.count < 3 {
let ud = NSUserDefaults.standardUserDefaults()
let sparkleRoot = ud.objectForKey("root") as? String
let htmlPath = ud.objectForKey("htmlPath") as? String
if sparkleRoot == nil || htmlPath == nil {
die("Missing arguments")
}
let sparkleRoot = args[1] as! String
let htmlPath = args[2] as! String

let enStringsPath = sparkleRoot + "/Sparkle/en.lproj/Sparkle.strings"
let enStringsPath = sparkleRoot! + "/Sparkle/en.lproj/Sparkle.strings"
let enStringsDict = NSDictionary(contentsOfFile: enStringsPath)
if enStringsDict == nil {
die("Invalid English strings")
}
let enStringsDictKeys = enStringsDict!.allKeys

let dirPath = sparkleRoot + "/Sparkle"
let dirPath = sparkleRoot! + "/Sparkle"
let dirContents = NSFileManager.defaultManager().contentsOfDirectoryAtPath(dirPath, error: nil) as! [String]
let css =
"body { font-family: sans-serif; font-size: 10pt; }" +
Expand Down Expand Up @@ -93,6 +93,6 @@ for dirEntry in dirContents {
html += "</body></html>"

var err: NSError?
if !html.writeToFile(htmlPath, atomically: true, encoding: NSUTF8StringEncoding, error: &err) {
if !html.writeToFile(htmlPath!, atomically: true, encoding: NSUTF8StringEncoding, error: &err) {
die("Can't write report: \(err)")
}

0 comments on commit 14fe42e

Please sign in to comment.