Re-implemented report translation support.

The HTML is getting a bit messy now, but it works.
This commit is contained in:
WrinklyNinja
2014-05-09 00:27:21 +01:00
parent 33d040deca
commit 27b16e4318
4 changed files with 113 additions and 37 deletions
+21 -21
View File
@@ -10,13 +10,13 @@
</head>
<body>
<div id="nav">
<div class="button current" data-section="summary">Summary</div>
<div class="button" data-section="plugins">Details</div>
<div class="button hidden" id="filtersToggle">Filters</div>
<div class="button current" data-section="summary" id="txtSummarySec"></div>
<div class="button" data-section="plugins" id="txtDetailsSec"></div>
<div class="button hidden" id="filtersToggle"></div>
</div>
<div id="main">
<noscript>
<div>The LOOT Report requires Javascript to be enabled in order to function.</div>
<div id="txtNoscript"></div>
</noscript>
<div id="plugins" class="hidden">
<ul id="pluginsList">
@@ -24,38 +24,38 @@
</div>
<div id="summary">
<div>
<h2>Summary</h2>
<h2 id="txtSummary"></h2>
<table>
<tbody>
<tr><td>LOOT Version</td><td id="lootVersion"></td></tr>
<tr><td>Masterlist Version</td><td id="masterlistRevision"></td></tr>
<tr><td>Masterlist Updating</td><td id="masterlistUpdating"></td></tr>
<tr><td>Total Number of Messages</td><td id="totalMessageNo"></td></tr>
<tr><td>Number of Warnings</td><td id="totalWarningNo"></td></tr>
<tr><td>Number of Errors</td><td id="totalErrorNo"></td></tr>
<tr><td id="txtLootVersion"></td><td id="lootVersion"></td></tr>
<tr><td id="txtMasterlistRevision"></td><td id="masterlistRevision"></td></tr>
<tr><td id="txtMasterlistUpdating"></td><td id="masterlistUpdating"></td></tr>
<tr><td id="txtTotalMessageNo"></td><td id="totalMessageNo"></td></tr>
<tr><td id="txtTotalWarningNo"></td><td id="totalWarningNo"></td></tr>
<tr><td id="txtTotalErrorNo"></td><td id="totalErrorNo"></td></tr>
</tbody>
</table>
</div>
<div>
<h2>General Messages</h2>
<h2 id="txtGeneralMessages"></h2>
<ul id="generalMessagesList">
</ul>
</div>
</div>
</div>
<div id="filters" class="hidden">
<label><input type="checkbox" id="hideVersionNumbers" data-class="version" />Hide Version Numbers</label>
<label><input type="checkbox" id="hideCRCs" data-class="crc" />Hide CRCs</label>
<label><input type="checkbox" id="hideBashTags" data-class="tag" />Hide Bash Tag Suggestions</label>
<label><input type="checkbox" id="hideNotes" />Hide Notes</label>
<label><input type="checkbox" id="hideDoNotCleanMessages" />Hide 'Do Not Clean' Messages</label>
<label><input type="checkbox" id="hideAllPluginMessages" />Hide All Plugin Messages</label>
<label><input type="checkbox" id="hideMessagelessPlugins" />Hide Messageless Plugins</label>
<input type="checkbox" id="hideVersionNumbers" data-class="version" /><label id="txtHideVersionNumbers" for="hideVersionNumbers"></label><br>
<input type="checkbox" id="hideCRCs" data-class="crc" /><label id="txtHideCRCs" for="hideCRCs"></label><br>
<input type="checkbox" id="hideBashTags" data-class="tag" /><label id="txtHideBashTags" for="hideBashTags"></label><br>
<input type="checkbox" id="hideNotes" /><label id="txtHideNotes" for="hideNotes"></label><br>
<input type="checkbox" id="hideDoNotCleanMessages" /><label id="txtHideDoNotCleanMessages" for="hideDoNotCleanMessages"></label><br>
<input type="checkbox" id="hideAllPluginMessages" /><label id="txtHideAllPluginMessages" for="hideAllPluginMessages"></label><br>
<input type="checkbox" id="hideMessagelessPlugins" /><label id="txtHideMessagelessPlugins" for="hideMessagelessPlugins"></label><br>
<div>
Plugins hidden: <span id="hiddenPluginNo">0</span> / <span id="totalPluginNo"></span>
<span id="txtPluginsHidden"></span>: <span id="hiddenPluginNo">0</span> / <span id="totalPluginNo"></span>
</div>
<div>
Messages hidden: <span id="hiddenMessageNo">0</span> / <span id="filterTotalMessageNo"></span>
<span id="txtMessagesHidden"></span>: <span id="hiddenMessageNo">0</span> / <span id="filterTotalMessageNo"></span>
</div>
</div>
<script src="script.js"></script>
+10 -9
View File
@@ -211,13 +211,6 @@ function setupEventHandlers() {
document.getElementById('hideAllPluginMessages').addEventListener('click', toggleMessages, false);
document.getElementById('hideMessagelessPlugins').addEventListener('click', togglePlugins, false);
}
function masterlistUpdaterStatus(state) {
if (state) {
return 'Enabled';
} else {
return 'Disabled';
}
}
function processURLParams() {
/* Get the data path from the URL and load it. */
var pos = document.URL.indexOf("?data=");
@@ -231,7 +224,7 @@ function processURLParams() {
/* Fill report with data. */
document.getElementById('lootVersion').textContent = data.lootVersion;
document.getElementById('masterlistRevision').textContent = data.masterlist.revision;
document.getElementById('masterlistUpdating').textContent = masterlistUpdaterStatus(data.masterlist.updaterEnabled);
document.getElementById('masterlistUpdating').textContent = data.masterlist.updaterEnabled;
var generalMessagesList = document.getElementById('generalMessagesList');
for (var i = 0; i < data.globalMessages.length; ++i) {
var li = document.createElement('li');
@@ -264,7 +257,7 @@ function processURLParams() {
if (data.plugins[i].version) {
var version = document.createElement('div');
version.className = 'version';
version.textContent = 'Version: ' + data.plugins[i].version;
version.textContent = data.plugins[i].version;
li.appendChild(version);
}
@@ -308,6 +301,14 @@ function processURLParams() {
document.getElementById('totalWarningNo').textContent = warnMessageNo;
document.getElementById('totalErrorNo').textContent = errorMessageNo;
/* Now apply translated UI strings. */
for (var id in data.l10n) {
var elem = document.getElementById(id);
if (elem) {
elem.textContent = data.l10n[id];
}
}
/* Now initialise the rest of the report. */
setupEventHandlers();
if (isStorageSupported()) {
+4 -4
View File
@@ -51,7 +51,7 @@ noscript div {
.button.current {
background: #ccc;
}
.button[id] {
#filtersToggle {
position:absolute;
right:0;
top:0;
@@ -98,19 +98,19 @@ table td:first-child {
display:none;
}
#filters label {
display:block;
display:inline-block;
padding:0.2em 0.5em;
white-space:nowrap;
cursor:pointer;
}
#filters div {
padding:0.2em 1em;
padding:0.2em 0.5em;
font-style:italic;
}
input[type='checkbox'] {
position:relative;
top:0.15em;
margin-right:0.5em;
margin-left:0.5em;
}
ul {
margin-top:0.5em;
+78 -3
View File
@@ -103,7 +103,7 @@ namespace loot {
if (!plugin.Version().empty()) {
out << YAML::Key << "version"
<< YAML::Value << plugin.Version();
<< YAML::Value << boost::locale::translate("Version").str() << ": " << plugin.Version();
}
std::set<Tag> tags = plugin.Tags();
@@ -189,8 +189,14 @@ namespace loot {
yout << YAML::Key << "masterlist"
<< YAML::BeginMap
<< YAML::Key << "updaterEnabled"
<< YAML::Value << masterlistUpdateEnabled
<< YAML::Key << "revision"
<< YAML::Value;
if (masterlistUpdateEnabled)
yout << boost::locale::translate("Enabled").str();
else
yout << boost::locale::translate("Disabled").str();
yout << YAML::Key << "revision"
<< YAML::Value << masterlistVersion
<< YAML::Key << "date"
<< YAML::Value << ""
@@ -216,6 +222,75 @@ namespace loot {
yout << YAML::EndSeq;
}
BOOST_LOG_TRIVIAL(debug) << "Generating text translations.";
yout << YAML::Key << "l10n"
<< YAML::BeginMap
<< YAML::Key << "txtNoscript"
<< YAML::Value << boost::locale::translate("The LOOT Report requires Javascript to be enabled in order to function.").str()
<< YAML::Key << "txtSummarySec"
<< YAML::Value << boost::locale::translate("Summary").str()
<< YAML::Key << "txtLootVersion"
<< YAML::Value << boost::locale::translate("LOOT Version").str()
<< YAML::Key << "txtMasterlistRevision"
<< YAML::Value << boost::locale::translate("Masterlist Version").str()
<< YAML::Key << "txtMasterlistUpdating"
<< YAML::Value << boost::locale::translate("Masterlist Updating").str()
<< YAML::Key << "txtTotalMessageNo"
<< YAML::Value << boost::locale::translate("Total Number of Messages").str()
<< YAML::Key << "txtTotalWarningNo"
<< YAML::Value << boost::locale::translate("Number of Warnings").str()
<< YAML::Key << "txtTotalErrorNo"
<< YAML::Value << boost::locale::translate("Number of Errors").str()
<< YAML::Key << "txtGeneralMessages"
<< YAML::Value << boost::locale::translate("General Messages").str()
<< YAML::Key << "txtDetailsSec"
<< YAML::Value << boost::locale::translate("Details").str()
<< YAML::Key << "filtersToggle"
<< YAML::Value << boost::locale::translate("Filters").str()
<< YAML::Key << "txtHideVersionNumbers"
<< YAML::Value << boost::locale::translate("Hide Version Numbers").str()
<< YAML::Key << "txtHideCRCs"
<< YAML::Value << boost::locale::translate("Hide CRCs").str()
<< YAML::Key << "txtHideBashTags"
<< YAML::Value << boost::locale::translate("Hide Bash Tag Suggestions").str()
<< YAML::Key << "txtHideNotes"
<< YAML::Value << boost::locale::translate("Hide Notes").str()
<< YAML::Key << "txtHideDoNotCleanMessages"
<< YAML::Value << boost::locale::translate("Hide 'Do Not Clean' Messages").str()
<< YAML::Key << "txtHideAllPluginMessages"
<< YAML::Value << boost::locale::translate("Hide All Plugin Messages").str()
<< YAML::Key << "txtHideMessagelessPlugins"
<< YAML::Value << boost::locale::translate("Hide Messageless Plugins").str()
<< YAML::Key << "txtPluginsHidden"
<< YAML::Value << boost::locale::translate("Plugins hidden").str()
<< YAML::Key << "txtMessagesHidden"
<< YAML::Value << boost::locale::translate("Messages hidden").str()
<< YAML::EndMap;
yout << YAML::EndMap;
loot::ofstream out(file);