background
- In /dominion, sometimes I write about a card by looking at the English text and sometimes by looking at the Japanese text, and I want both links to be connected.
- After making a few by hand, I settled on âput the Japanese card name in the titleâ and âput a link to the English name in the body textâ.
- If this is not done for the remaining hundreds, the benefit of âconnecting in both Japanese and Englishâ will not be achieved.
- I donât want to do it manually, so Iâll generate it mechanically.
- I donât want to overwrite something hand-crafted with something machine-generated.
- It has not been determined whether or not to add to what is already there, so I will add it anyway.
mounting
- First, export the current project with updated date and time
- See the Eiwa list.
- If you already have a page, add it.
- If not, create and add an older date.
python
import json
import from_enwiki
data = json.load(open('dominion.json'))
titles = [p["title"] for p in data["pages"]]
OLD = 946652400.0 # 2000-01-01
for line in open("jaen.txt"):
ja, en = line.strip().split("\t")
# generate contents
lines = from_enwiki.parse(en)
lines += ["", f""[Dominion Wiki https://wikiwiki.jp/dominiondeck/{en}]"]
if ja in titles:
print("exists", ja, en)
for page in data["pages"]:
if page["title"] == ja:
page["lines"] += lines
else:
page = dict(
title=ja,
lines=[ja] + lines,
updated=OLD)
data["pages"].append(page)
json.dump(data, open("dominion_new.json", "w"), indent=2)
This page is auto-translated from /nishio/Scrapboxă§æ©æą°çć çăăă using DeepL. If you looks something interesting but the auto-translated English is not good enough to understand it, feel free to let me know at @nishio_en. Iâm very happy to spread my thought to non-Japanese readers.