Revert "Changed normalized accents code"

This reverts commit 86ce46eb
This commit is contained in:
Peter
2019-07-28 07:52:45 +02:00
parent 86ce46eb4e
commit 92bbda14ac
3 changed files with 27 additions and 22 deletions

View File

@@ -2,16 +2,15 @@
<modelVersion>4.0.0</modelVersion>
<properties>
<android.sdk.path>C:\Users\Peter\AppData\Local\Android\Sdk</android.sdk.path>
<maven.build.timestamp.format>yyyyMMdd-HHmm</maven.build.timestamp.format>
<packaging.type>jar</packaging.type>
<build.min.memory>-Xms4g</build.min.memory>
<build.max.memory>-Xmx8g</build.max.memory>
<build.min.memory>-Xms1024m</build.min.memory>
<build.max.memory>-Xmx1536m</build.max.memory>
<alpha-version>1.6.27.001</alpha-version>
<sign.keystore>C:\Users\Peter\forge.keystore</sign.keystore>
<sign.alias>Forge</sign.alias>
<sign.storepass>parodius</sign.storepass>
<sign.keypass>parodius</sign.keypass>
<sign.keystore>keystore</sign.keystore>
<sign.alias>alias</sign.alias>
<sign.storepass>storepass</sign.storepass>
<sign.keypass>keypass</sign.keypass>
<cardforge.user>user</cardforge.user>
<cardforge.pass>pass</cardforge.pass>
<cardforge.server>ftp.cardforge.org</cardforge.server>

View File

@@ -8,5 +8,4 @@
# project structure.
# Project target.
project.type=0
target=android-25
target=android-20

View File

@@ -7,7 +7,6 @@ import forge.util.LineReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.text.Normalizer;
import java.util.HashMap;
import java.util.Map;
@@ -18,9 +17,17 @@ public class CardTranslation {
public static Map <String, String> translatedoracles;
public static Map <String, String> translatedflavors;
private static String removeDiacritics(String text) {
text = Normalizer.normalize(text, Normalizer.Form.NFD);
text = text.replaceAll("[\\p{InCombiningDiacriticalMarks}]", "");
private static String sanitize(String text) {
text = text.replace("á", "a");
text = text.replace("é", "e");
text = text.replace("í", "i");
text = text.replace("ó", "o");
text = text.replace("ú", "u");
text = text.replace("Á", "A");
text = text.replace("É", "E");
text = text.replace("Í", "I");
text = text.replace("Ó", "O");
text = text.replace("Ú", "U");
text = text.replace("ñ", "ny");
return text;
}
@@ -28,25 +35,25 @@ public class CardTranslation {
private static void readTranslationFile(String language) {
String filename = "cardnames-" + language + ".txt";
try (LineReader translationFile = new LineReader(new FileInputStream(ForgeConstants.LANG_DIR + filename))) {
try (LineReader translationFile = new LineReader(new FileInputStream(ForgeConstants.LANG_DIR + filename));) {
for (String line : translationFile.readLines()) {
String[] matches = line.split("#");
if(matches.length >= 2) {
translatednames.put(matches[0], removeDiacritics(matches[1]));
translatednames.put(matches[0], sanitize(matches[1]));
}
if(matches.length >= 3) {
translatedtypes.put(matches[0], removeDiacritics(matches[2]));
translatedtypes.put(matches[0], sanitize(matches[2]));
}
if(matches.length >= 4) {
translatedoracles.put(matches[0], removeDiacritics(matches[3]).replace("\\n", "\n\n"));
translatedoracles.put(matches[0], sanitize(matches[3]).replace("\\n", "\n\n"));
}
if(matches.length >= 5) {
translatedflavors.put(matches[0], removeDiacritics(matches[4]));
translatedflavors.put(matches[0], sanitize(matches[4]));
}
}
} catch (IOException e) {
@@ -60,10 +67,10 @@ public class CardTranslation {
public static void preloadTranslation(String language) {
if (needsTranslation()) {
translatednames = new HashMap<>();
translatedtypes = new HashMap<>();
translatedoracles = new HashMap<>();
translatedflavors = new HashMap<>();
translatednames = new HashMap<String, String>();
translatedtypes = new HashMap<String, String>();
translatedoracles = new HashMap<String, String>();
translatedflavors = new HashMap<String, String>();
readTranslationFile(ForgePreferences.FPref.UI_LANGUAGE.toString());
}
}