com.github.houbb.special.chars.test.data.FhdqSpecialTest Maven / Gradle / Ivy
package com.github.houbb.special.chars.test.data;
import com.github.houbb.babel.util.BabelHelper;
import com.github.houbb.heaven.support.handler.IHandler;
import com.github.houbb.heaven.util.io.FileUtil;
import com.github.houbb.heaven.util.lang.StringUtil;
import com.github.houbb.heaven.util.util.CharsetUtil;
import com.github.houbb.heaven.util.util.CollectionUtil;
import org.junit.Ignore;
import org.junit.Test;
import java.util.List;
/**
*
* @author binbin.hou
* @since 0.0.1
*/
@Ignore
public class FhdqSpecialTest {
@Test
public void translateFormatTest() {
final String o = "D:\\github\\special-char\\special-char-test\\src\\main\\resources\\fhdq\\special\\index_v1.txt";
final String t = "D:\\github\\special-char\\special-char-test\\src\\main\\resources\\fhdq\\special\\index_v2.txt";
List lines = FileUtil.readAllLines(o);
lines = CollectionUtil.toList(lines, new IHandler() {
@Override
public String handle(String s) {
boolean isChinese = CharsetUtil.isAllChinese(s);
if(isChinese) {
String en = BabelHelper.translate(s);
return "#" + s + "," + en;
} else {
return s;
}
}
});
FileUtil.write(t, lines);
}
@Test
public void typeEnumTest() {
final String t = "D:\\github\\special-char\\special-char-single\\src\\main\\resources\\special-char-single_bk.txt";
List lines = FileUtil.readAllLines(t);
for(String line : lines) {
if(line.startsWith("#")) {
String zh = line.split(",")[0].replace("#", "");
String en = line.split(",")[1].toLowerCase();
//lower
List enList = StringUtil.splitToList(en, " ");
String inOne = StringUtil.join(enList, "_");
//UPPER_CASE("code", "DESC")
System.out.println(String.format("%s(\"%s\", \"%s\"),",
inOne.toUpperCase(), en, zh));
}
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy