Skip to content

Instantly share code, notes, and snippets.

@Nub
Created June 13, 2014 17:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Nub/985e3cda8c7e56d7f54f to your computer and use it in GitHub Desktop.
Save Nub/985e3cda8c7e56d7f54f to your computer and use it in GitHub Desktop.
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