Skip to content

Commit

Permalink
fix PO parser error for files starting with a comment and msgctxt
Browse files Browse the repository at this point in the history
  • Loading branch information
y5nw committed Oct 12, 2024
1 parent c3284b3 commit 6a83ee5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# Dummy entry. This is a test to make sure that a parser error is not thrown
# if the following line is msgctxt.
msgctxt "testtranslations"
msgid "Dummy entry"
msgstr "Dummy result"

# Used for translating the mod title
msgid "Test translations"
msgstr "Test translations (French)"
16 changes: 9 additions & 7 deletions src/translation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,13 +450,15 @@ void Translations::loadPoTranslation(const std::string &basefilename, const std:
auto prefix = parsed->first;
auto s = parsed->second;

if (prefix == L"#" && s[0] == L',') {
// Skip fuzzy entries
if ((s + L' ').find(L" fuzzy ") != line.npos) {
if (last_entry.empty())
skip_last = true;
else
skip = true;
if (prefix == L"#") {
if (s[0] == L',') {
// Skip fuzzy entries
if ((s + L' ').find(L" fuzzy ") != line.npos) {
if (last_entry.empty())
skip_last = true;
else
skip = true;
}
}
continue;
}
Expand Down

0 comments on commit 6a83ee5

Please sign in to comment.