Last active
September 6, 2018 08:13
-
-
Save chumpa/0769454ac0ba3d616a7410d41a289594 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
package io.rsug.sf.sow | |
import groovy.json.StringEscapeUtils | |
import com.ibm.icu.text.Transliterator | |
class Main { | |
static String createGroovyDecl(String unicode) { | |
String x = StringEscapeUtils.escapeJava(unicode) | |
Transliterator toEn = Transliterator.getInstance("Russian-Latin/BGN") | |
String varname = "c" + toEn.transliterate(unicode) | |
"String $varname = \"$x\"" | |
} | |
static main(args) { | |
println createGroovyDecl("Да") | |
println createGroovyDecl("Дни") | |
println createGroovyDecl("Недели") | |
println createGroovyDecl("Месяцы") | |
println createGroovyDecl("Годы") | |
} | |
} | |
/* | |
String cDa = "\u0414\u0430" | |
String cDni = "\u0414\u043D\u0438" | |
String cNedeli = "\u041D\u0435\u0434\u0435\u043B\u0438" | |
String cMesyatsy = "\u041C\u0435\u0441\u044F\u0446\u044B" | |
String cGody = "\u0413\u043E\u0434\u044B" | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Для транслитерации см icu
com.ibm.icu icu4j 61.1Transliterator toLatinTrans = Transliterator.getInstance("Russian-Latin/BGN");
String result = toLatinTrans.transliterate("русское");
System.out.println(result);