mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 13:27:45 -07:00
Add helper function for fmt::format(GetStringT(...
This commit is contained in:
parent
d100c1dc37
commit
1084cfec1a
@ -9,6 +9,7 @@ find $SRCDIR -name '*.cpp' -o -name '*.h' -o -name '*.c' | \
|
|||||||
xgettext -d dolphin-emu -s --keyword=_ --keyword=wxTRANSLATE --keyword=SuccessAlertT \
|
xgettext -d dolphin-emu -s --keyword=_ --keyword=wxTRANSLATE --keyword=SuccessAlertT \
|
||||||
--keyword=PanicAlertT --keyword=PanicYesNoT --keyword=AskYesNoT --keyword=CriticalAlertT \
|
--keyword=PanicAlertT --keyword=PanicYesNoT --keyword=AskYesNoT --keyword=CriticalAlertT \
|
||||||
--keyword=GetStringT --keyword=_trans --keyword=tr:1,1t --keyword=tr:1,2c --keyword=QT_TR_NOOP \
|
--keyword=GetStringT --keyword=_trans --keyword=tr:1,1t --keyword=tr:1,2c --keyword=QT_TR_NOOP \
|
||||||
|
--keyword=FmtFormatT \
|
||||||
--add-comments=i18n -p ./Languages/po -o dolphin-emu.pot -f - --package-name="Dolphin Emulator" \
|
--add-comments=i18n -p ./Languages/po -o dolphin-emu.pot -f - --package-name="Dolphin Emulator" \
|
||||||
--from-code=utf-8
|
--from-code=utf-8
|
||||||
|
|
||||||
|
@ -5,6 +5,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
|
#include <fmt/format.h>
|
||||||
|
|
||||||
namespace Common
|
namespace Common
|
||||||
{
|
{
|
||||||
@ -30,6 +33,13 @@ bool MsgAlert(bool yes_no, MsgType style, const char* format, ...)
|
|||||||
#endif
|
#endif
|
||||||
;
|
;
|
||||||
void SetEnableAlert(bool enable);
|
void SetEnableAlert(bool enable);
|
||||||
|
|
||||||
|
// Like fmt::format, except the string becomes translatable
|
||||||
|
template <typename... Args>
|
||||||
|
std::string FmtFormatT(const char* string, Args&&... args)
|
||||||
|
{
|
||||||
|
return fmt::format(Common::GetStringT(string), std::forward<Args>(args)...);
|
||||||
|
}
|
||||||
} // namespace Common
|
} // namespace Common
|
||||||
|
|
||||||
#define SuccessAlert(format, ...) \
|
#define SuccessAlert(format, ...) \
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <fmt/format.h>
|
|
||||||
#include <zlib.h>
|
#include <zlib.h>
|
||||||
|
|
||||||
#include "Common/Assert.h"
|
#include "Common/Assert.h"
|
||||||
@ -256,9 +255,8 @@ static ConversionResultCode Output(OutputParameters parameters, File::IOFile* ou
|
|||||||
const int ratio =
|
const int ratio =
|
||||||
parameters.inpos == 0 ? 0 : static_cast<int>(100 * *position / parameters.inpos);
|
parameters.inpos == 0 ? 0 : static_cast<int>(100 * *position / parameters.inpos);
|
||||||
|
|
||||||
const std::string text =
|
const std::string text = Common::FmtFormatT("{0} of {1} blocks. Compression ratio {2}%",
|
||||||
fmt::format(Common::GetStringT("{0} of {1} blocks. Compression ratio {2}%"),
|
parameters.block_number, num_blocks, ratio);
|
||||||
parameters.block_number, num_blocks, ratio);
|
|
||||||
|
|
||||||
const float completion = static_cast<float>(parameters.block_number) / num_blocks;
|
const float completion = static_cast<float>(parameters.block_number) / num_blocks;
|
||||||
|
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
#include <string_view>
|
#include <string_view>
|
||||||
#include <unordered_set>
|
#include <unordered_set>
|
||||||
|
|
||||||
#include <fmt/format.h>
|
|
||||||
#include <mbedtls/md5.h>
|
#include <mbedtls/md5.h>
|
||||||
#include <mbedtls/sha1.h>
|
#include <mbedtls/sha1.h>
|
||||||
#include <pugixml.hpp>
|
#include <pugixml.hpp>
|
||||||
@ -521,7 +520,7 @@ bool VolumeVerifier::CheckPartition(const Partition& partition)
|
|||||||
m_volume.PartitionOffsetToRawOffset(0, partition) % VolumeWii::BLOCK_TOTAL_SIZE != 0)
|
m_volume.PartitionOffsetToRawOffset(0, partition) % VolumeWii::BLOCK_TOTAL_SIZE != 0)
|
||||||
{
|
{
|
||||||
AddProblem(Severity::Medium,
|
AddProblem(Severity::Medium,
|
||||||
fmt::format(Common::GetStringT("The {0} partition is not properly aligned."), name));
|
Common::FmtFormatT("The {0} partition is not properly aligned.", name));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_is_datel)
|
if (!m_is_datel)
|
||||||
@ -539,17 +538,15 @@ bool VolumeVerifier::CheckPartition(const Partition& partition)
|
|||||||
IOS::HLE::Device::ES::VerifyMode::DoNotUpdateCertStore,
|
IOS::HLE::Device::ES::VerifyMode::DoNotUpdateCertStore,
|
||||||
m_volume.GetTMD(partition), cert_chain))
|
m_volume.GetTMD(partition), cert_chain))
|
||||||
{
|
{
|
||||||
AddProblem(
|
AddProblem(Severity::Low,
|
||||||
Severity::Low,
|
Common::FmtFormatT("The {0} partition is not correctly signed.", name));
|
||||||
fmt::format(Common::GetStringT("The {0} partition is not correctly signed."), name));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_volume.SupportsIntegrityCheck() && !m_volume.CheckH3TableIntegrity(partition))
|
if (m_volume.SupportsIntegrityCheck() && !m_volume.CheckH3TableIntegrity(partition))
|
||||||
{
|
{
|
||||||
std::string text = fmt::format(
|
AddProblem(Severity::Low,
|
||||||
Common::GetStringT("The H3 hash table for the {0} partition is not correct."), name);
|
Common::FmtFormatT("The H3 hash table for the {0} partition is not correct.", name));
|
||||||
AddProblem(Severity::Low, std::move(text));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool invalid_disc_header = false;
|
bool invalid_disc_header = false;
|
||||||
@ -578,12 +575,11 @@ bool VolumeVerifier::CheckPartition(const Partition& partition)
|
|||||||
}
|
}
|
||||||
if (invalid_disc_header)
|
if (invalid_disc_header)
|
||||||
{
|
{
|
||||||
// This can happen when certain programs that create WBFS files scrub the entirety of
|
AddProblem(severity,
|
||||||
// the Masterpiece partitions in Super Smash Bros. Brawl without removing them from
|
// This can happen when certain programs that create WBFS files scrub the entirety of
|
||||||
// the partition table. https://bugs.dolphin-emu.org/issues/8733
|
// the Masterpiece partitions in Super Smash Bros. Brawl without removing them from
|
||||||
std::string text = fmt::format(
|
// the partition table. https://bugs.dolphin-emu.org/issues/8733
|
||||||
Common::GetStringT("The {0} partition does not seem to contain valid data."), name);
|
Common::FmtFormatT("The {0} partition does not seem to contain valid data.", name));
|
||||||
AddProblem(severity, std::move(text));
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -610,9 +606,8 @@ bool VolumeVerifier::CheckPartition(const Partition& partition)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string text = fmt::format(
|
AddProblem(severity,
|
||||||
Common::GetStringT("The {0} partition does not have a valid file system."), name);
|
Common::FmtFormatT("The {0} partition does not have a valid file system.", name));
|
||||||
AddProblem(severity, std::move(text));
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -670,7 +665,7 @@ std::string VolumeVerifier::GetPartitionName(std::optional<u32> type) const
|
|||||||
// (French), Clásicos (Spanish), Capolavori (Italian), 클래식 게임 체험판 (Korean).
|
// (French), Clásicos (Spanish), Capolavori (Italian), 클래식 게임 체험판 (Korean).
|
||||||
// If your language is not one of the languages above, consider leaving the string untranslated
|
// If your language is not one of the languages above, consider leaving the string untranslated
|
||||||
// so that people will recognize it as the name of the game mode.
|
// so that people will recognize it as the name of the game mode.
|
||||||
name = fmt::format(Common::GetStringT("{0} (Masterpiece)"), name);
|
name = Common::FmtFormatT("{0} (Masterpiece)", name);
|
||||||
}
|
}
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
@ -898,9 +893,8 @@ void VolumeVerifier::CheckMisc()
|
|||||||
// Hacked version of the Wii Backup Disc (aka "pinkfish" disc).
|
// Hacked version of the Wii Backup Disc (aka "pinkfish" disc).
|
||||||
std::string proper_game_id = game_id_unencrypted;
|
std::string proper_game_id = game_id_unencrypted;
|
||||||
proper_game_id[0] = '4';
|
proper_game_id[0] = '4';
|
||||||
AddProblem(Severity::Low,
|
AddProblem(Severity::Low, Common::FmtFormatT("The game ID is {0} but should be {1}.",
|
||||||
fmt::format(Common::GetStringT("The game ID is {0} but should be {1}."),
|
game_id_unencrypted, proper_game_id));
|
||||||
game_id_unencrypted, proper_game_id));
|
|
||||||
inconsistent_game_id = false;
|
inconsistent_game_id = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -954,9 +948,9 @@ void VolumeVerifier::CheckMisc()
|
|||||||
if (region == Region::NTSC_K && ios_id < 40 && ios_id != 4 && ios_id != 9 && ios_id != 21 &&
|
if (region == Region::NTSC_K && ios_id < 40 && ios_id != 4 && ios_id != 9 && ios_id != 21 &&
|
||||||
ios_id != 37)
|
ios_id != 37)
|
||||||
{
|
{
|
||||||
// This is intended to catch pirated Korean games that have had the IOS slot set to 36
|
// This is intended to catch Korean games (usually but not always pirated) that have the IOS
|
||||||
// as a side effect of having to fakesign after changing the common key slot to 0.
|
// slot set to 36 as a side effect of having to fakesign after changing the common key slot to
|
||||||
// (IOS36 was the last IOS to have the Trucha bug.) https://bugs.dolphin-emu.org/issues/10319
|
// 0. (IOS36 was the last IOS with the Trucha bug.) https://bugs.dolphin-emu.org/issues/10319
|
||||||
AddProblem(
|
AddProblem(
|
||||||
Severity::High,
|
Severity::High,
|
||||||
// i18n: You may want to leave the term "ERROR #002" untranslated,
|
// i18n: You may want to leave the term "ERROR #002" untranslated,
|
||||||
@ -967,7 +961,7 @@ void VolumeVerifier::CheckMisc()
|
|||||||
|
|
||||||
if (ios_id >= 0x80)
|
if (ios_id >= 0x80)
|
||||||
{
|
{
|
||||||
// This is also intended to catch fakesigned pirated Korean games,
|
// This is intended to catch the same kind of fakesigned Korean games,
|
||||||
// but this time with the IOS slot set to cIOS instead of IOS36.
|
// but this time with the IOS slot set to cIOS instead of IOS36.
|
||||||
AddProblem(Severity::High, Common::GetStringT("This title is set to use an invalid IOS."));
|
AddProblem(Severity::High, Common::GetStringT("This title is set to use an invalid IOS."));
|
||||||
}
|
}
|
||||||
@ -994,11 +988,10 @@ void VolumeVerifier::CheckMisc()
|
|||||||
{
|
{
|
||||||
// Many fakesigned WADs have the common key index set to a (random?) bogus value.
|
// Many fakesigned WADs have the common key index set to a (random?) bogus value.
|
||||||
// For WADs, Dolphin will detect this and use the correct key, making this low severity.
|
// For WADs, Dolphin will detect this and use the correct key, making this low severity.
|
||||||
std::string text = fmt::format(
|
AddProblem(Severity::Low,
|
||||||
// i18n: This is "common" as in "shared", not the opposite of "uncommon"
|
// i18n: This is "common" as in "shared", not the opposite of "uncommon"
|
||||||
Common::GetStringT("The specified common key index is {0} but should be {1}."),
|
Common::FmtFormatT("The specified common key index is {0} but should be {1}.",
|
||||||
specified_common_key_index, fixed_common_key_index);
|
specified_common_key_index, fixed_common_key_index));
|
||||||
AddProblem(Severity::Low, std::move(text));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1208,8 +1201,7 @@ void VolumeVerifier::Process()
|
|||||||
m_content_future = std::async(std::launch::async, [this, read_succeeded, content] {
|
m_content_future = std::async(std::launch::async, [this, read_succeeded, content] {
|
||||||
if (!read_succeeded || !m_volume.CheckContentIntegrity(content, m_data, m_ticket))
|
if (!read_succeeded || !m_volume.CheckContentIntegrity(content, m_data, m_ticket))
|
||||||
{
|
{
|
||||||
AddProblem(Severity::High,
|
AddProblem(Severity::High, Common::FmtFormatT("Content {0:08x} is corrupt.", content.id));
|
||||||
fmt::format(Common::GetStringT("Content {0:08x} is corrupt."), content.id));
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -1324,10 +1316,9 @@ void VolumeVerifier::Finish()
|
|||||||
if (blocks > 0)
|
if (blocks > 0)
|
||||||
{
|
{
|
||||||
const std::string name = GetPartitionName(m_volume.GetPartitionType(partition));
|
const std::string name = GetPartitionName(m_volume.GetPartitionType(partition));
|
||||||
std::string text =
|
AddProblem(Severity::Medium,
|
||||||
fmt::format(Common::GetStringT("Errors were found in {0} blocks in the {1} partition."),
|
Common::FmtFormatT("Errors were found in {0} blocks in the {1} partition.", blocks,
|
||||||
blocks, name);
|
name));
|
||||||
AddProblem(Severity::Medium, std::move(text));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1336,10 +1327,9 @@ void VolumeVerifier::Finish()
|
|||||||
if (blocks > 0)
|
if (blocks > 0)
|
||||||
{
|
{
|
||||||
const std::string name = GetPartitionName(m_volume.GetPartitionType(partition));
|
const std::string name = GetPartitionName(m_volume.GetPartitionType(partition));
|
||||||
std::string text = fmt::format(
|
AddProblem(Severity::Low,
|
||||||
Common::GetStringT("Errors were found in {0} unused blocks in the {1} partition."),
|
Common::FmtFormatT("Errors were found in {0} unused blocks in the {1} partition.",
|
||||||
blocks, name);
|
blocks, name));
|
||||||
AddProblem(Severity::Low, std::move(text));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1694,9 +1694,8 @@ ConversionResultCode WIARVZFileReader<RVZ>::RunCallback(size_t groups_written, u
|
|||||||
if (bytes_read != 0)
|
if (bytes_read != 0)
|
||||||
ratio = static_cast<int>(100 * bytes_written / bytes_read);
|
ratio = static_cast<int>(100 * bytes_written / bytes_read);
|
||||||
|
|
||||||
const std::string text =
|
const std::string text = Common::FmtFormatT("{0} of {1} blocks. Compression ratio {2}%",
|
||||||
fmt::format(Common::GetStringT("{0} of {1} blocks. Compression ratio {2}%"), groups_written,
|
groups_written, total_groups, ratio);
|
||||||
total_groups, ratio);
|
|
||||||
|
|
||||||
const float completion = static_cast<float>(bytes_read) / iso_size;
|
const float completion = static_cast<float>(bytes_read) / iso_size;
|
||||||
|
|
||||||
|
@ -677,7 +677,7 @@ std::string GameFile::GetFileFormatName() const
|
|||||||
{
|
{
|
||||||
std::string name = DiscIO::GetName(m_blob_type, true);
|
std::string name = DiscIO::GetName(m_blob_type, true);
|
||||||
if (m_is_nkit)
|
if (m_is_nkit)
|
||||||
name = fmt::format(Common::GetStringT("{0} (NKit)"), name);
|
name = Common::FmtFormatT("{0} (NKit)", name);
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user