Skip to content

Commit

Permalink
Fix entries (such as neighbour) that had spaces after some tags in th…
Browse files Browse the repository at this point in the history
…e translation
  • Loading branch information
cpina committed Feb 2, 2024
1 parent f88da9e commit 6d55645
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ Per a més informació de l'instal·lació: veure [INSTALL.ca.md](INSTALL.ca.md)

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

Carles Pina i Estany ([email protected]), 2005-2023
Carles Pina i Estany ([email protected]), 2005-2024
2 changes: 1 addition & 1 deletion gui/AuxiliarGUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
void *AuxiliarGUI::m=nullptr;

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

QString AuxiliarGUI::getVersion() {
return version;
Expand Down
26 changes: 24 additions & 2 deletions nongui/StructureList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* This file is part of qdacco
* qdacco: offline Dacco Catalan <-> English dictionary
*
* Copyright (c) 2005, 2006, 2007, 2015, 2020, 2021, 2023
* Copyright (c) 2005, 2006, 2007, 2015, 2020, 2021, 2023-2024
* Carles Pina i Estany <[email protected]>
*
* qdacco is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -101,6 +101,8 @@ void StructureList::startElement(QXmlStreamReader& reader) {
m_inFemPlural = true;
} else if (qName == "synonyms") {
m_inSynonyms = true;
} else if (qName == "otherlocal") {
m_inOtherLocal = true;
} else if (exampleElements.contains(qName)) {
m_inExample = true;
} else if (noteElements.contains(qName)) {
Expand Down Expand Up @@ -146,6 +148,8 @@ void StructureList::endElement(QXmlStreamReader& reader) {
}
else if (qName == "synonyms") {
m_inSynonyms = false;
} else if (qName == "otherlocal") {
m_inOtherLocal = false;
}
if (exampleElements.contains(qName)) {
m_inExample = false;
Expand Down Expand Up @@ -194,6 +198,7 @@ void StructureList::processEntry(QXmlStreamReader& reader) {
m_inTranslation = false;
m_inExample = false;
m_inPlural = false;
m_inOtherLocal = false;
m_inNote = false;
m_inFems = false;
m_inFemPlural = false;
Expand All @@ -216,6 +221,11 @@ void StructureList::processEntry(QXmlStreamReader& reader) {
if (m_inTranslation && m_inPlural) {
m_translation.plural = ch;
}
if (m_inTranslation && m_inOtherLocal) {
// This is added but not used in the UI
// (it also needs to read the "local="us" and then show it as British local)
m_translation.otherLocal = ch;
}
else if (m_inTranslation && m_inSynonyms) {
m_translation.synonyms = ch;
}
Expand Down Expand Up @@ -244,7 +254,19 @@ void StructureList::processEntry(QXmlStreamReader& reader) {
m_translation.femalePlural = ch;
}
else if (m_inTranslation) {
m_translation.translation = ch;
/* There are entries where the "translation" is between different parts. For example:
*
* <Entry frequency="17500000">neighbor<nouns><translations><translation gender="mf" local="us">veí<otherlocal>neighbour</otherlocal>
*
* </translation></translations></nouns>
*
* </Entry>
* Since there are empty spaces after </otherlocal> and before </translation>,
* the m_translation.translation = ch; was removing the previous text added in the translation.
* Now it's adding it trimmed so "veí" stays, and if there was some other meaningul text it would
* be added.
*/
m_translation.translation += ch.trimmed();
}
else if (m_inExpressions) {
m_expressions.expression = ch;
Expand Down
1 change: 1 addition & 0 deletions nongui/StructureList.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ class StructureList
bool m_inEngAcro;
bool m_inMistakes;
bool m_inSynonyms;
bool m_inOtherLocal;

Translation m_translation;
Expressions m_expressions;
Expand Down
1 change: 1 addition & 0 deletions nongui/WordData.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ struct Translation {
QStringList examples;
QStringList notes;
QString plural;
QString otherLocal;

QString catagory;
QString gender;
Expand Down

0 comments on commit 6d55645

Please sign in to comment.