Created
July 14, 2015 17:48
-
-
Save KatrinaHoffert/d336f800ae9dd574fd34 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
object Language { | |
def langs: Try[Seq[Language]] = { | |
Try { val m = for { | |
l<- current.configuration.getConfig("langs") | |
a <- l.getConfig("mapping") | |
} yield a | |
m.get.keys.map { c=>Language(c, m.get.getString(c).get)}.toList.sortBy(_.c)} | |
}} |
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
object Language { | |
/** | |
* Gets a list of all languages supported from the configuration file. The "langs.mapping" field | |
* is a JSON object with keys as 2 character country codes and the values as full, native language | |
* names. | |
*/ | |
def getSupportedLanguages: Try[Seq[Language]] = { | |
Try { | |
val languageMappings = for { | |
langs <- current.configuration.getConfig("langs") | |
mapping <- langs.getConfig("mapping") | |
} yield mapping | |
val countryCodes = languageMappings.get.keys | |
countryCodes.map { code => | |
Language(code, languageMappings.get.getString(code).get) | |
}.toList.sortBy(_.code) | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment