add hunter arts to translate page

main
Bryce Allen 10 years ago
parent c2a72c951b
commit 4abf0e7011

@ -2,25 +2,191 @@
import sys
import json
import os.path
import _pathfix
from mhapi.db import MHDB
from mhapi.util import get_utf8_writer
def mk_html_list(dict_list, keys, sort_key):
print '<ul data-role="listview" data-filter="true" data-autodividers="true">'
for d in sorted(dict_list, key=lambda x: x[sort_key]):
PANEL = """
<div data-role="panel" id="menu" data-display="overlay"
data-position="fixed">
<div data-role="navbar">
<ul>
<li><a href="#page-skilltrees">Skill Trees</a></li>
<li><a href="#page-items">Items</a></li>
</ul>
</div>
</div>
"""
PANEL2 = """
<div data-role="panel" id="menu" data-display="overlay"
data-position="fixed">
<div data-role="controlgroup" data-corners="false">
<a href="#page-skilltrees">Skill Trees</a>
<a href="#page-items">Items</a>
</div>
</div>
"""
def print_header_nav(current_page_id):
pages = [("page-skilltrees", "Skill Trees"),
("page-items", "Items"),
("page-hunterarts", "Hunter Arts")]
print """
<div data-role="header" data-position="fixed">
<div data-role="navbar">
<ul>
""".strip("\n")
for page_id, page_name in pages:
if current_page_id == page_id:
print """
<li><a href="#%s"
class="ui-btn-active ui-state-persist">%s</a></li>
""".strip("\n") % (page_id, page_name)
else:
print """
<li><a href="#%s">%s</a></li>
""".strip("\n") % (page_id, page_name)
print """
</ul>
</div>
</div>
""".strip("\n")
HEADER_START = """
<div data-role="header" data-position="fixed">
<a href="#menu" data-icon="bars" class="ui-btn-left">Menu</a>
"""
def mk_html_list(dict_list, keys, sort_keys, divider_fn=None):
if divider_fn is None:
print ('<ul data-role="listview" data-filter="true"'
' data-autodividers="true">')
else:
print '<ul data-role="listview" data-filter="true">'
def sort_fn(d):
return tuple(d[k] for k in sort_keys)
prev_d = None
if sort_keys is not None:
it = sorted(dict_list, key=sort_fn)
else:
it = dict_list
for d in it:
if divider_fn is not None:
divider_text = divider_fn(d, prev_d)
if divider_text is not None:
print ' <li data-role="list-divider">%s</li>' % divider_text
print " <li>"
for k in keys:
print ' <span class="%s">%s</span>' % (k, d[k])
value = d[k]
if value.endswith(".png"):
value = ('<img class="icon" src="/img/icons_items/%s" />'
% value)
print ' <span class="%s">%s</span>' % (k, value)
print " </li>"
prev_d = d
print '</ul>'
if __name__ == '__main__':
with open(sys.argv[1]) as f:
data = json.load(f)
def _main():
db = MHDB()
strees = db.get_skill_trees()
items = db.get_items(item_types=("Tool", "Book", "Consumable", "Ammo"))
print """<!DOCTYPE html>
<html>
<head>
<title>Poogie Translate</title>
<meta charset="utf-8" />
<!-- Include meta tag to ensure proper rendering and touch zooming -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Include jQuery Mobile stylesheets -->
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css">
<!-- Include the jQuery library -->
<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
<!-- Include the jQuery Mobile library -->
<script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
<style>
span.name { display: inline-block; min-width: 50%; }
span.name_jp { display: inline-block; min-width: 50%; }
img.icon { width: 20px; height: 20px; }
</style>
</head>
<body>
"""
print '<div data-role="page" id="page-skilltrees">'
#print PANEL
#print HEADER_START
#print '<h2>Skill Trees</h2>'
#print '</div>'
#print HEADER_NAV
print_header_nav("page-skilltrees")
print '<div data-role="main" class="ui-content">'
mk_html_list(strees, ("name", "name_jp"), ("name",))
print '</div>'
print '</div>'
def item_divider_fn(d, prev_d):
prefix = _icon_prefix(d)
prev_prefix = _icon_prefix(prev_d)
if prefix != prev_prefix:
return prefix
return None
print '<div data-role="page" id="page-items">'
#print PANEL
#print HEADER_START
#print '<h2>Items</h2>'
#print '</div>'
#print HEADER_NAV
print_header_nav("page-items")
print '<div data-role="main" class="ui-content">'
mk_html_list(items, ("icon_name", "name", "name_jp"),
("icon_name", "name"), divider_fn=item_divider_fn)
print '</div>'
print '</div>'
ha_path = os.path.join(_pathfix.project_path, "db", "hunter_arts.json")
with open(ha_path) as f:
ha_list = json.load(f)
def ha_divider_fn(d, prev_d):
if prev_d is None:
return d["section"]
elif d["section"] != prev_d["section"]:
return d["section"]
return None
print '<div data-role="page" id="page-hunterarts">'
print_header_nav("page-hunterarts")
print '<div data-role="main" class="ui-content">'
mk_html_list(ha_list, ("name", "name_jp"), None, divider_fn=ha_divider_fn)
print '</div>'
print '</div>'
print """
</body>
"""
def _icon_prefix(d):
if d is None:
return ""
parts = d["icon_name"].split("-", 1)
return parts[0].replace(".png", "")
if __name__ == '__main__':
sys.stdout = get_utf8_writer(sys.stdout)
mk_html_list(data, ("name", "name_jp"), "name")
_main()

@ -0,0 +1,65 @@
#!/usr/bin/env python
# -*- coding: utf8 -*-
"""
Parse hunter arts name, name_jp, and description from wikia:
http://monsterhunter.wikia.com/wiki/MHX:_Hunter_Arts
Returns list of dict, e.g.:
[
{
"section": "Heavy Bowgun",
"description": "",
"name": "Acceleration Shower I",
"name_jp": "\u30a2\u30af\u30bb\u30eb\u30b7\u30e3\u30ef\u30fc I"
},
...
]
"""
import sys
import re
import json
from collections import defaultdict, OrderedDict
#<h3><span class="mw-headline" id="Lance">Lance</span></h3>
#<td style="vertical-align: top; background-color: #ddeeee; font-size:12pt;">Absolute Evasion<br />絶対回避
#</td><td>The hunter's body spins and evades attacks while retreating from the immediate area. Your weapon will always be sheathed after this technique.
SECTION_RE = re.compile('^<h[23]><span class="mw-headline" id="[^"]*">([^<]*)</span></h[23]>')
NAME_RE = re.compile(
'^<td style="vertical-align: top; background-color: #ddeeee; font-size:12pt;">([^<]*)<br />(.*)')
def parse_wikia_hunter_arts(f):
section = None
data = []
skill = {}
while True:
line = f.readline()
if not line:
break
line = line.strip()
m = SECTION_RE.match(line)
if m:
section = m.group(1)
continue
m = NAME_RE.match(line)
if m:
skill["section"] = section
skill["name"] = m.group(1)
skill["name_jp"] = m.group(2)
# next line is description
description = f.readline().strip().replace("</td><td>", "")
skill["description"] = description
data.append(skill)
skill = {}
return data
def _main():
with open(sys.argv[1]) as f:
data = parse_wikia_hunter_arts(f)
print json.dumps(data, indent=2)
if __name__ == '__main__':
_main()

@ -0,0 +1,302 @@
[
{
"section": "General Use",
"description": "The hunter's body spins and evades attacks while retreating from the immediate area. Your weapon will always be sheathed after this technique.",
"name": "Absolute Evasion",
"name_jp": "\u7d76\u5bfe\u56de\u907f"
},
{
"section": "General Use",
"description": "No stamina loss for panic running or carrying eggs.",
"name": "Escape Runner",
"name_jp": "\u30a8\u30b9\u30b1\u30fc\u30d7\u30e9\u30f3\u30ca\u30fc"
},
{
"section": "General Use",
"description": "Allows you to set up a healing station which will heal hunters within its vicinity.",
"name": "Hunter's Oasis",
"name_jp": "\u72e9\u4eba\u306e\u30aa\u30a2\u30b7\u30b9"
},
{
"section": "General Use",
"description": "Increases combining quantity and success percentage for short period of time.",
"name": "Perfect Combination",
"name_jp": "\u5b8c\u5168\u8abf\u5408"
},
{
"section": "General Use",
"description": "Cures all status ailments and heals you.",
"name": "Phoenix Breath",
"name_jp": "\u4e0d\u6b7b\u9ce5\u306e\u606f\u5439"
},
{
"section": "General Use",
"description": "Increases healing item effect and speeds up red gauge recovery.",
"name": "Heal Up",
"name_jp": "\u30d2\u30fc\u30eb\u30b2\u30a4\u30f3"
},
{
"section": "General Use",
"description": "Lose ability to run, but monster attacks will not flinch you.",
"name": "Metal Body",
"name_jp": "\u9244\u92fc\u8eab"
},
{
"section": "General Use",
"description": "",
"name": "Frenzy Body",
"name_jp": "\u72c2\u7adc\u8eab"
},
{
"section": "Great Sword",
"description": "Unleashes stored energy in a frightfully powerful slash. You cannot be knocked over during this move.",
"name": "Brimstone Slash I",
"name_jp": "\u9707\u6012\u7adc\u6028\u65ac I"
},
{
"section": "Great Sword",
"description": "A technique that stores energy in your hunter and their blade. Your next attack will deal more damage.",
"name": "Lion's Maw I",
"name_jp": "\u7363\u5bbf\u3057\u3010\u7345\u5b50\u3011 I"
},
{
"section": "Great Sword",
"description": "",
"name": "Thrusting Earth Slash I",
"name_jp": "\u5730\u885d\u65ac I"
},
{
"section": "Long Sword",
"description": "When this Hunting Art is activated, along with the Spirit Gauge reaching maximum, the Spirit Release Full Moon Slash will keep your Spirit Gauge at MAX for a limited time.",
"name": "Spirit Release Full Moon Slash I",
"name_jp": "\u7df4\u6c17\u89e3\u653e\u5186\u6708\u65ac\u308a I"
},
{
"section": "Long Sword",
"description": "This Hunting Art involves taking a special guarding stance. If attacked while in this stance, you will parry it and strike with a counter!",
"name": "Mirror Flower Stance I",
"name_jp": "\u93e1\u82b1\u306e\u69cb\u3048 I"
},
{
"section": "Long Sword",
"description": "",
"name": "Sakura Spirit Slash I",
"name_jp": "\u685c\u82b1\u6c17\u5203\u65ac I"
},
{
"section": "Sword and Shield",
"description": "A spin attack that slashes at targets surrounding you. During execution, you'll be invulnerable to monster attacks, making it an effective evasion technique.",
"name": "Round Force I",
"name_jp": "\u30e9\u30a6\u30f3\u30c9\u30d5\u30a9\u30fc\u30b9 I"
},
{
"section": "Sword and Shield",
"description": "Smashes shield upwards after a slash attack. Fierce enough to Stun if it hits a monster's head.",
"name": "Shoryugeki I",
"name_jp": "\u6607\u7adc\u6483 I"
},
{
"section": "Sword and Shield",
"description": "",
"name": "Blade Dance I",
"name_jp": "\u30d6\u30ec\u30a4\u30c9\u30c0\u30f3\u30b9 I"
},
{
"section": "Dual Blades",
"description": "A forward advancing combo that carves up your targets! You are able to change the direction of your advances during the move.",
"name": "Bloody Wind Top I",
"name_jp": "\u8840\u98a8\u72ec\u697d I"
},
{
"section": "Dual Blades",
"description": "With this Hunter Art, utilize ledges to attack. Following the upward spinning slice, you will deal a severe blow.",
"name": "Soaring Heaven Splitter I",
"name_jp": "\u5929\u7fd4\u7a7a\u7834\u65ad I"
},
{
"section": "Dual Blades",
"description": "",
"name": "Beast Mode: Ravenous Wolf I",
"name_jp": "\u7363\u5bbf\u3057\u3010\u9913\u72fc\u3011 I"
},
{
"section": "Hammer",
"description": "Provokes a monster and for a limited time it will be more likely that it focuses its offensive on you!",
"name": "Provoke I",
"name_jp": "\u5927\u6311\u767a I"
},
{
"section": "Hammer",
"description": "Spin the Hammer around with tremendous force before striking down your target with a super-charged attack.",
"name": "Spinning Meteor I",
"name_jp": "\u30b9\u30d4\u30cb\u30f3\u30b0\u30e1\u30c6\u30aa I"
},
{
"section": "Hammer",
"description": "",
"name": "Typhoon Trigger I",
"name_jp": "\u30bf\u30a4\u30d5\u30fc\u30f3\u30c8\u30ea\u30ac\u30fc I"
},
{
"section": "Hunting Horn",
"description": "This Hunter Art involves playing the Hunting Horn with a pressurized shockwave! A very powerful attack!",
"name": "Sound Attack Tremor I",
"name_jp": "\u97f3\u6483\u9707 I"
},
{
"section": "Hunting Horn",
"description": "For a limited duration, you will have the ability to play double notes without hitting a monster!",
"name": "Full Orchestra I",
"name_jp": "\u594f\u7e8f I"
},
{
"section": "Hunting Horn",
"description": "",
"name": "Orchestra Soul I",
"name_jp": "\u30aa\u30eb\u30b1\u30b9\u30bf\u30bd\u30a6\u30eb I"
},
{
"section": "Lance",
"description": "Raise your shield and charge monsters while blocking. Capable of follow-up thrusts.",
"name": "Shield Assault I",
"name_jp": "\u30b7\u30fc\u30eb\u30c9\u30a2\u30b5\u30eb\u30c8 I"
},
{
"section": "Lance",
"description": "Raise your shield to absorb an attack's power. Block stronger attacks to absorb more power. Try it just before an attack hits you.",
"name": "Enraged Guard I",
"name_jp": "\u30ac\u30fc\u30c9\u30ec\u30a4\u30b8 I"
},
{
"section": "Lance",
"description": "",
"name": "Screw Thrust I",
"name_jp": "\u30b9\u30af\u30ea\u30e5\u30fc\u30b9\u30e9\u30b9\u30c8 I"
},
{
"section": "Gunlance",
"description": "Utilizing explosive energies, unleashing a swirling dose of hellfire in this terrifying Wyvern's Fire attack!",
"name": "Supreme Mountain Wyvern's Fire I",
"name_jp": "\u8987\u5c71\u7adc\u6483\u7832 I"
},
{
"section": "Gunlance",
"description": "This Hunter Art brings the internal heat energy of the Gunlance to its highest point, allowing the heat gauge to stay at maximum for a limited time!",
"name": "Wyvern's Breath",
"name_jp": "\u7adc\u306e\u606f\u5439 I"
},
{
"section": "Gunlance",
"description": "",
"name": "Blast Dash I",
"name_jp": "\u30d6\u30e9\u30b9\u30c8\u30c0\u30c3\u30b7\u30e5 I"
},
{
"section": "Switch Axe",
"description": "A combo of Axe Mode and Sword Mode strikes followed by an Elemental Discharge.",
"name": "Translash I",
"name_jp": "\u30c8\u30e9\u30f3\u30b9\u30e9\u30c3\u30b7\u30e5 I"
},
{
"section": "Switch Axe",
"description": "Enhances the power inside your Sword Mode, granting it even more attack power.",
"name": "Demon Sword Mode I",
"name_jp": "\u5263\u9b3c\u5f62\u614b I"
},
{
"section": "Switch Axe",
"description": "",
"name": "Energy Charge I",
"name_jp": "\u30a8\u30cd\u30eb\u30ae\u30fc\u30c1\u30e3\u30fc\u30b8 I"
},
{
"section": "Charge Blade",
"description": "Use the power charged in your phials to create a blade of energy. More phials means more power!",
"name": "Energy Blade I",
"name_jp": "\u30a8\u30cd\u30eb\u30ae\u30fc\u30d6\u30ec\u30a4\u30c9 I"
},
{
"section": "Charge Blade",
"description": "Temporarily increase the maximum number of phials you can charge up.",
"name": "Over Limit I",
"name_jp": "\u30aa\u30fc\u30d0\u30fc\u30ea\u30df\u30c3\u30c8 I"
},
{
"section": "Charge Blade",
"description": "",
"name": "Healing Bottle I",
"name_jp": "\u30d2\u30fc\u30ea\u30f3\u30b0\u30dc\u30c8\u30eb I"
},
{
"section": "Insect Glaive",
"description": "Attract insects that stay around you and protect you by attacking anything that draws near you.",
"name": "Insect Clad I",
"name_jp": "\u87f2\u7e8f\u3044 I"
},
{
"section": "Insect Glaive",
"description": "Send out your Kinsect with incredible velocity, allowing it to draw all 3 Extracts in one shot.",
"name": "Extract Hunter I",
"name_jp": "\u30a8\u30ad\u30b9\u30cf\u30f3\u30bf\u30fc I"
},
{
"section": "Insect Glaive",
"description": "",
"name": "Soaring Insect Slash I",
"name_jp": "\u98db\u7fd4\u87f2\u65ac\u7834 I"
},
{
"section": "Light Bowgun",
"description": "Propel backward while leaving an explosive shot on the ground for the approaching monster to get blasted with.",
"name": "Bullet Geyser I",
"name_jp": "\u30d0\u30ec\u30c3\u30c8\u30b2\u30a4\u30b6\u30fc I"
},
{
"section": "Light Bowgun",
"description": "Allows you to rapid fire your rapid shots in fast succession until you run out.",
"name": "Rapid Heaven I",
"name_jp": "\u30e9\u30d4\u30c3\u30c9\u30d8\u30d6\u30f3 I"
},
{
"section": "Light Bowgun",
"description": "",
"name": "Full Load I",
"name_jp": "\u5168\u5f3e\u88c5\u586b I"
},
{
"section": "Heavy Bowgun",
"description": "A special shot that results in a massive mid-air explosion that affects a wide area.",
"name": "Supernova I",
"name_jp": "\u30b9\u30fc\u30d1\u30fc\u30ce\u30f4\u30a1 I"
},
{
"section": "Heavy Bowgun",
"description": "Loads a special coating that increases the power of your shots.",
"name": "Load Gunpowder I",
"name_jp": "\u706b\u85ac\u88c5\u586b"
},
{
"section": "Heavy Bowgun",
"description": "",
"name": "Acceleration Shower I",
"name_jp": "\u30a2\u30af\u30bb\u30eb\u30b7\u30e3\u30ef\u30fc I"
},
{
"section": "Bow",
"description": "A special shower that gives your hunter increased movement speed and charging speed.",
"name": "Acceleration Rain I",
"name_jp": "\u30a2\u30af\u30bb\u30eb\u30ec\u30a4\u30f3 I"
},
{
"section": "Bow",
"description": "Tie two arrows together with a wire and shoot them as a single shot that cuts like a blade.",
"name": "Blade Wire I",
"name_jp": "\u30d6\u30ec\u30a4\u30c9\u30ef\u30a4\u30e4\u30fc I"
},
{
"section": "Bow",
"description": "",
"name": "Trinity Raven I",
"name_jp": "\u30c8\u30ea\u30cb\u30c6\u30a3\u30ec\u30a4\u30f4\u30f3 I"
}
]

@ -1,5 +1,6 @@
<html>
<head>
<meta charset="utf-8" />
<title>Poogie's Toolbox</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
@ -90,4 +91,9 @@
<legend title="Plan armor sets">Poogie Outfitters</legend>
<a href="outfitters.html">Armor set planner</a>
</fieldset>
<br />
<fieldset>
<legend title="Mobile friendly translation guide">Poogie トランスレーター</legend>
<a href="translate/">English to Japanese translation guide</a>
</fieldset>
</body>

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save