Created
June 13, 2014 17:39
-
-
Save Nub/985e3cda8c7e56d7f54f to your computer and use it in GitHub Desktop.
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
struct LocalizedString: StringInterpolationConvertible, StringLiteralConvertible { | |
typealias StringLiteralType = String | |
typealias ExtendedGraphemeClusterLiteralType = String | |
var s:String | |
init(_ string: String) { | |
s = string | |
} | |
static func convertFromExtendedGraphemeClusterLiteral(value: ExtendedGraphemeClusterLiteralType) -> LocalizedString { | |
return LocalizedString(String.convertFromExtendedGraphemeClusterLiteral(value)) | |
} | |
static func convertFromStringLiteral(value: String) -> LocalizedString { | |
return LocalizedString(String.convertFromStringLiteral(value)) | |
} | |
static func convertFromStringInterpolation(strings: LocalizedString...) -> LocalizedString { | |
var string: String = String() | |
for s in strings { | |
string += "\"\(s.s)\"" | |
} | |
return LocalizedString(string) | |
} | |
static func convertFromStringInterpolationSegment<T>(expr: T) -> LocalizedString { | |
return LocalizedString(String.convertFromStringInterpolationSegment(expr)) | |
} | |
} | |
var v:LocalizedString = "12\(1+4)1💩" | |
println(v.s) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment