Skip to content

Commit 6d55645

Browse files
committed
Fix entries (such as neighbour) that had spaces after some tags in the translation
1 parent f88da9e commit 6d55645

File tree

5 files changed

+28
-4
lines changed

5 files changed

+28
-4
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,4 @@ Per a més informació de l'instal·lació: veure [INSTALL.ca.md](INSTALL.ca.md)
5252

5353
![qdacco](docs/images/preferences-advanced.png)
5454

55-
Carles Pina i Estany ([email protected]), 2005-2023
55+
Carles Pina i Estany ([email protected]), 2005-2024

gui/AuxiliarGUI.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
void *AuxiliarGUI::m=nullptr;
99

1010
QString AuxiliarGUI::version = QDACCO_VERSION;
11-
QString AuxiliarGUI::copyright_date = "2005-2009, 2011, 2013, 2015, 2017, 2020-2023";
11+
QString AuxiliarGUI::copyright_date = "2005-2009, 2011, 2013, 2015, 2017, 2020-2024";
1212

1313
QString AuxiliarGUI::getVersion() {
1414
return version;

nongui/StructureList.cpp

+24-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* This file is part of qdacco
33
* qdacco: offline Dacco Catalan <-> English dictionary
44
*
5-
* Copyright (c) 2005, 2006, 2007, 2015, 2020, 2021, 2023
5+
* Copyright (c) 2005, 2006, 2007, 2015, 2020, 2021, 2023-2024
66
* Carles Pina i Estany <[email protected]>
77
*
88
* qdacco is free software; you can redistribute it and/or modify
@@ -101,6 +101,8 @@ void StructureList::startElement(QXmlStreamReader& reader) {
101101
m_inFemPlural = true;
102102
} else if (qName == "synonyms") {
103103
m_inSynonyms = true;
104+
} else if (qName == "otherlocal") {
105+
m_inOtherLocal = true;
104106
} else if (exampleElements.contains(qName)) {
105107
m_inExample = true;
106108
} else if (noteElements.contains(qName)) {
@@ -146,6 +148,8 @@ void StructureList::endElement(QXmlStreamReader& reader) {
146148
}
147149
else if (qName == "synonyms") {
148150
m_inSynonyms = false;
151+
} else if (qName == "otherlocal") {
152+
m_inOtherLocal = false;
149153
}
150154
if (exampleElements.contains(qName)) {
151155
m_inExample = false;
@@ -194,6 +198,7 @@ void StructureList::processEntry(QXmlStreamReader& reader) {
194198
m_inTranslation = false;
195199
m_inExample = false;
196200
m_inPlural = false;
201+
m_inOtherLocal = false;
197202
m_inNote = false;
198203
m_inFems = false;
199204
m_inFemPlural = false;
@@ -216,6 +221,11 @@ void StructureList::processEntry(QXmlStreamReader& reader) {
216221
if (m_inTranslation && m_inPlural) {
217222
m_translation.plural = ch;
218223
}
224+
if (m_inTranslation && m_inOtherLocal) {
225+
// This is added but not used in the UI
226+
// (it also needs to read the "local="us" and then show it as British local)
227+
m_translation.otherLocal = ch;
228+
}
219229
else if (m_inTranslation && m_inSynonyms) {
220230
m_translation.synonyms = ch;
221231
}
@@ -244,7 +254,19 @@ void StructureList::processEntry(QXmlStreamReader& reader) {
244254
m_translation.femalePlural = ch;
245255
}
246256
else if (m_inTranslation) {
247-
m_translation.translation = ch;
257+
/* There are entries where the "translation" is between different parts. For example:
258+
*
259+
* <Entry frequency="17500000">neighbor<nouns><translations><translation gender="mf" local="us">veí<otherlocal>neighbour</otherlocal>
260+
*
261+
* </translation></translations></nouns>
262+
*
263+
* </Entry>
264+
* Since there are empty spaces after </otherlocal> and before </translation>,
265+
* the m_translation.translation = ch; was removing the previous text added in the translation.
266+
* Now it's adding it trimmed so "veí" stays, and if there was some other meaningul text it would
267+
* be added.
268+
*/
269+
m_translation.translation += ch.trimmed();
248270
}
249271
else if (m_inExpressions) {
250272
m_expressions.expression = ch;

nongui/StructureList.h

+1
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ class StructureList
114114
bool m_inEngAcro;
115115
bool m_inMistakes;
116116
bool m_inSynonyms;
117+
bool m_inOtherLocal;
117118

118119
Translation m_translation;
119120
Expressions m_expressions;

nongui/WordData.h

+1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ struct Translation {
7777
QStringList examples;
7878
QStringList notes;
7979
QString plural;
80+
QString otherLocal;
8081

8182
QString catagory;
8283
QString gender;

0 commit comments

Comments
 (0)