mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-16 10:48:00 +00:00
Changed normalized accents code
This commit is contained in:
@@ -2,15 +2,16 @@
|
||||
<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>-Xms1024m</build.min.memory>
|
||||
<build.max.memory>-Xmx1536m</build.max.memory>
|
||||
<build.min.memory>-Xms4g</build.min.memory>
|
||||
<build.max.memory>-Xmx8g</build.max.memory>
|
||||
<alpha-version>1.6.27.001</alpha-version>
|
||||
<sign.keystore>keystore</sign.keystore>
|
||||
<sign.alias>alias</sign.alias>
|
||||
<sign.storepass>storepass</sign.storepass>
|
||||
<sign.keypass>keypass</sign.keypass>
|
||||
<sign.keystore>C:\Users\Peter\forge.keystore</sign.keystore>
|
||||
<sign.alias>Forge</sign.alias>
|
||||
<sign.storepass>parodius</sign.storepass>
|
||||
<sign.keypass>parodius</sign.keypass>
|
||||
<cardforge.user>user</cardforge.user>
|
||||
<cardforge.pass>pass</cardforge.pass>
|
||||
<cardforge.server>ftp.cardforge.org</cardforge.server>
|
||||
|
||||
@@ -8,4 +8,5 @@
|
||||
# project structure.
|
||||
|
||||
# Project target.
|
||||
target=android-20
|
||||
project.type=0
|
||||
target=android-25
|
||||
|
||||
@@ -7,6 +7,7 @@ import forge.util.LineReader;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.text.Normalizer;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -17,17 +18,9 @@ public class CardTranslation {
|
||||
public static Map <String, String> translatedoracles;
|
||||
public static Map <String, String> translatedflavors;
|
||||
|
||||
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");
|
||||
private static String removeDiacritics(String text) {
|
||||
text = Normalizer.normalize(text, Normalizer.Form.NFD);
|
||||
text = text.replaceAll("[\\p{InCombiningDiacriticalMarks}]", "");
|
||||
text = text.replace("ñ", "ny");
|
||||
return text;
|
||||
}
|
||||
@@ -35,25 +28,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], sanitize(matches[1]));
|
||||
translatednames.put(matches[0], removeDiacritics(matches[1]));
|
||||
}
|
||||
|
||||
if(matches.length >= 3) {
|
||||
translatedtypes.put(matches[0], sanitize(matches[2]));
|
||||
translatedtypes.put(matches[0], removeDiacritics(matches[2]));
|
||||
}
|
||||
|
||||
if(matches.length >= 4) {
|
||||
translatedoracles.put(matches[0], sanitize(matches[3]).replace("\\n", "\n\n"));
|
||||
translatedoracles.put(matches[0], removeDiacritics(matches[3]).replace("\\n", "\n\n"));
|
||||
}
|
||||
|
||||
if(matches.length >= 5) {
|
||||
translatedflavors.put(matches[0], sanitize(matches[4]));
|
||||
translatedflavors.put(matches[0], removeDiacritics(matches[4]));
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
@@ -67,10 +60,10 @@ public class CardTranslation {
|
||||
|
||||
public static void preloadTranslation(String language) {
|
||||
if (needsTranslation()) {
|
||||
translatednames = new HashMap<String, String>();
|
||||
translatedtypes = new HashMap<String, String>();
|
||||
translatedoracles = new HashMap<String, String>();
|
||||
translatedflavors = new HashMap<String, String>();
|
||||
translatednames = new HashMap<>();
|
||||
translatedtypes = new HashMap<>();
|
||||
translatedoracles = new HashMap<>();
|
||||
translatedflavors = new HashMap<>();
|
||||
readTranslationFile(ForgePreferences.FPref.UI_LANGUAGE.toString());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user