Skip to content

Commit

Permalink
subtitles: use builtin plural support
Browse files Browse the repository at this point in the history
Currently, the source code on subtitles either assumes subtitle items
to be always in plural form or tries determines plural form by itself.

This commit fixes that by using builtin `QObject::tr` plural support.
  • Loading branch information
rschiang committed Jan 16, 2025
1 parent 0abb1de commit c4ea372
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions src/commands/subtitlecommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ OverwriteSubtitlesCommand::OverwriteSubtitlesCommand(SubtitlesModel &model, int
if (m_newSubtitles.size() == 1) {
setText(QObject::tr("Add subtitle"));
} else {
setText(QObject::tr("Add %1 subtitles").arg(m_newSubtitles.size()));
setText(QObject::tr("Add %n subtitles", nullptr, m_newSubtitles.size()));
}

if (m_newSubtitles.size() <= 0) {
Expand Down Expand Up @@ -155,7 +155,7 @@ RemoveSubtitlesCommand::RemoveSubtitlesCommand(SubtitlesModel &model, int trackI
if (m_items.size() == 1) {
setText(QObject::tr("Remove subtitle"));
} else {
setText(QObject::tr("Remove %1 subtitles").arg(m_items.size()));
setText(QObject::tr("Remove %n subtitles", nullptr, m_items.size()));
}
}

Expand Down Expand Up @@ -288,7 +288,7 @@ MoveSubtitlesCommand::MoveSubtitlesCommand(SubtitlesModel &model, int trackIndex
if (m_oldSubtitles.size() == 1) {
setText(QObject::tr("Move subtitle"));
} else {
setText(QObject::tr("Move %1 subtitles").arg(m_oldSubtitles.size()));
setText(QObject::tr("Move %n subtitles", nullptr, m_oldSubtitles.size()));
}
// Create a list of subtitles with the new times
int64_t delta = msTime - m_oldSubtitles[0].start;
Expand Down
4 changes: 2 additions & 2 deletions src/docks/subtitlesdock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ void SubtitlesDock::importSrtFromFile(const QString &srtPath, const QString &tra

m_model->importSubtitlesToNewTrack(track, items);

MAIN.showStatusMessage(QObject::tr("Imported %1 subtitle items").arg(items.size()));
MAIN.showStatusMessage(QObject::tr("Imported %1 subtitle item(s)", nullptr, items.size()));
}

void SubtitlesDock::addSubtitleTrack()
Expand Down Expand Up @@ -623,7 +623,7 @@ void SubtitlesDock::importSubtitles()
}
ensureTrackExists();
m_model->importSubtitles(m_trackCombo->currentIndex(), msTime, items);
MAIN.showStatusMessage(QObject::tr("Imported %1 subtitle items").arg(items.size()));
MAIN.showStatusMessage(QObject::tr("Imported %n subtitle item(s)", nullptr, items.size()));
}

void SubtitlesDock::exportSubtitles()
Expand Down

0 comments on commit c4ea372

Please sign in to comment.