Skip to content

Commit

Permalink
converter: Handle missing Stellarium locales more gracefully
Browse files Browse the repository at this point in the history
  • Loading branch information
10110111 committed Feb 3, 2025
1 parent 8b8bb78 commit a2af61d
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion util/skyculture-converter/DescriptionOldLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1162,7 +1162,22 @@ bool DescriptionOldLoader::dump(const QString& outDir) const
po_message_iterator_t iterator = po_message_iterator(file, nullptr);

// I've found no API to *create* a header, so will try to emulate it with a message
const auto header = poHeaders[locale];
const auto headerIt = poHeaders.find(locale);
if(headerIt == poHeaders.end())
{
qWarning().nospace() << "WARNING: No header for locale " << locale << " found. "
"This could mean that either this locale is not supported by Stellarium, "
"or its designation in the description file name is wrong.";
}
static const auto defaultHeaderTemplate = QLatin1String(
"Project-Id-Version: PACKAGE VERSION\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: %1\n");
const QString header = headerIt == poHeaders.end() ?
defaultHeaderTemplate.arg(locale) :
headerIt.value();
const auto headerMsg = po_message_create();
po_message_set_msgid(headerMsg, "");
po_message_set_msgstr(headerMsg, header.toStdString().c_str());
Expand Down

0 comments on commit a2af61d

Please sign in to comment.