diff --git a/Makefile b/Makefile index 6912bdda..b3de3f8f 100644 --- a/Makefile +++ b/Makefile @@ -26,3 +26,7 @@ ci: xcodebuild -sdk "macosx10.$$i" -scheme Distribution -configuration Debug test ; \ fi ; \ done + +check-localizations: + ./Sparkle/CheckLocalizations.swift -root . -htmlPath "$(TMPDIR)/LocalizationsReport.htm" + open "$(TMPDIR)/LocalizationsReport.htm" diff --git a/Sparkle/CheckLocalizations.swift b/Sparkle/CheckLocalizations.swift new file mode 100755 index 00000000..1f751fda --- /dev/null +++ b/Sparkle/CheckLocalizations.swift @@ -0,0 +1,100 @@ +#!/usr/bin/xcrun swift + +import Foundation + +func die(msg: String) { + println("ERROR: \(msg)") + exit(1) +} + +func escapeHTML(str: String) -> String { + if let node = NSXMLNode.textWithStringValue(str) as? NSXMLNode { + return node.XMLString + } + die("NSXMLNode failure"); return "" +} + +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 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 dirContents = NSFileManager.defaultManager().contentsOfDirectoryAtPath(dirPath, error: nil) as! [String] +let css = + "body { font-family: sans-serif; font-size: 10pt; }" + + "h1 { font-size: 12pt; }" + + ".missing { background-color: #FFBABA; color: #D6010E; }" + + ".unused { background-color: #BDE5F8; color: #00529B; }" + + ".unlocalized { background-color: #FEEFB3; color: #9F6000; }" +var html = "\n
\n