Last active
March 28, 2020 01:32
-
-
Save rockpunk/4fc315a8fff0b1d980ae95ad63230a14 to your computer and use it in GitHub Desktop.
generate a proto enum from JVM locales
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 java.util.Locale | |
import java.io._ | |
val w = new BufferedWriter(new FileWriter(new File("/tmp/test.proto"))) | |
w.write("enum Language {\n") | |
("unknown" +: Locale.getISOLanguages).zipWithIndex.foreach { x=> | |
w.write(f" ${x._1.toUpperCase} = ${x._2}; // ${Locale.forLanguageTag(x._1).getDisplayLanguage}\n") } | |
w.write("}\n"); | |
w.close |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment