From 27b16e4318c5ef43efcb8ae3dc1ee1b7d9b367d6 Mon Sep 17 00:00:00 2001 From: WrinklyNinja Date: Fri, 9 May 2014 00:27:21 +0100 Subject: [PATCH] Re-implemented report translation support. The HTML is getting a bit messy now, but it works. --- resources/report/report.html | 42 +++++++++---------- resources/report/script.js | 19 +++++---- resources/report/style.css | 8 ++-- src/backend/generators.cpp | 81 ++++++++++++++++++++++++++++++++++-- 4 files changed, 113 insertions(+), 37 deletions(-) diff --git a/resources/report/report.html b/resources/report/report.html index f4024444..98b3f3aa 100644 --- a/resources/report/report.html +++ b/resources/report/report.html @@ -10,13 +10,13 @@
-

Summary

+

- - - - - - + + + + + +
LOOT Version
Masterlist Version
Masterlist Updating
Total Number of Messages
Number of Warnings
Number of Errors
-

General Messages

+

diff --git a/resources/report/script.js b/resources/report/script.js index 4ee75b77..16a172f9 100644 --- a/resources/report/script.js +++ b/resources/report/script.js @@ -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()) { diff --git a/resources/report/style.css b/resources/report/style.css index 1d0a875c..e15e4873 100644 --- a/resources/report/style.css +++ b/resources/report/style.css @@ -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; diff --git a/src/backend/generators.cpp b/src/backend/generators.cpp index c9efe365..daed8171 100644 --- a/src/backend/generators.cpp +++ b/src/backend/generators.cpp @@ -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 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);