DolphinQt: Support gettext contexts (Qt disambiguations)

This commit is contained in:
JosJuice 2020-06-02 22:13:23 +02:00
parent 19ce87fa63
commit 74ae02f979
2 changed files with 13 additions and 2 deletions

View File

@ -8,7 +8,7 @@ SRCDIR=Source
find $SRCDIR -name '*.cpp' -o -name '*.h' -o -name '*.c' | \
xgettext -d dolphin-emu -s --keyword=_ --keyword=wxTRANSLATE --keyword=SuccessAlertT \
--keyword=PanicAlertT --keyword=PanicYesNoT --keyword=AskYesNoT --keyword=CriticalAlertT \
--keyword=GetStringT --keyword=_trans --keyword=tr --keyword=QT_TR_NOOP \
--keyword=GetStringT --keyword=_trans --keyword=tr:1,1t --keyword=tr:1,2c --keyword=QT_TR_NOOP \
--add-comments=i18n -p ./Languages/po -o dolphin-emu.pot -f - --package-name="Dolphin Emulator" \
--from-code=utf-8

View File

@ -10,6 +10,7 @@
#include <algorithm>
#include <cstring>
#include <iterator>
#include <string>
#include "Common/File.h"
#include "Common/FileUtil.h"
@ -213,7 +214,17 @@ public:
QString translate(const char* context, const char* source_text,
const char* disambiguation = nullptr, int n = -1) const override
{
return QString::fromUtf8(m_mo_file.Translate(source_text));
if (disambiguation)
{
std::string combined_string = disambiguation;
combined_string += '\4';
combined_string += source_text;
return QString::fromUtf8(m_mo_file.Translate(combined_string.c_str()));
}
else
{
return QString::fromUtf8(m_mo_file.Translate(source_text));
}
}
private: