User Guide localization

git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@6341 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
Bill Somerville 2016-01-02 22:30:12 +00:00
parent 7b7ef610b5
commit 0ba0977aa2
94 changed files with 316 additions and 111 deletions

View File

@ -52,7 +52,7 @@ set (PROJECT_VENDOR "Joe Taylor, K1JT")
set (PROJECT_CONTACT "Joe Taylor <k1jt@arrl.net>")
set (PROJECT_COPYRIGHT "Copyright (C) 2001-2015 by Joe Taylor, K1JT")
set (PROJECT_HOMEPAGE http://www.physics.princeton.edu/pulsar/K1JT/wsjtx.html)
set (PROJECT_MANUAL wsjtx-main-${wsjtx_VERSION}.html)
set (PROJECT_MANUAL wsjtx-main)
set (PROJECT_MANUAL_DIRECTORY_URL http://www.physics.princeton.edu/pulsar/K1JT/wsjtx-doc)
set (PROJECT_SAMPLES_URL http://downloads.sourceforge.net/project/wsjt/)
set (PROJECT_SAMPLES_UPLOAD_DEST frs.sourceforge.net:/home/frs/project/wsjt/)
@ -215,6 +215,7 @@ set (wsjt_qt_CXXSRCS
SampleDownloader/Directory.cpp
SampleDownloader/FileNode.cpp
SampleDownloader/RemoteFile.cpp
DisplayManual.cpp
)
set (wsjt_qtmm_CXXSRCS

152
DisplayManual.cpp Normal file
View File

@ -0,0 +1,152 @@
#include "DisplayManual.hpp"
#include <QObject>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QUrl>
#include <QString>
#include <QDir>
#include <QFileInfo>
#include <QDesktopServices>
#include <QLocale>
#include "revision_utils.hpp"
#include "pimpl_impl.hpp"
namespace
{
class token
: public QObject
{
Q_OBJECT
public:
token (QUrl const& url, QString const& lang, QString const& name_we, QObject * parent = nullptr)
: QObject {parent}
, url_ {url}
, lang_ {lang}
, name_we_ {name_we}
{
}
QUrl url_;
QString lang_;
QString name_we_;
};
}
class DisplayManual::impl final
: public QObject
{
Q_OBJECT
public:
impl (QNetworkAccessManager * qnam)
: qnam_ {qnam}
{
connect (qnam_, &QNetworkAccessManager::finished, this, &DisplayManual::impl::reply_finished);
}
void display (QUrl const& url, QString const& name_we)
{
// try and find a localized manual
auto lang = QLocale::system ().name ();
// try for language and country first
auto file = name_we + '_' + lang + '-' + version () + ".html";
auto target = url.resolved (file);
QNetworkRequest request {target};
request.setRawHeader ("User-Agent", "WSJT-X Manual Checker");
request.setOriginatingObject (new token {url, lang, name_we, this});
auto * reply = qnam_->head (request);
outstanding_requests_ << reply;
}
void reply_finished (QNetworkReply * reply)
{
if (outstanding_requests_.contains (reply))
{
QUrl target;
if (reply->error ())
{
if (auto * tok = qobject_cast<token *> (reply->request ().originatingObject ()))
{
auto pos = tok->lang_.lastIndexOf ('_');
QString file;
if (pos >= 0)
{
tok->lang_.truncate (pos);
file = tok->name_we_ + '_' + tok->lang_ + '-' + version () + ".html";
target = tok->url_.resolved (file);
QNetworkRequest request {target};
request.setRawHeader ("User-Agent", "WSJT-X Manual Checker");
request.setOriginatingObject (tok);
auto * reply = qnam_->head (request);
outstanding_requests_ << reply;
}
else
{
// give up looking and request the default
file = tok->name_we_ + '-' + version () + ".html";
target = tok->url_.resolved (file);
QDesktopServices::openUrl (target);
delete tok;
}
}
}
else
{
// found it
if (auto * tok = qobject_cast<token *> (reply->request ().originatingObject ()))
{
delete tok;
}
QDesktopServices::openUrl (reply->request ().url ());
}
outstanding_requests_.removeOne (reply);
reply->deleteLater ();
}
}
QNetworkAccessManager * qnam_;
QList<QNetworkReply *> outstanding_requests_;
};
#include "DisplayManual.moc"
DisplayManual::DisplayManual (QNetworkAccessManager * qnam, QObject * parent)
: QObject {parent}
, m_ {qnam}
{
}
DisplayManual::~DisplayManual ()
{
}
void DisplayManual::display_html_url (QUrl const& url, QString const& name_we)
{
m_->display (url, name_we);
}
void DisplayManual::display_html_file (QDir const& dir, QString const& name_we)
{
// try and find a localized manual
auto lang = QLocale::system ().name ();
// try for language and country first
auto file = dir.absoluteFilePath (name_we + '_' + lang + '-' + version () + ".html");
if (!QFileInfo::exists (file))
{
// try for language
lang.truncate (lang.lastIndexOf ('_'));
file = dir.absoluteFilePath (name_we + '_' + lang + '-' + version () + ".html");
if (!QFileInfo::exists (file))
{
// use default
file = dir.absoluteFilePath (name_we + '-' + version () + ".html");
}
}
// may fail but browser 404 error is a good as anything
QDesktopServices::openUrl (QUrl {"file:///" + file});
}

27
DisplayManual.hpp Normal file
View File

@ -0,0 +1,27 @@
#ifndef DISPLAY_MANUAL_HPP__
#define DISPLAY_MANUAL_HPP__
#include <QObject>
#include "pimpl_h.hpp"
class QNetworkAccessManager;
class QDir;
class QUrl;
class QString;
class DisplayManual
: public QObject
{
public:
DisplayManual (QNetworkAccessManager *, QObject * = nullptr);
~DisplayManual ();
void display_html_url (QUrl const& url, QString const& name_we);
void display_html_file (QDir const& dir, QString const& name_we);
private:
class impl;
pimpl<impl> m_;
};
#endif

View File

@ -1,3 +1,7 @@
set (LANGUAGES
en
)
set (common_SRCS
common/communication.adoc
common/license.adoc
@ -5,88 +9,88 @@ set (common_SRCS
)
set (UG_SRCS
user_guide/docinfo.html
user_guide/docinfo.xml
user_guide/acknowledgements.adoc
user_guide/compiling.adoc
user_guide/config-details.adoc
user_guide/controls-functions-center.adoc
user_guide/controls-functions-left.adoc
user_guide/controls-functions-main-window.adoc
user_guide/controls-functions-menus.adoc
user_guide/controls-functions-messages.adoc
user_guide/controls-functions-status-bar.adoc
user_guide/controls-functions-wide-graph.adoc
user_guide/cooperating-programs.adoc
user_guide/faq.adoc
user_guide/font-sizes.adoc
user_guide/implementation.adoc
user_guide/install-from-source.adoc
user_guide/install-linux.adoc
user_guide/install-mac.adoc
user_guide/install-windows.adoc
user_guide/introduction.adoc
user_guide/protocols.adoc
user_guide/logging.adoc
user_guide/make-qso.adoc
user_guide/new_features.adoc
user_guide/platform-dependencies.adoc
user_guide/settings-audio.adoc
user_guide/settings-colors.adoc
user_guide/settings-frequencies.adoc
user_guide/settings-general.adoc
user_guide/settings-radio.adoc
user_guide/settings-reporting.adoc
user_guide/settings-txmacros.adoc
user_guide/support.adoc
user_guide/system-requirements.adoc
user_guide/transceiver-setup.adoc
user_guide/tutorial-example1.adoc
user_guide/tutorial-example2.adoc
user_guide/tutorial-main-window.adoc
user_guide/tutorial-wide-graph-settings.adoc
user_guide/utilities.adoc
user_guide/vhf-features.adoc
user_guide/wsjtx-main.adoc
user_guide/wspr.adoc
docinfo.html
docinfo.xml
acknowledgements.adoc
compiling.adoc
config-details.adoc
controls-functions-center.adoc
controls-functions-left.adoc
controls-functions-main-window.adoc
controls-functions-menus.adoc
controls-functions-messages.adoc
controls-functions-status-bar.adoc
controls-functions-wide-graph.adoc
cooperating-programs.adoc
faq.adoc
font-sizes.adoc
implementation.adoc
install-from-source.adoc
install-linux.adoc
install-mac.adoc
install-windows.adoc
introduction.adoc
protocols.adoc
logging.adoc
make-qso.adoc
new_features.adoc
platform-dependencies.adoc
settings-audio.adoc
settings-colors.adoc
settings-frequencies.adoc
settings-general.adoc
settings-radio.adoc
settings-reporting.adoc
settings-txmacros.adoc
support.adoc
system-requirements.adoc
transceiver-setup.adoc
tutorial-example1.adoc
tutorial-example2.adoc
tutorial-main-window.adoc
tutorial-wide-graph-settings.adoc
utilities.adoc
vhf-features.adoc
wsjtx-main.adoc
wspr.adoc
)
set (UG_IMGS
user_guide/images/130610_2343-wav-80.png
user_guide/images/band-settings.png
user_guide/images/colors.png
user_guide/images/decode-menu.png
user_guide/images/decodes.png
user_guide/images/file-menu.png
user_guide/images/freemsg.png
user_guide/images/help-menu.png
user_guide/images/jtalert.png
user_guide/images/keyboard-shortcuts.png
user_guide/images/log-qso.png
user_guide/images/MacAppMenu.png
user_guide/images/main-ui-1.5.png
user_guide/images/main-ui-controls.png
user_guide/images/misc-controls-center.png
user_guide/images/misc-main-ui.png
user_guide/images/mode-menu.png
user_guide/images/new-msg-box.png
user_guide/images/psk-reporter.png
user_guide/images/r3666-config-screen-80.png
user_guide/images/r3666-main-ui-80.png
user_guide/images/r4148-txmac-ui.png
user_guide/images/RadioTab.png
user_guide/images/reporting.png
user_guide/images/save-menu.png
user_guide/images/settings-audio.png
user_guide/images/settings-frequencies.png
user_guide/images/settings-general.png
user_guide/images/setup-menu.png
user_guide/images/special-mouse-commands.png
user_guide/images/status-bar-a.png
user_guide/images/traditional-msg-box.png
user_guide/images/tx-macros.png
user_guide/images/view-menu.png
user_guide/images/wide-graph-controls.png
images/130610_2343-wav-80.png
images/band-settings.png
images/colors.png
images/decode-menu.png
images/decodes.png
images/file-menu.png
images/freemsg.png
images/help-menu.png
images/jtalert.png
images/keyboard-shortcuts.png
images/log-qso.png
images/MacAppMenu.png
images/main-ui-1.5.png
images/main-ui-controls.png
images/misc-controls-center.png
images/misc-main-ui.png
images/mode-menu.png
images/new-msg-box.png
images/psk-reporter.png
images/r3666-config-screen-80.png
images/r3666-main-ui-80.png
images/r4148-txmac-ui.png
images/RadioTab.png
images/reporting.png
images/save-menu.png
images/settings-audio.png
images/settings-frequencies.png
images/settings-general.png
images/setup-menu.png
images/special-mouse-commands.png
images/status-bar-a.png
images/traditional-msg-box.png
images/tx-macros.png
images/view-menu.png
images/wide-graph-controls.png
)
@ -110,17 +114,17 @@ include (CMakeParseArguments)
# ASCIIDOCTOR_OPTIONS - asciidoctor command options
# DEPENDS - dependent files
function (document)
cmake_parse_arguments (_args "HTML" "SOURCE;OUTPUT" "ASCIIDOCTOR_OPTIONS;PDF;DEPENDS" ${ARGN})
cmake_parse_arguments (_args "HTML" "SOURCE;LANG;OUTPUT" "ASCIIDOCTOR_OPTIONS;PDF;DEPENDS" ${ARGN})
get_filename_component (_source_path ${_args_SOURCE} PATH)
get_filename_component (_source_name ${_args_SOURCE} NAME)
get_filename_component (_output_name_we ${_args_SOURCE} NAME_WE)
# HTML
if (${_args_HTML})
set (_html_file ${CMAKE_CURRENT_BINARY_DIR}/${_output_name_we}.html)
set (_html_file ${CMAKE_CURRENT_BINARY_DIR}/${_output_name_we}_${lang}.html)
add_custom_command (
OUTPUT ${_html_file}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${_source_path}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${_source_path}/${lang}
COMMAND ${ASCIIDOCTOR_EXECUTABLE} ${_args_ASCIIDOCTOR_OPTIONS}
-b html5
-a VERSION_MAJOR=${WSJTX_VERSION_MAJOR}
@ -136,11 +140,11 @@ function (document)
# PDF
if (_args_PDF AND EXISTS ${FOPUB_EXECUTABLE})
set (_docbook_file ${CMAKE_CURRENT_BINARY_DIR}/${_output_name_we}.xml)
set (_pdf_file_we ${CMAKE_CURRENT_BINARY_DIR}/${_output_name_we})
set (_docbook_file ${CMAKE_CURRENT_BINARY_DIR}/${_output_name_we}_${lang}.xml)
set (_pdf_file_we ${CMAKE_CURRENT_BINARY_DIR}/${_output_name_we}_${lang})
add_custom_command (
OUTPUT ${_docbook_file} "${_pdf_file_we} (USLetter).pdf" "${_pdf_file_we} (A4).pdf"
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${_source_path}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/${_source_path}/${lang}
COMMAND ${ASCIIDOCTOR_EXECUTABLE} ARGS ${_args_ASCIIDOCTOR_OPTIONS}
-b docbook
-a data-uri!
@ -163,25 +167,44 @@ function (document)
set (${_args_OUTPUT} ${_output_files} PARENT_SCOPE)
endfunction (document)
document(
HTML
SOURCE user_guide/wsjtx-main.adoc
OUTPUT html
ASCIIDOCTOR_OPTIONS -d book -a data-uri -a toc=left -a max-width=1024px
DEPENDS ${common_SRCS} ${UG_SRCS} ${UG_IMGS}
)
document(
PDF -param body.font.master 11 -param body.font.family "'Noto Sans, Helvetica, sans-serif'" -param title.font.family "'Noto Serif, Times New Roman, serif'" -param page.margin.inner 1cm -param page.margin.outer 1cm -param page.margin.top 0.75cm -param page.margin.bottom 0.5cm -param generate.toc 0
SOURCE user_guide/wsjtx-main.adoc
OUTPUT pdf
ASCIIDOCTOR_OPTIONS -d book
DEPENDS ${common_SRCS} ${UG_SRCS} ${UG_IMGS}
)
add_custom_target (docs ALL DEPENDS ${html} ${pdf})
set (htmls)
set (pdfs)
foreach (lang ${LANGUAGES})
set (_sources)
foreach (_src ${UG_SRCS} ${UG_IMGS})
list (APPEND _sources "user_guide/${lang}/${_src}")
endforeach ()
document(
HTML
SOURCE user_guide/wsjtx-main.adoc
LANG "${lang}"
OUTPUT html
ASCIIDOCTOR_OPTIONS -d book -a data-uri -a toc=left -a max-width=1024px
DEPENDS ${common_SRCS} ${_sources}
)
document(
PDF -param body.font.master 11 -param body.font.family "'Noto Sans, Helvetica, sans-serif'" -param title.font.family "'Noto Serif, Times New Roman, serif'" -param page.margin.inner 1cm -param page.margin.outer 1cm -param page.margin.top 0.75cm -param page.margin.bottom 0.5cm -param generate.toc 0
SOURCE user_guide/wsjtx-main.adoc
LANG "${lang}"
OUTPUT pdf
ASCIIDOCTOR_OPTIONS -d book
DEPENDS ${common_SRCS} ${_sources}
)
list (APPEND htmls "${html}")
list (APPEND pdfs "${pdf}")
endforeach ()
install (FILES
${html}
DESTINATION ${WSJT_SHARE_DESTINATION}/${WSJT_DOC_DESTINATION}
RENAME ${PROJECT_MANUAL}
#COMPONENT runtime
)
add_custom_target (docs ALL DEPENDS ${htmls} ${pdfs})
foreach (_html ${htmls})
get_filename_component (_path ${_html} PATH)
get_filename_component (_nwe ${_html} NAME_WE)
get_filename_component (_ext ${_html} EXT)
string (REGEX REPLACE "_en$" "" _nwe ${_nwe})
install (FILES
${_html}
DESTINATION ${WSJT_SHARE_DESTINATION}/${WSJT_DOC_DESTINATION}
RENAME ${_nwe}-${wsjtx_VERSION}${_ext}
#COMPONENT runtime
)
endforeach ()

View File

Before

Width:  |  Height:  |  Size: 184 KiB

After

Width:  |  Height:  |  Size: 184 KiB

View File

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 31 KiB

View File

Before

Width:  |  Height:  |  Size: 34 KiB

After

Width:  |  Height:  |  Size: 34 KiB

View File

Before

Width:  |  Height:  |  Size: 55 KiB

After

Width:  |  Height:  |  Size: 55 KiB

View File

Before

Width:  |  Height:  |  Size: 55 KiB

After

Width:  |  Height:  |  Size: 55 KiB

View File

Before

Width:  |  Height:  |  Size: 6.6 KiB

After

Width:  |  Height:  |  Size: 6.6 KiB

View File

Before

Width:  |  Height:  |  Size: 131 KiB

After

Width:  |  Height:  |  Size: 131 KiB

View File

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View File

Before

Width:  |  Height:  |  Size: 22 KiB

After

Width:  |  Height:  |  Size: 22 KiB

View File

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 11 KiB

View File

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB

View File

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

Before

Width:  |  Height:  |  Size: 84 KiB

After

Width:  |  Height:  |  Size: 84 KiB

View File

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 6.7 KiB

View File

Before

Width:  |  Height:  |  Size: 7.0 KiB

After

Width:  |  Height:  |  Size: 7.0 KiB

View File

Before

Width:  |  Height:  |  Size: 4.8 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

View File

Before

Width:  |  Height:  |  Size: 50 KiB

After

Width:  |  Height:  |  Size: 50 KiB

View File

Before

Width:  |  Height:  |  Size: 63 KiB

After

Width:  |  Height:  |  Size: 63 KiB

View File

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

View File

Before

Width:  |  Height:  |  Size: 341 KiB

After

Width:  |  Height:  |  Size: 341 KiB

View File

Before

Width:  |  Height:  |  Size: 97 KiB

After

Width:  |  Height:  |  Size: 97 KiB

View File

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

Before

Width:  |  Height:  |  Size: 6.4 KiB

After

Width:  |  Height:  |  Size: 6.4 KiB

View File

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

View File

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

View File

Before

Width:  |  Height:  |  Size: 37 KiB

After

Width:  |  Height:  |  Size: 37 KiB

View File

Before

Width:  |  Height:  |  Size: 532 KiB

After

Width:  |  Height:  |  Size: 532 KiB

View File

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

View File

Before

Width:  |  Height:  |  Size: 207 KiB

After

Width:  |  Height:  |  Size: 207 KiB

View File

Before

Width:  |  Height:  |  Size: 7.0 KiB

After

Width:  |  Height:  |  Size: 7.0 KiB

View File

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 19 KiB

View File

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

View File

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 38 KiB

View File

Before

Width:  |  Height:  |  Size: 66 KiB

After

Width:  |  Height:  |  Size: 66 KiB

View File

Before

Width:  |  Height:  |  Size: 54 KiB

After

Width:  |  Height:  |  Size: 54 KiB

View File

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View File

Before

Width:  |  Height:  |  Size: 53 KiB

After

Width:  |  Height:  |  Size: 53 KiB

View File

Before

Width:  |  Height:  |  Size: 4.1 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

View File

Before

Width:  |  Height:  |  Size: 6.0 KiB

After

Width:  |  Height:  |  Size: 6.0 KiB

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 3.6 KiB

View File

Before

Width:  |  Height:  |  Size: 5.5 KiB

After

Width:  |  Height:  |  Size: 5.5 KiB

View File

@ -183,7 +183,8 @@ MainWindow::MainWindow(bool multiple, QSettings * settings, QSharedMemory *shdme
m_messageClient {new MessageClient {QApplication::applicationName (),
m_config.udp_server_name (), m_config.udp_server_port (),
this}},
psk_Reporter {new PSK_Reporter {m_messageClient, this}}
psk_Reporter {new PSK_Reporter {m_messageClient, this}},
m_manual {network_manager}
{
ui->setupUi(this);
@ -1479,7 +1480,7 @@ void MainWindow::msgBox(QString t) //msgBox
void MainWindow::on_actionOnline_User_Guide_triggered() //Display manual
{
#if defined (CMAKE_BUILD)
QDesktopServices::openUrl (QUrl (PROJECT_MANUAL_DIRECTORY_URL "/" PROJECT_MANUAL));
m_manual.display_html_url (QUrl {PROJECT_MANUAL_DIRECTORY_URL}, PROJECT_MANUAL);
#endif
}
@ -1487,8 +1488,7 @@ void MainWindow::on_actionOnline_User_Guide_triggered() //Display manual
void MainWindow::on_actionLocal_User_Guide_triggered()
{
#if defined (CMAKE_BUILD)
auto file = m_config.doc_dir ().absoluteFilePath (PROJECT_MANUAL);
QDesktopServices::openUrl (QUrl {"file:///" + file});
m_manual.display_html_file (m_config.doc_dir (), PROJECT_MANUAL);
#endif
}

View File

@ -25,6 +25,7 @@
#include "Configuration.hpp"
#include "WSPRBandHopping.hpp"
#include "Transceiver.hpp"
#include "DisplayManual.hpp"
#include "psk_reporter.h"
#include "logbook/logbook.h"
#include "decodedtext.h"
@ -521,6 +522,7 @@ private:
QTimer m_heartbeat;
MessageClient * m_messageClient;
PSK_Reporter *psk_Reporter;
DisplayManual m_manual;
//---------------------------------------------------- private functions
void readSettings();