Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch skycultures to the new format #3751

Open
wants to merge 45 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
c105f2a
Move common DSO and star names from modern_iau to a common dir
10110111 Mar 12, 2024
8766da9
Remove all old sky cultures
10110111 Jan 9, 2025
810fdc5
Rename stellarium-skycultures -> stellarium-sky
10110111 Jan 9, 2025
7d40ff7
Update stellarium-sky.pot
10110111 Jan 13, 2025
262e42c
Update stellarium-sky translations by the new .pot file
10110111 Jan 13, 2025
83f3a98
Add a script to import new-format sky cultures
10110111 May 17, 2024
3611d16
Import eligible cultures from stellarium-skycultures
10110111 Jan 13, 2025
bc41ab1
Pass StelSkyCulture instead of dir to SC parsers
10110111 May 2, 2024
5fe2ed9
Start adding support for new sky cultures format
10110111 May 2, 2024
1fbd42c
Implement reading asterisms in new format
10110111 May 7, 2024
66cad50
Implement reading constellations in new format
10110111 May 7, 2024
775e6bf
Fallback to global dictionary for constellations translation
10110111 Jan 25, 2024
c206a4b
Implement loading culture-specific DSO names
10110111 May 7, 2024
765a45c
Implement loading of Solar system names
10110111 May 7, 2024
7dad1b0
Implement loading culture-specific star names
10110111 May 7, 2024
5f08287
Add support for loading new sky culture format translators in StelLoc…
10110111 Jan 15, 2024
2ad1577
Translate sky culture description and name
10110111 Jun 11, 2024
7b89b83
Translate planet names
10110111 Jan 17, 2024
297be0d
Add support for Chinese translations of Chinese cultures
10110111 Mar 11, 2024
a2cdd36
Add a converter for sky cultures from old format to new
10110111 Mar 19, 2024
764a57c
Add a tool to generate pot files for sky cultures
10110111 Jan 15, 2025
5678b40
Update/create stellarium-skycultures{,-descriptions}.pot
10110111 Jan 15, 2025
078bae7
Restore deleted additional SC files
10110111 Jan 20, 2025
e0ad684
Update SC description po files by the new .pot
10110111 Jan 20, 2025
871db3c
Load default DSO names if none are specified in current SC
10110111 Jan 20, 2025
dd11e41
Update transifex.yml to point to stellarium-sky
10110111 Jan 27, 2025
d54f8bc
converter: Add comments for object names in po files
10110111 Jan 28, 2025
e8ef175
converter: Avoid duplicate msgid in po files
10110111 Jan 30, 2025
fc2605b
converter: don't report duplicates, just remove them silently
10110111 Jan 31, 2025
f171618
converter: Don't forget to trim native name of a constellation
10110111 Jan 31, 2025
fa3b957
converter: add a find_package call for gettextpo
10110111 Feb 2, 2025
cfe4b9c
converter: Add missing include
10110111 Feb 2, 2025
a48c9c9
converter: fix a typo
10110111 Feb 2, 2025
8b8bb78
converter: Try to make sure we are able to extract culture id
10110111 Feb 3, 2025
a2af61d
converter: Handle missing Stellarium locales more gracefully
10110111 Feb 3, 2025
221bb34
constellations: Don't forget to enable seasonal rules after successfu…
10110111 Feb 3, 2025
9c4e61c
SCManager: simplify handling license lines
10110111 Feb 3, 2025
072df96
asterisms: fix reading long integers
10110111 Feb 3, 2025
d8d76fe
constellations: fix reading long integers
10110111 Feb 3, 2025
3c8ef55
asterisms: report failure to parse a number; fix a type check
10110111 Feb 3, 2025
e0f569b
asterism: Rename asterism types
10110111 Feb 3, 2025
5917787
converter: use a reference instead of a copy
10110111 Feb 3, 2025
57bb1a1
converter: switch to Qt6
10110111 Feb 3, 2025
29bdce0
converter: add comments for asterism names too
10110111 Feb 3, 2025
12a8373
converter: fix check for presence of asterism files
10110111 Feb 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 28 additions & 59 deletions src/core/modules/SolarSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -537,72 +537,43 @@ void SolarSystem::updateSkyCulture(const StelSkyCulture& skyCulture)
planetNativeNamesMap.clear();
planetNativeNamesMeaningMap.clear();

QString namesFile = skyCulture.path + "/planet_names.fab";
if (!skyCulture.names.isEmpty())
loadCultureSpecificNames(skyCulture.names);

if (!QFileInfo(namesFile).exists())
{
for (const auto& p : std::as_const(systemPlanets))
{
if (p->getPlanetType()==Planet::isPlanet || p->getPlanetType()==Planet::isMoon || p->getPlanetType()==Planet::isStar)
{
p->setNativeName("");
p->setNativeNameMeaning("");
}
}
updateI18n();
return;
}

// Open file
QFile planetNamesFile(namesFile);
if (!planetNamesFile.open(QIODevice::ReadOnly | QIODevice::Text))
{
qDebug() << " Cannot open file" << QDir::toNativeSeparators(namesFile);
return;
}

// Now parse the file
// lines to ignore which start with a # or are empty
static const QRegularExpression commentRx("^(\\s*#.*|\\s*)$");

// lines which look like records - we use the RE to extract the fields
// which will be available in recRx.capturedTexts()
static const QRegularExpression recRx("^\\s*(\\w+)\\s+\"(.+)\"\\s+_[(]\"(.+)\"[)]\\n");

QString record, planetId, nativeName, nativeNameMeaning;
updateI18n();
}

// keep track of how many records we processed.
int totalRecords=0;
int readOk=0;
int lineNumber=0;
while (!planetNamesFile.atEnd())
void SolarSystem::loadCultureSpecificNames(const QJsonObject& data)
{
for (auto it = data.begin(); it != data.end(); ++it)
{
record = QString::fromUtf8(planetNamesFile.readLine());
lineNumber++;
const auto key = it.key();
const auto specificNames = it->toArray();

// Skip comments
if (commentRx.match(record).hasMatch())
continue;

totalRecords++;

QRegularExpressionMatch match=recRx.match(record);
if (!match.hasMatch())
if (key.startsWith("NAME "))
{
qWarning() << "ERROR - cannot parse record at line" << lineNumber << "in planet names file" << QDir::toNativeSeparators(namesFile);
}
else
{
planetId = match.captured(1).trimmed();
nativeName = match.captured(2).trimmed();
nativeNameMeaning = match.captured(3).trimmed();
const auto planetId = key.mid(5);
const auto names = it.value().toArray();

// We store only one name per planet, so just take the first valid one
// FIXME: maybe we should somehow store all
gzotti marked this conversation as resolved.
Show resolved Hide resolved
QString nativeName, nativeNameMeaning;
for (const auto& nameVal : names)
{
const auto nameObj = nameVal.toObject();
if (nameObj.find("english") == nameObj.end())
continue;
nativeNameMeaning = nameObj["english"].toString();
if (nameObj.find("native") != nameObj.end())
nativeName = nameObj["native"].toString();
else
nativeName = nativeNameMeaning;
break;
}
planetNativeNamesMap[planetId] = nativeName;
planetNativeNamesMeaningMap[planetId] = nativeNameMeaning;
readOk++;
}
}
planetNamesFile.close();
qDebug() << "Loaded" << readOk << "/" << totalRecords << "native names of planets";

for (const auto& p : std::as_const(systemPlanets))
{
Expand All @@ -612,8 +583,6 @@ void SolarSystem::updateSkyCulture(const StelSkyCulture& skyCulture)
p->setNativeNameMeaning(planetNativeNamesMeaningMap[p->getEnglishName()]);
}
}

updateI18n();
}

void SolarSystem::reloadShaders()
Expand Down
2 changes: 2 additions & 0 deletions src/core/modules/SolarSystem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -941,6 +941,8 @@ private slots:
//! Loads native names of planets for a given sky culture.
void updateSkyCulture(const StelSkyCulture& skyCulture);

void loadCultureSpecificNames(const QJsonObject& data);

//! Called following StelMainView::reloadShadersRequested
void reloadShaders();

Expand Down