mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-14 09:48:02 +00:00
Changed delimiter from # to | (reminder texts fixed).
Python script now downloads the big json file from scryfall. Updated spanish and deutsch translations
This commit is contained in:
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -22,7 +22,7 @@ public class CardTranslation {
|
||||
|
||||
try (LineReader translationFile = new LineReader(new FileInputStream(ForgeConstants.LANG_DIR + filename), Charsets.UTF_8)) {
|
||||
for (String line : translationFile.readLines()) {
|
||||
String[] matches = line.split("#");
|
||||
String[] matches = line.split("\\|");
|
||||
if (matches.length >= 2) {
|
||||
translatednames.put(matches[0], matches[1]);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,19 @@
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import urllib.request
|
||||
|
||||
database = 'scryfall-all-cards.json'
|
||||
scryfalldburl = 'https://archive.scryfall.com/json/' + database
|
||||
languages = ['es', 'de']
|
||||
|
||||
urllib.request.urlretrieve(scryfalldburl, database)
|
||||
|
||||
def oracleformat(oracle):
|
||||
oracle = re.sub(r"[)]([A-Z,{,•,-])", ")\n\1", toracle)
|
||||
oracle = re.sub(r"(.)[\.]([A-Z,{,•,-])", "\1.\n\2", toracle)
|
||||
return oracle
|
||||
|
||||
with open(database, mode='r', encoding='utf8') as json_file:
|
||||
data = json.load(json_file)
|
||||
|
||||
@@ -36,15 +46,13 @@ with open(database, mode='r', encoding='utf8') as json_file:
|
||||
except:
|
||||
pass
|
||||
|
||||
output = name + '#' + tname + '#' + ttype
|
||||
output = name + '|' + tname + '|' + ttype
|
||||
|
||||
# Format oracle
|
||||
if toracle != "":
|
||||
toracle = toracle.replace('"', '“')
|
||||
toracle = toracle.replace('(', '#(')
|
||||
toracle = toracle.replace(')', ')#')
|
||||
toracle = oracleformat(toracle)
|
||||
|
||||
output = output + '#' + toracle
|
||||
output = output + '|' + toracle
|
||||
output = output.replace('\n', '\\n')
|
||||
|
||||
if card['lang'] == 'es':
|
||||
@@ -100,15 +108,13 @@ with open(database, mode='r', encoding='utf8') as json_file:
|
||||
|
||||
# Output Card0
|
||||
|
||||
output0 = name0 + '#' + tname0 + '#' + ttype0
|
||||
output0 = name0 + '|' + tname0 + '|' + ttype0
|
||||
|
||||
# Format oracle for card0
|
||||
if toracle0 != "":
|
||||
toracle0 = toracle0.replace('"', '“')
|
||||
toracle0 = toracle0.replace('(', '#(')
|
||||
toracle0 = toracle0.replace(')', ')#')
|
||||
toracle0 = oracleformat(toracle0)
|
||||
|
||||
output0 = output0 + '#' + toracle0
|
||||
output0 = output0 + '|' + toracle0
|
||||
output0 = output0.replace('\n', '\\n')
|
||||
|
||||
if card['lang'] == 'es':
|
||||
@@ -118,15 +124,13 @@ with open(database, mode='r', encoding='utf8') as json_file:
|
||||
|
||||
# Output Card1
|
||||
|
||||
output1 = name1 + '#' + tname1 + '#' + ttype1
|
||||
output1 = name1 + '|' + tname1 + '|' + ttype1
|
||||
|
||||
# Format oracle for card0
|
||||
if toracle1 != "":
|
||||
toracle1 = toracle1.replace('"', '“')
|
||||
toracle1 = toracle1.replace('(', '#(')
|
||||
toracle1 = toracle1.replace(')', ')#')
|
||||
toracle1 = oracleformat(toracle1)
|
||||
|
||||
output1 = output1 + '#' + toracle1
|
||||
output1 = output1 + '|' + toracle1
|
||||
output1 = output1.replace('\n', '\\n')
|
||||
|
||||
if card['lang'] == 'es':
|
||||
@@ -141,7 +145,7 @@ with open(database, mode='r', encoding='utf8') as json_file:
|
||||
names_seen = set()
|
||||
outfile = open("cardnames-es-ES.txt", "w", encoding='utf8')
|
||||
for line in open("cardnames-es-ES.tmp", "r", encoding='utf8'):
|
||||
name = line.split('#')[0]
|
||||
name = line.split('|')[0]
|
||||
if name not in names_seen:
|
||||
outfile.write(line)
|
||||
names_seen.add(name)
|
||||
@@ -152,7 +156,7 @@ os.remove("cardnames-es-ES.tmp")
|
||||
names_seen = set()
|
||||
outfile = open("cardnames-de-DE.txt", "w", encoding='utf8')
|
||||
for line in open("cardnames-de-DE.tmp", "r", encoding='utf8'):
|
||||
name = line.split('#')[0]
|
||||
name = line.split('|')[0]
|
||||
if name not in names_seen:
|
||||
outfile.write(line)
|
||||
names_seen.add(name)
|
||||
|
||||
Reference in New Issue
Block a user