Skip to content

Commit

Permalink
Rewrite project to be more manageable
Browse files Browse the repository at this point in the history
  • Loading branch information
Jackson-S authored Aug 9, 2019
1 parent fadba82 commit df75d04
Show file tree
Hide file tree
Showing 35 changed files with 2,401 additions and 3,004,600 deletions.
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# JMdict Japanese Dictionary for MacOS
A Japanese -> English dictionary for the Dictionary app in MacOS based off JMdict
# Japanese Dictionary for MacOS
A Japanese -> English dictionary for the Dictionary app in MacOS based off JMdict, Kanjidic2 and KanjiVG

![](/screenshots/a.png)
![](/screenshots/b.png)
Expand All @@ -13,4 +13,18 @@ These files are the property of the
Research and Development Group</a>, and are used in
conformance with the Group's
<a href="http://www.edrdg.org/edrdg/licence.html">licence</a>.
</p>
<p>
The example sentences in this dictionary are provided by
<a href="https://tatoeba.org/eng/downloads">Tatoeba.org</a>
under the
<a href="https://creativecommons.org/licenses/by/2.0/fr/">Creative Common Attribution 2.0 France</a>
(CC BY 2.0 FR) license.
</p>
<p>
The kanji samples in this dictionary are provided by
<a href="https://kanjivg.tagaini.net/">KanjiVG</a>
under the
<a href="https://creativecommons.org/licenses/by-sa/3.0/">Creative Common Attribution-ShareAlike 3.0 Unported</a>
(CC BY-SA 3.0) license and are copyright © 2009-2018 Ulrich Apel.
</p>
20 changes: 0 additions & 20 deletions argument_parser.py

This file was deleted.

2 changes: 1 addition & 1 deletion project/Makefile → assets/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ CSS_PATH = JapaneseDictionary.css
PLIST_PATH = JapaneseDictionary.plist
IMAGE_PATH = "OtherResources/Images"

DICT_BUILD_OPTS = -v 10.6
DICT_BUILD_OPTS = #-v 10.6
# Suppress adding supplementary key.
# DICT_BUILD_OPTS = -s 0 # Suppress adding supplementary key.

Expand Down
83 changes: 83 additions & 0 deletions assets/definition_page.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<body>
<section id="header">
<h1 id="page_title">{{ entry.page_title }}</h1>
</section>

<section id="sub_header">
{% if entry.readings | count > 0 or entry.kanji | count > 1 %}
<section id="readings">
{% if entry.readings | count > 0 %}
<section id="onyomi">
<h3 class="section_heading" apple_mouseover_disable="1">Readings</h3>
{% for reading in entry.readings %}
<div class="reading">
<p>{{ reading.text }}</p>
{% for info in reading.info %}
<div class="badge">{{ info }}</div>
{% endfor %}
</div>
{% endfor %}
</section>
{% endif %}

{% if entry.kanji | count > 1 %}
<section id="alt_kanji">
<h3 class="section_heading" apple_mouseover_disable="1">Alternate Kanji</h3>
{% for kanji in entry.kanji[1:] %}
<div class="reading">
<p>{{ kanji.text }}</p>
{% for info in kanji.info %}
<div class="badge">{{ info }}</div>
{% endfor %}
</div>
{% endfor %}
</section>
{% endif %}
</section>
{% endif %}

{% if entry.containing_kanji | count > 0 %}
<section id="containing_kanji">
<h3 class="section_heading" apple_mouseover_disable="1">Kanji in this Term</h3>
{% for kanji in entry.containing_kanji %}
<a href="x-dictionary:r:jp_kanji_{{ kanji }}">{{ kanji }}</a>
{% endfor %}
</section>
{% endif %}

{% if entry.sentences | count > 0 %}
<details id="sentences">
<summary class="section_heading" apple_mouseover_disable="1">Example Sentences</summary>
{% for sentence in entry.sentences %}
<article class="sentence">
<p>{{ sentence.japanese }}</p>
<p>{{ sentence.english }}</p>
</article>
{% endfor %}
</details>
{% endif %}
</section>

<section id="definitions">
<h3 class="section_heading" apple_mouseover_disable="1">Definitions</h3>
{% for definition in entry.definitions %}
<article>
<p class="number" apple_mouseover_disable="1">{{ loop.index }}</p>
<div class="translation_line">
{% for translation in definition.translations %}
{% if loop.last %}
<p class="translation">{{ translation }}</p>
{% else %}
<p class="translation">{{ translation }},</p>
{% endif %}
{% endfor %}
</div>
<div class="badges">
{% for pos in definition.pos %}
<div class="badge">{{ pos }}</div>
{% endfor %}
</div>
</article>
{% endfor %}
</section>
</body>
4 changes: 2 additions & 2 deletions project/JapaneseDictionary.plist → assets/info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleIdentifier</key>
<string>com.jackson-s.jmdict</string>
<string>com.jackson-s.japanesedictionary</string>
<key>CFBundleName</key>
<string>Japanese - English</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>DCSDictionaryManufacturerName</key>
<string>JMDict</string>
<string>Japanese Dictionary</string>
<key>DCSDictionaryPrefsHTML</key>
<string>JapaneseDictionary_prefs.html</string>
<key>DCSDictionaryUseSystemAppearance</key>
Expand Down
73 changes: 73 additions & 0 deletions assets/kanji_page.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<body>
<section id="header">
<h1 id="page_title">{{ entry.page_title }}</h1>
</section>

<section id="sub_header">

{% if entry.on_yomi | count > 0 and entry.kun_yomi | count > 0 %}
<section id="readings">

{% if entry.on_yomi | count > 0 %}
<section id="onyomi">
<h3 class="section_heading" apple_mouseover_disable="1">On-Yomi</h3>
{% for reading in entry.on_yomi %}
<div class="reading">
<p>{{ reading }}</p>
</div>
{% endfor %}
</section>
{% endif %}

{% if entry.kun_yomi | count > 0 %}
<section id="kunyomi">
<h3 class="section_heading" apple_mouseover_disable="1">Kun-Yomi</h3>
{% for reading in entry.kun_yomi %}
<div class="reading">
<p>{{ reading }}</p>
</div>
{% endfor %}
</section>
{% endif %}

</section>
{% endif %}

{% if entry.nanor | count > 0 %}
<details id="nanori">
<summary class="section_heading" apple_mouseover_disable="1">Nanori</summary>
{% for reading in entry.nanori %}
{% if loop.last %}
<p>{{ reading }}</p>
{% else %}
<p>{{ reading }}、</p>
{% endif %}
{% endfor %}
</details>
{% endif %}


<details id="stroke_order">
<summary class="section_heading" apple_mouseover_disable="1">Stroke Order</summary>
<img src="Images/{{ entry.image }}" />
</details>
</section>

<section id="definitions">
<h3 class="section_heading" apple_mouseover_disable="1">Definitions</h3>
{% for definition in entry.definitions %}
<article>
<p class="number" apple_mouseover_disable="1">{{ loop.index }}</p>
<div class="translation_line">
{% for translation in definition %}
{% if loop.last %}
<p class="translation">{{ translation }}</p>
{% else %}
<p class="translation">{{ translation }},</p>
{% endif %}
{% endfor %}
</div>
</article>
{% endfor %}
</section>
</body>
Binary file renamed kanji_vg.zip → assets/kanjivg.zip
Binary file not shown.
12 changes: 12 additions & 0 deletions ...erResources/JapaneseDictionary_prefs.html → assets/prefs.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,18 @@
Research and Development Group</a>, and are used in
conformance with the Group's
<a href="http://www.edrdg.org/edrdg/licence.html">licence</a>.

The example sentences in this dictionary are provided by
<a href="https://tatoeba.org/eng/downloads">Tatoeba.org</a>
under the
<a href="https://creativecommons.org/licenses/by/2.0/fr/">Creative Common Attribution 2.0 France</a>
(CC BY 2.0 FR) license.

The kanji samples in this dictionary are provided by
<a href="https://kanjivg.tagaini.net/">KanjiVG</a>
under the
<a href="https://creativecommons.org/licenses/by-sa/3.0/">Creative Common Attribution-ShareAlike 3.0 Unported</a>
(CC BY-SA 3.0) license and are copyright © 2009-2018 Ulrich Apel.
</div>
</body>
</html>
130 changes: 130 additions & 0 deletions assets/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
@charset "UTF-8";
@namespace d url(http://www.apple.com/DTDs/DictionaryService-1.0.rng);

d|entry {
}

p {
margin: 0px 0;
width: min-content;
white-space: nowrap;
}

summary {
cursor: pointer !important;
}

#header, #sub_header, #definitions {
max-width: 600px;
}

#sub_header {
display: grid;
grid-gap: 10px;
}

#sub_header > details, #sub_header > section {
background-color: rgba(230,230,230,100);
padding: 10px;
border-radius: 5px;
}

#sub_header > #readings {
display: grid;
grid-template-columns: 1fr 1fr;
}

.section_heading {
cursor: default;
font-size: small;
font-weight: normal;
margin: 2px 0;
}

#sub_header > #nanori > p {
display: inline-block;
}

#sub_header > #readings .reading {
display: flex;
}

#sub_header > #readings .reading > p {
margin-right: 10px;
}

#sub_header > #stroke_order img {
width: 100%;
}

#definitions {
border: 1px solid lightgrey;
margin: 10px 0;
border-radius: 5px;
}

#definitions h3 {
padding: 10px 0 0 10px;
margin: 0;
font-size: medium;
font-weight: normal;
}

#definitions > article {
display: grid;
grid-template-columns: min-content 1fr min-content;
grid-gap: 10px;
margin: 10px;
padding-bottom: 5px;
border-bottom: dotted 1.5px lightgray;
}

#definitions > article:last-of-type {
border-bottom: none;
}

#definitions .translation_line > p {
display: inline-block;
}

#definitions .number {
grid-column: 1;
font-size: smaller;
align-self: center;
color: grey;
}

#definitions .badges {
display: flex;
}

#containing_kanji a {
color: black;
font-size: larger;
margin-right: 5px;
}

#sentences {
max-width: 600px;
}

.sentence {
width: 100%;
padding: 10px 0;
}

.sentence > p {
white-space: normal;
width: 100%;
}

.badge {
display: inline-block;
padding: 2px 5px;
margin: 0 2px;
background: rgba(230,230,230,100);
width: min-content;
white-space: nowrap;
border-radius: 5px;
font-size: 80%;
}
Loading

0 comments on commit df75d04

Please sign in to comment.