Fix Failed to load translation for English

- Add patch:
  cppcheck-2.5-fix_failed_to_load_translation_for_English.patch
- Fixes: #1983599
This commit is contained in:
Wolfgang Stöggl 2021-07-23 21:54:42 +02:00
parent e2c1dbb34c
commit 6f85fa2223
2 changed files with 41 additions and 1 deletions

View File

@ -0,0 +1,33 @@
From 8d5249e3b6cd892b283eba0369b33ec302c8fbe0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Wolfgang=20St=C3=B6ggl?= <c72578@yahoo.de>
Date: Fri, 23 Jul 2021 19:27:53 +0200
Subject: [PATCH] Fix Failed to load translation for English (#3351)
Upon the first start of cppcheck-gui, the following message appears,
if the language of the OS is English:
Failed to load the user interface language:
Failed to load translation for language English from file
cppcheck_en.qm
The user interface language has been reset to English.
- Update translationhandler.cpp and check if the language code starts
with "en". The code can be e.g. "en_US"
---
gui/translationhandler.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/gui/translationhandler.cpp b/gui/translationhandler.cpp
index e00829e2008..5c27eb4ec0c 100644
--- a/gui/translationhandler.cpp
+++ b/gui/translationhandler.cpp
@@ -86,8 +86,8 @@ bool TranslationHandler::setLanguage(const QString &code)
bool failure = false;
QString error;
- //If English is the language
- if (code == "en") {
+ //If English is the language. Code can be e.g. en_US
+ if (code.indexOf("en") == 0) {
//Just remove all extra translators
if (mTranslator) {
qApp->removeTranslator(mTranslator);

View File

@ -2,7 +2,7 @@
Name: cppcheck
Version: 2.5
Release: 2%{?dist}
Release: 3%{?dist}
Summary: Tool for static C/C++ code analysis
License: GPLv3+
URL: http://cppcheck.wiki.sourceforge.net/
@ -15,6 +15,9 @@ Patch1: cppcheck-1.88-htmlreport-python3.patch
# Disable one test, which fails under 32-bit archs i686 and armv7hl
# https://trac.cppcheck.net/ticket/10282
Patch2: cppcheck-2.5-disable-test-testexprengine-array7.patch
# Fix Failed to load translation for English (#1983599)
# https://github.com/danmar/cppcheck/commit/8d5249e3b6cd892b283eba0369b33ec302c8fbe0
Patch3: cppcheck-2.5-fix_failed_to_load_translation_for_English.patch
BuildRequires: gcc-c++
BuildRequires: pcre-devel
@ -62,6 +65,7 @@ from xml files first generated using cppcheck.
%patch0 -p1 -b .translations
%patch1 -p1 -b .python3
%patch2 -p1 -b .array7
%patch3 -p1 -b .en
# Make sure bundled tinyxml2 is not used
rm -r externals/tinyxml2
# Generate the Qt online-help file
@ -118,6 +122,9 @@ cd %{_vpath_builddir}/bin
%{_bindir}/cppcheck-htmlreport
%changelog
* Fri Jul 23 2021 Wolfgang Stöggl <c72578@yahoo.de> - 2.5-3
- Fix Failed to load translation for English (#1983599)
* Wed Jul 21 2021 Fedora Release Engineering <releng@fedoraproject.org> - 2.5-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild