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

DolphinQt: Enable RTL layout #8006

Merged
merged 3 commits into from Oct 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
674 changes: 674 additions & 0 deletions Externals/gettext/gettext-license.txt

Large diffs are not rendered by default.

Binary file removed Externals/gettext/libgettextlib.dll
Binary file not shown.
Binary file removed Externals/gettext/libgettextsrc.dll
Binary file not shown.
Binary file removed Externals/gettext/libiconv2.dll
Binary file not shown.
Binary file removed Externals/gettext/libintl3.dll
Binary file not shown.
Binary file modified Externals/gettext/msgfmt.exe
Binary file not shown.
2 changes: 1 addition & 1 deletion Languages/update-source-strings.sh
Expand Up @@ -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

Expand Down
24 changes: 23 additions & 1 deletion Source/Core/DolphinQt/Translation.cpp
Expand Up @@ -10,6 +10,7 @@
#include <algorithm>
#include <cstring>
#include <iterator>
#include <string>

#include "Common/File.h"
#include "Common/FileUtil.h"
Expand Down Expand Up @@ -213,7 +214,17 @@ class MoTranslator : public QTranslator
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:
Expand Down Expand Up @@ -291,6 +302,17 @@ static bool TryInstallTranslator(const QString& exact_language_code)

void Translation::Initialize()
{
// Let the translation select the GUI directionality. This is intentionally excluded
// from compilation, since all that matters is that xgettext sees it. We could use
// QT_TRANSLATE_NOOP3 instead of tr, but that doesn't compile correctly when put
// on a line of its own, so we would need to exclude it from compilation anyway.
#if 0
QGuiApplication::tr(
"QT_LAYOUT_DIRECTION",
"Translate this string to the string 'LTR' in left-to-right languages or to 'RTL' in "
"right-to-left languages (such as Hebrew and Arabic) to get proper widget layout.");
#endif

// Hook up Dolphin internal translation
Common::RegisterStringTranslator(
[](const char* text) { return QObject::tr(text).toStdString(); });
Expand Down