Skip to content

Instantly share code, notes, and snippets.

@propensive

propensive/translate.scala Secret

Created Apr 12, 2015
Embed
What would you like to do?
Welcome to Scala version 2.10.5 (OpenJDK 64-Bit Server VM, Java 1.6.0_27).
Type in expressions to have them evaluated.
Type :help for more information.
scala> import rapture.i18n._
import rapture.i18n._
scala> type IString = I18n[String, En with Fr with De with Pl with La] // English, French, German, Polish, Latin
defined type alias IString
scala> val msg: IString = en"Hello, world!"
<console>:11: error: Some language translations were not provided: fr, la, de, pl
val msg: IString = en"Hello, world!"
^
scala> import rapture.translate._
import rapture.translate._
scala> val msg: IString = en"Hello, world!"
<console>:14: error: Not all required language translations have been provided. Consider appending the following translations to the expression:
| fr"Bonjour le monde!" | la"Salve, mundi!" | de"Hallo Welt!" | pl"Witaj świecie!"
val msg: IString = en"Hello, world!"
^
scala> val msg: IString = en"Hello, world!" | fr"Bonjour le monde!" | la"Salve, mundi!" | de"Hallo Welt!" | pl"Witaj świecie!"
msg: IString = fr|la|de|en|pl:Hello, world!
scala> msg[De]
res0: String = Hallo Welt!
scala> msg[La]
res1: String = Salve, mundi!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment