Add support for plural forms in Qt forms
This commit is contained in:
parent
4436e86a46
commit
edeed89648
|
@ -116,6 +116,7 @@ endif()
|
||||||
|
|
||||||
set(TS_FILES
|
set(TS_FILES
|
||||||
translations/duckstation-qt_de.ts
|
translations/duckstation-qt_de.ts
|
||||||
|
translations/duckstation-qt_en.ts
|
||||||
translations/duckstation-qt_es.ts
|
translations/duckstation-qt_es.ts
|
||||||
translations/duckstation-qt_fr.ts
|
translations/duckstation-qt_fr.ts
|
||||||
translations/duckstation-qt_he.ts
|
translations/duckstation-qt_he.ts
|
||||||
|
|
|
@ -83,8 +83,7 @@ void AudioSettingsWidget::updateBufferingLabel()
|
||||||
}
|
}
|
||||||
|
|
||||||
const float max_latency = AudioStream::GetMaxLatency(HostInterface::AUDIO_SAMPLE_RATE, actual_buffer_size);
|
const float max_latency = AudioStream::GetMaxLatency(HostInterface::AUDIO_SAMPLE_RATE, actual_buffer_size);
|
||||||
m_ui.bufferingLabel->setText(tr("Maximum Latency: %1 frames (%2ms)")
|
m_ui.bufferingLabel->setText(tr("Maximum Latency: %n frames (%1ms)", "", actual_buffer_size)
|
||||||
.arg(actual_buffer_size)
|
|
||||||
.arg(static_cast<double>(max_latency) * 1000.0, 0, 'f', 2));
|
.arg(static_cast<double>(max_latency) * 1000.0, 0, 'f', 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -286,6 +286,9 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<QtTs Include="translations\duckstation-qt_de.ts">
|
<QtTs Include="translations\duckstation-qt_de.ts">
|
||||||
<FileType>Document</FileType>
|
<FileType>Document</FileType>
|
||||||
|
</QtTs>
|
||||||
|
<QtTs Include="translations\duckstation-qt_en.ts">
|
||||||
|
<FileType>Document</FileType>
|
||||||
</QtTs>
|
</QtTs>
|
||||||
<QtTs Include="translations\duckstation-qt_es.ts">
|
<QtTs Include="translations\duckstation-qt_es.ts">
|
||||||
<FileType>Document</FileType>
|
<FileType>Document</FileType>
|
||||||
|
|
|
@ -180,6 +180,9 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<QtTs Include="translations\duckstation-qt_de.ts">
|
<QtTs Include="translations\duckstation-qt_de.ts">
|
||||||
<Filter>translations</Filter>
|
<Filter>translations</Filter>
|
||||||
|
</QtTs>
|
||||||
|
<QtTs Include="translations\duckstation-qt_en.ts">
|
||||||
|
<Filter>translations</Filter>
|
||||||
</QtTs>
|
</QtTs>
|
||||||
<QtTs Include="translations\duckstation-qt_es.ts">
|
<QtTs Include="translations\duckstation-qt_es.ts">
|
||||||
<Filter>translations</Filter>
|
<Filter>translations</Filter>
|
||||||
|
|
|
@ -121,8 +121,7 @@ void EmulationSettingsWidget::updateRewind()
|
||||||
System::CalculateRewindMemoryUsage(frames, &ram_usage, &vram_usage);
|
System::CalculateRewindMemoryUsage(frames, &ram_usage, &vram_usage);
|
||||||
|
|
||||||
m_ui.rewindSummary->setText(
|
m_ui.rewindSummary->setText(
|
||||||
tr("Rewind for %1 frames, lasting %2 seconds will require up to %3MB of RAM and %4MB of VRAM.")
|
tr("Rewind for %n frame(s), lasting %1 second(s) will require up to %2MB of RAM and %3MB of VRAM.", "", frames)
|
||||||
.arg(frames)
|
|
||||||
.arg(duration)
|
.arg(duration)
|
||||||
.arg(ram_usage / 1048576)
|
.arg(ram_usage / 1048576)
|
||||||
.arg(vram_usage / 1048576));
|
.arg(vram_usage / 1048576));
|
||||||
|
|
|
@ -36,7 +36,7 @@ void InputBindingWidget::updateText()
|
||||||
if (m_bindings.empty())
|
if (m_bindings.empty())
|
||||||
setText(QString());
|
setText(QString());
|
||||||
else if (m_bindings.size() > 1)
|
else if (m_bindings.size() > 1)
|
||||||
setText(tr("%1 bindings").arg(m_bindings.size()));
|
setText(tr("%n bindings", "", m_bindings.size()));
|
||||||
else
|
else
|
||||||
setText(QString::fromStdString(m_bindings[0]));
|
setText(QString::fromStdString(m_bindings[0]));
|
||||||
}
|
}
|
||||||
|
|
|
@ -215,7 +215,7 @@ void MemoryCardEditorDialog::updateCardBlocksFree(Card* card)
|
||||||
{
|
{
|
||||||
card->blocks_free = MemoryCardImage::GetFreeBlockCount(card->data);
|
card->blocks_free = MemoryCardImage::GetFreeBlockCount(card->data);
|
||||||
card->blocks_free_label->setText(
|
card->blocks_free_label->setText(
|
||||||
tr("%1 blocks free%2").arg(card->blocks_free).arg(card->dirty ? QStringLiteral(" (*)") : QString()));
|
tr("%n block(s) free%1", "", card->blocks_free).arg(card->dirty ? QStringLiteral(" (*)") : QString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MemoryCardEditorDialog::setCardDirty(Card* card)
|
void MemoryCardEditorDialog::setCardDirty(Card* card)
|
||||||
|
|
|
@ -64,7 +64,7 @@ const char* QtHostInterface::GetFrontendName() const
|
||||||
|
|
||||||
std::vector<std::pair<QString, QString>> QtHostInterface::getAvailableLanguageList()
|
std::vector<std::pair<QString, QString>> QtHostInterface::getAvailableLanguageList()
|
||||||
{
|
{
|
||||||
return {{QStringLiteral("English"), QStringLiteral("")},
|
return {{QStringLiteral("English"), QStringLiteral("en")},
|
||||||
{QStringLiteral("Deutsch"), QStringLiteral("de")},
|
{QStringLiteral("Deutsch"), QStringLiteral("de")},
|
||||||
{QStringLiteral("Español"), QStringLiteral("es")},
|
{QStringLiteral("Español"), QStringLiteral("es")},
|
||||||
{QStringLiteral("Français"), QStringLiteral("fr")},
|
{QStringLiteral("Français"), QStringLiteral("fr")},
|
||||||
|
@ -129,7 +129,7 @@ void QtHostInterface::installTranslator()
|
||||||
|
|
||||||
std::string language = GetStringSettingValue("Main", "Language", "");
|
std::string language = GetStringSettingValue("Main", "Language", "");
|
||||||
if (language.empty())
|
if (language.empty())
|
||||||
return;
|
language = "en";
|
||||||
|
|
||||||
const QString path =
|
const QString path =
|
||||||
QStringLiteral("%1/translations/duckstation-qt_%3.qm").arg(qApp->applicationDirPath()).arg(language.c_str());
|
QStringLiteral("%1/translations/duckstation-qt_%3.qm").arg(qApp->applicationDirPath()).arg(language.c_str());
|
||||||
|
|
|
@ -0,0 +1,44 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!DOCTYPE TS>
|
||||||
|
<TS version="2.1" language="en_US">
|
||||||
|
<context>
|
||||||
|
<name>AudioSettingsWidget</name>
|
||||||
|
<message numerus="yes">
|
||||||
|
<source>Maximum Latency: %n frames (%1ms)</source>
|
||||||
|
<translation>
|
||||||
|
<numerusform>Maximum Latency: %n frame (%1ms)</numerusform>
|
||||||
|
<numerusform>Maximum Latency: %n frames (%1ms)</numerusform>
|
||||||
|
</translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>EmulationSettingsWidget</name>
|
||||||
|
<message numerus="yes">
|
||||||
|
<source>Rewind for %n frame(s), lasting %1 second(s) will require up to %2MB of RAM and %3MB of VRAM.</source>
|
||||||
|
<translation>
|
||||||
|
<numerusform>Rewind for %n frame, lasting %1 second(s) will require up to %2MB of RAM and %3MB of VRAM.</numerusform>
|
||||||
|
<numerusform>Rewind for %n frames, lasting %1 second(s) will require up to %2MB of RAM and %3MB of VRAM.</numerusform>
|
||||||
|
</translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>InputBindingWidget</name>
|
||||||
|
<message numerus="yes">
|
||||||
|
<source>%n bindings</source>
|
||||||
|
<translation>
|
||||||
|
<numerusform>%n binding</numerusform>
|
||||||
|
<numerusform>%n bindings</numerusform>
|
||||||
|
</translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
|
<context>
|
||||||
|
<name>MemoryCardEditorDialog</name>
|
||||||
|
<message numerus="yes">
|
||||||
|
<source>%n block(s) free%1</source>
|
||||||
|
<translation>
|
||||||
|
<numerusform>%n block free%1</numerusform>
|
||||||
|
<numerusform>%n blocks free%1</numerusform>
|
||||||
|
</translation>
|
||||||
|
</message>
|
||||||
|
</context>
|
||||||
|
</TS>
|
|
@ -0,0 +1,10 @@
|
||||||
|
@echo off
|
||||||
|
|
||||||
|
set "linguist=..\..\..\dep\msvc\qt\5.15.0\msvc2017_64\bin"
|
||||||
|
set context=../ ../../core/ ../../frontend-common/ -tr-function-alias translate+=TranslateString -tr-function-alias translate+=TranslateStdString -tr-function-alias QT_TRANSLATE_NOOP+=TRANSLATABLE -pluralonly
|
||||||
|
|
||||||
|
"%linguist%\lupdate.exe" %context% -ts duckstation-qt_en.ts
|
||||||
|
pause
|
||||||
|
|
||||||
|
cd "%linguist%"
|
||||||
|
start /B linguist.exe "%~dp0\duckstation-qt_en.ts"
|
Loading…
Reference in New Issue