Use wide character logging for efficiency as most o/p is QString

This commit is contained in:
Bill Somerville
2020-09-26 14:15:44 +01:00
parent db9b2d538d
commit 1d43ddd38b
14 changed files with 116 additions and 107 deletions
+18 -18
View File
@@ -67,7 +67,7 @@ L10nLoader::L10nLoader (QApplication * app, QLocale const& locale, QString const
.arg (QLocale::languageToString (locale.language ()))
.arg (QLocale::scriptToString (locale.script ()))
.arg (QLocale::countryToString (locale.country ()))
.arg (locale.uiLanguages ().join (", ")));
.arg (locale.uiLanguages ().join (", ")).toStdWString ());
// we don't load translators if the language override is 'en',
// 'en_US', or 'en-US'. In these cases we assume the user is trying
@@ -81,7 +81,7 @@ L10nLoader::L10nLoader (QApplication * app, QLocale const& locale, QString const
QString translations_dir {":/Translations"};
if (!skip_locale)
{
LOG_INFO ("Looking for locale based Qt translations in resources filesystem");
LOG_TRACE ("Looking for locale based Qt translations in resources filesystem");
if (m_->load_translator (locale, "qt", "_", translations_dir))
{
LOG_INFO ("Loaded Qt translations for current locale from resources");
@@ -99,25 +99,25 @@ L10nLoader::L10nLoader (QApplication * app, QLocale const& locale, QString const
// source control for translators to access and update.
// try and load the base translation
LOG_INFO ("Looking for WSJT-X translations based on UI languages in the resources filesystem");
LOG_TRACE ("Looking for WSJT-X translations based on UI languages in the resources filesystem");
for (QString locale_name : locale.uiLanguages ())
{
auto language = locale_name.left (2);
if (locale.uiLanguages ().front ().left (2) == language)
{
LOG_TRACE (QString {"Trying %1"}.arg (language));
LOG_TRACE (QString {"Trying %1"}.arg (language).toStdWString ());
if (m_->load_translator ("wsjtx_" + language, translations_dir))
{
LOG_INFO (QString {"Loaded WSJT-X base translation file from %1 based on language %2"}
.arg (translations_dir)
.arg (language));
.arg (language).toStdWString ());
break;
}
}
}
// now try and load the most specific translations (may be a
// duplicate but we shouldn't care)
LOG_INFO ("Looking for WSJT-X translations based on locale in the resources filesystem");
LOG_TRACE ("Looking for WSJT-X translations based on locale in the resources filesystem");
if (m_->load_translator (locale, "wsjtx", "_", translations_dir))
{
LOG_INFO ("Loaded WSJT-X translations for current locale from resources");
@@ -136,21 +136,21 @@ L10nLoader::L10nLoader (QApplication * app, QLocale const& locale, QString const
language.replace ('-', '_');
// try and load the base translation
auto base_language = language.left (2);
LOG_INFO ("Looking for WSJT-X translations based on command line region override in the resources filesystem");
LOG_TRACE ("Looking for WSJT-X translations based on command line region override in the resources filesystem");
if (m_->load_translator ("wsjtx_" + base_language, translations_dir))
{
LOG_INFO (QString {"Loaded base translation file from %1 based on language %2"}
.arg (translations_dir)
.arg (base_language));
.arg (base_language).toStdWString ());
}
// now load the requested translations (may be a duplicate
// but we shouldn't care)
LOG_INFO ("Looking for WSJT-X translations based on command line override country in the resources filesystem");
LOG_TRACE ("Looking for WSJT-X translations based on command line override country in the resources filesystem");
if (m_->load_translator ("wsjtx_" + language, translations_dir))
{
LOG_INFO (QString {"Loaded translation file from %1 based on language %2"}
.arg (translations_dir)
.arg (language));
.arg (language).toStdWString ());
}
}
@@ -163,16 +163,16 @@ L10nLoader::L10nLoader (QApplication * app, QLocale const& locale, QString const
// the LANG environment variable on non-Windows system.
// try and load the base translation
LOG_INFO ("Looking for WSJT-X translations based on command line override country in the current directory");
LOG_TRACE ("Looking for WSJT-X translations based on command line override country in the current directory");
for (QString locale_name : locale.uiLanguages ())
{
auto language = locale_name.left (2);
if (locale.uiLanguages ().front ().left (2) == language)
{
LOG_TRACE (QString {"Trying %1"}.arg (language));
LOG_TRACE (QString {"Trying %1"}.arg (language).toStdWString ());
if (m_->load_translator ("wsjtx_" + language))
{
LOG_INFO (QString {"Loaded base translation file from $cwd based on language %1"}.arg (language));
LOG_INFO (QString {"Loaded base translation file from $cwd based on language %1"}.arg (language).toStdWString ());
break;
}
}
@@ -182,7 +182,7 @@ L10nLoader::L10nLoader (QApplication * app, QLocale const& locale, QString const
{
// now try and load the most specific translations (may be a
// duplicate but we shouldn't care)
LOG_INFO ("Looking for WSJT-X translations based on locale in the resources filesystem");
LOG_TRACE ("Looking for WSJT-X translations based on locale in the resources filesystem");
if (m_->load_translator (locale, "wsjtx", "_"))
{
LOG_INFO ("loaded translations for current locale from a file");
@@ -201,17 +201,17 @@ L10nLoader::L10nLoader (QApplication * app, QLocale const& locale, QString const
language.replace ('-', '_');
// try and load the base translation
auto base_language = language.left (2);
LOG_INFO ("Looking for WSJT-X translations based on command line override country in the current directory");
LOG_TRACE ("Looking for WSJT-X translations based on command line override country in the current directory");
if (m_->load_translator ("wsjtx_" + base_language))
{
LOG_INFO (QString {"Loaded base translation file from $cwd based on language %1"}.arg (base_language));
LOG_INFO (QString {"Loaded base translation file from $cwd based on language %1"}.arg (base_language).toStdWString ());
}
// now load the requested translations (may be a duplicate
// but we shouldn't care)
LOG_INFO ("Looking for WSJT-X translations based on command line region in the current directory");
LOG_TRACE ("Looking for WSJT-X translations based on command line region in the current directory");
if (m_->load_translator ("wsjtx_" + language))
{
LOG_INFO (QString {"loaded translation file from $cwd based on language %1"}.arg (language));
LOG_INFO (QString {"loaded translation file from $cwd based on language %1"}.arg (language).toStdWString ());
}
}
}