Fix plural handling for translations (#1424)

* .arg() doesn't handle plurals, replace %1 with %n and pass number to tr(), but only if there is an accompanying word for that we want singular/plural translations and only for whole numbers.

* Qt's translation methods only accept integers and we don't know what grammatical number form would be correct for floating-point numbers in different languages anyway.

* Add optional 2nd argument to SliderBase::SetFormat() to activate deferred plural handling:
  SetFormat(QT_TRANSLATE_N_NOOP("olive::SliderBase", "%n unit(s)"), true)

* Generate en_US.ts with lupdate's -pluralonly option. Only source strings that require plural handling need to be translated (as long as the source language is American English).
This commit is contained in:
Simran
2021-04-13 00:58:46 +02:00
committed by GitHub
parent c03c197412
commit fca485bd69
10 changed files with 58 additions and 4759 deletions
@@ -69,7 +69,7 @@ PreferencesDiskTab::PreferencesDiskTab()
cache_behavior_layout->addWidget(new QLabel(tr("Cache Ahead:")), row, 0);
cache_ahead_slider_ = new FloatSlider();
cache_ahead_slider_->SetFormat(tr("%1 second(s)"));
cache_ahead_slider_->SetFormat(tr("%1 seconds"));
cache_ahead_slider_->SetMinimum(0);
cache_ahead_slider_->SetValue(Config::Current()["DiskCacheAhead"].value<rational>().toDouble());
cache_behavior_layout->addWidget(cache_ahead_slider_, row, 1);
@@ -78,7 +78,7 @@ PreferencesDiskTab::PreferencesDiskTab()
cache_behind_slider_ = new FloatSlider();
cache_behind_slider_->SetMinimum(0);
cache_behind_slider_->SetFormat(tr("%1 second(s)"));
cache_behind_slider_->SetFormat(tr("%1 seconds"));
cache_behind_slider_->SetValue(Config::Current()["DiskCacheBehind"].value<rational>().toDouble());
cache_behavior_layout->addWidget(cache_behind_slider_, row, 3);