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