Host: Add TranslatePluralToSmallString()

This commit is contained in:
Stenzek
2024-08-26 14:06:57 +10:00
parent 88e4bf6aad
commit c9f5cfc1bc
3 changed files with 31 additions and 1 deletions

View File

@ -4,6 +4,7 @@
#pragma once
#include "common/heap_array.h"
#include "common/small_string.h"
#include "common/types.h"
#include <ctime>
@ -62,6 +63,7 @@ std::string TranslateToString(std::string_view context, std::string_view msg);
/// Returns a localized version of the specified string within the specified context, adjusting for plurals using %n.
std::string TranslatePluralToString(const char* context, const char* msg, const char* disambiguation, int count);
SmallString TranslatePluralToSmallString(const char* context, const char* msg, const char* disambiguation, int count);
/// Clears the translation cache. All previously used strings should be considered invalid.
void ClearTranslationCache();
@ -79,8 +81,10 @@ s32 GetTranslatedStringImpl(std::string_view context, std::string_view msg, char
#define TRANSLATE_FS(context, msg) fmt::runtime(Host::TranslateToStringView(context, msg))
#define TRANSLATE_PLURAL_STR(context, msg, disambiguation, count) \
Host::TranslatePluralToString(context, msg, disambiguation, count)
#define TRANSLATE_PLURAL_SSTR(context, msg, disambiguation, count) \
Host::TranslatePluralToSmallString(context, msg, disambiguation, count)
#define TRANSLATE_PLURAL_FS(context, msg, disambiguation, count) \
fmt::runtime(Host::TranslatePluralToString(context, msg, disambiguation, count))
fmt::runtime(Host::TranslatePluralToSmallString(context, msg, disambiguation, count).view())
// Does not translate the string at runtime, but allows the UI to in its own way.
#define TRANSLATE_NOOP(context, msg) msg