Created
February 5, 2016 06:41
-
-
Save wookay/8762075000583304ee83 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import Foundation | |
class TestTranslate: WTestCase { | |
func test_locales() { | |
let en = NSLocale(localeIdentifier: "en_US") | |
Assert.equal("just now", en.translate("just now")) | |
let ko = NSLocale(localeIdentifier: "ko_KR") | |
Assert.equal("방금", ko.translate("just now")) | |
Assert.equal("1시간 전", ko.translate("%d hours ago", n: 1)) | |
} | |
func test_dates() { | |
Assert.equal("ko", NSLocale.currentLocale().languageCode) | |
let d1 = NSDate(type: .today, hour: 1, min: 0, sec: 0) | |
Assert.equal("just now".translate, d1.since(d1)) | |
Assert.equal("방금", d1.since(d1)) | |
let d2 = NSDate(type: .today, hour: 1, min: 5, sec: 0) | |
Assert.equal("%d mins ago".translate(5), d2.since(d1)) | |
let d3 = NSDate(type: .today, hour: 2, min: 5, sec: 0) | |
Assert.equal("%d hours ago".translate(1), d3.since(d1)) | |
let d4 = NSDate(type: .yesterday, hour: 1, min: 0, sec: 0) | |
Assert.equal("어제", d1.since(d4)) | |
let d5 = NSDate(type: .tomorrow, hour: 1, min: 0, sec: 0) | |
Assert.equal("어제", d5.since(d1)) | |
Assert.equal("미래", d1.since(d5)) | |
} | |
} |
Author
wookay
commented
Feb 5, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment